Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automating SDK generation process #398

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
a9529f3
replaced postman URL with PRISM Url for Accounting YML
Sep 13, 2024
4df0162
replace POSTMAN url with PRISM url for appstore related tests
Sep 13, 2024
fb295c4
Fixed issues w.r to Assets, Bankfeed yml
Sep 13, 2024
1b5bbdd
fixed test cases with Finance.yml
Sep 13, 2024
19d8b04
fixed test cases related to payroll UK APIs
Sep 20, 2024
8ee3e80
Fixed test cases with payroll nz api
Sep 20, 2024
f133c1b
Fixed test cases in project api
Sep 20, 2024
5119b37
Fixed test cases in payroll au api
Sep 20, 2024
9c2a680
fixed final issue findings
Sep 20, 2024
770bd4e
removed unused code
Sep 20, 2024
8efad97
PETOS-560 Adds Content Type for API Calls
Sep 23, 2024
4b860f6
Fixed review comment - Set content type only if it is available
Sep 24, 2024
2b6b528
Merge branch 'master' of https://github.com/XeroAPI/Xero-Java into fi…
Sep 24, 2024
59008a8
Merge branch 'master' of https://github.com/XeroAPI/Xero-Java into fi…
Sep 24, 2024
8ff765e
updated values from zero
Sep 24, 2024
90d068c
adds config file and reference from config file
Sep 24, 2024
024c46f
fixed review comments
Sep 24, 2024
ecd5581
simplified getting classes
Sep 24, 2024
334678d
removed duplicate codes
Sep 24, 2024
3f9c14c
fixed review comments - remove duplicates
Sep 24, 2024
349b76e
Updated Readme.md file for running test cases
Sep 24, 2024
7d19f0c
Merge pull request #385 from XeroAPI/PETOSS-560-Update-existing-tests…
vigneshk-tw Sep 24, 2024
5f0112b
Merge branch 'master' of https://github.com/XeroAPI/Xero-Java into fi…
Sep 24, 2024
7dcdd2f
Merge pull request #384 from XeroAPI/fix/replace-postman-with-prism
vigneshk-tw Sep 24, 2024
cfbe8c1
Merge branch 'master' of https://github.com/XeroAPI/Xero-Java into fi…
Sep 24, 2024
f6c1cbb
Merge pull request #383 from XeroAPI/fix/replace-postman-with-prism-p…
vigneshk-tw Sep 24, 2024
d0a28a4
remove duplicate content type setting
Sep 24, 2024
b209452
Replaced byte content type by binary for octet-stream
Sep 25, 2024
8932890
initial commit
Sep 30, 2024
86faf0a
export gpg key
Sep 30, 2024
ac44e53
adds gpg passphrase as one input
Sep 30, 2024
d193628
adds a step to configure maven settings
Sep 30, 2024
70e8fda
simplified by having a separate settings.xml file
Sep 30, 2024
a15f876
adds working directory
Sep 30, 2024
3c84688
make the pipeline run only when release is created
Sep 30, 2024
f3bfe77
final commit
Sep 30, 2024
d2bc4eb
corrected review comments
Sep 30, 2024
516515d
corrected getting secrets
Sep 30, 2024
b224011
adds gpg passphrase in secret
Sep 30, 2024
ab0cad3
corrected build pipeline
Sep 30, 2024
09a5166
Merge pull request #387 from XeroAPI/PETOSS-533-Publish-Java-SDK-afte…
vigneshk-tw Sep 30, 2024
b603234
initial commit
vigneshk-tw Oct 4, 2024
8d914c8
removed passphrase variable from java installation
vigneshk-tw Oct 4, 2024
b8a2f23
corrected the environment variable name for gpg passphrase
vigneshk-tw Oct 4, 2024
9481ae0
fixed some other dependencies
vigneshk-tw Oct 4, 2024
304be26
Merge pull request #389 from XeroAPI/PETOSS-516-Find-package-vulnerab…
vigneshk-tw Oct 4, 2024
78bbe0a
ci: Added slack alert
Oct 21, 2024
d7187c1
ci: clean up
Oct 21, 2024
4e112c4
initial commit
vigneshk-tw Oct 23, 2024
f085eff
skip running tests
vigneshk-tw Oct 23, 2024
4505f93
ci: testing the successflow
Oct 23, 2024
3940e80
ci: reverted the testing changes
Oct 23, 2024
7883f7f
ci: jira-576 Added the slack alert code
sangeet-joy-tw Oct 23, 2024
6e3d72f
Merge branch 'master' into PETOSS-585-Enable-Test-Step-in-Code-Gen-an…
vigneshk-tw Oct 24, 2024
af2dac3
Merge branch 'master' of https://github.com/XeroAPI/Xero-Java into fi…
vigneshk-tw Oct 25, 2024
7d098b9
remove skipping tests
vigneshk-tw Oct 25, 2024
139cee2
remove check for prism kill
vigneshk-tw Oct 28, 2024
95918ed
Merge pull request #391 from XeroAPI/PETOSS-585-Enable-Test-Step-in-C…
vigneshk-tw Oct 28, 2024
4db21db
Merge branch 'master' into fix/replace-byte-by-binary
vigneshk-tw Nov 4, 2024
6855f41
Merge pull request #386 from XeroAPI/fix/replace-byte-by-binary
vigneshk-tw Nov 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/actions/notify-slack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: slack-alert-action
description: "Action to send slack payload to public-sdk-events channel"

inputs:
heading_text:
required: true
description: "Heading of the slack payload"
alert_type:
required: true
description: "type of the slack alert"
job_status:
required: true
description: "status of the job"
XERO_SLACK_WEBHOOK_URL:
required: true
description: "webhook url for channel - public-sdk-events"
job_url:
required: true
description: "job run id link"
button_type:
required: true
description: "color for the check logs button"
package_version:
required: true
description: "released package version"
repo_link:
required: true
description: "link of the repo"


runs:
using: "composite"

steps:

- name: Send slack notification
id: slack
uses: slackapi/[email protected]
env:
SLACK_WEBHOOK_URL: ${{inputs.XERO_SLACK_WEBHOOK_URL}}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"blocks": [
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "${{inputs.heading_text}} ",
"style": {
"bold": true
}
},
{
"type": "emoji",
"name": "${{inputs.alert_type}}"
}
]
}
]
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Repository:* \n ${{inputs.repo_link}}"
},
{
"type": "mrkdwn",
"text": "*Status:*\n ${{inputs.job_status}}"
},
{
"type": "mrkdwn",
"text": "*Package Version:*\n ${{inputs.package_version}}"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Check the logs",
"emoji": true
},
"style": "${{inputs.button_type}}",
"url": "${{inputs.job_url}}"
}
]
}
]
}
20 changes: 19 additions & 1 deletion .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -27,8 +27,26 @@ jobs:
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY}}

- name: Set up Node environment
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install Prism
run: npm install -g @stoplight/prism-cli

- name: Start PRISM Server
run: ./start-prism.sh & sleep 15
working-directory: Xero-Java/src/test/java/com/xero/api/util

- name: Build and test post generation
run: |
export GPG_TTY=$(tty)
mvn clean verify -DskipTests=true -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }}
mvn clean verify
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
working-directory: Xero-Java

- name: Stop PRISM
run: pkill -f prism
working-directory: Xero-Java
104 changes: 104 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Publish
on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest

outputs:
release_number: ${{steps.get_latest_release_number.outputs.release_tag}}
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout Xero-Java repo
uses: actions/checkout@v4
with:
repository: XeroAPI/Xero-Java
path: Xero-Java

- name: Set up JDK environment
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: maven
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-passphrase: GPG_PASSPHRASE

- name: Fetch Latest release number
id: get_latest_release_number
run: |
latest_version=$(gh release view --json tagName --jq '.tagName')
echo "Latest release version is - $latest_version"
echo "::set-output name=release_tag::$latest_version"
working-directory: Xero-Java
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Import GPG Key
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY}}

- name: Publish to Maven
run: |
export GPG_TTY=$(tty)
mvn clean deploy -DskipTests=true
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
working-directory: Xero-Java

notify-slack-on-success:
runs-on: ubuntu-latest
needs: publish
if: success()
steps:
- name: Checkout Xero-Java repo
uses: actions/checkout@v4
with:
repository: XeroAPI/Xero-Java
path: Xero-Java

- name: Send slack notification on success
uses: ./Xero-Java/.github/actions/notify-slack
with:
heading_text: "Publish job has succeeded !"
alert_type: "thumbsup"
job_status: "Success"
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}}
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
button_type: "primary"
package_version: ${{needs.publish.outputs.release_number}}
repo_link: ${{github.server_url}}/${{github.repository}}

notify-slack-on-failure:
runs-on: ubuntu-latest
needs: publish
if: failure()
steps:
- name: Checkout Xero-Java repo
uses: actions/checkout@v4
with:
repository: XeroAPI/Xero-Java
path: Xero-Java

- name: Send slack notification on failure
uses: ./Xero-Java/.github/actions/notify-slack
with:
heading_text: "Publish job has failed !"
alert_type: "alert"
job_status: "Failed"
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}}
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
button_type: "danger"
package_version: ${{needs.publish.outputs.release_number}}
repo_link: ${{github.server_url}}/${{github.repository}}
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ The **Xero-Java** SDK makes it easy for developers to access Xero's APIs in thei
- [App Store Subscriptions](#app-store-subscriptions)
- [API Clients](#api-clients)
- [Usage Examples](#usage-examples)
- [Running Test(s) in Local](#running-tests-in-local)
- [SDK conventions](#sdk-conventions)
- [Participating in Xero’s developer community](#participating-in-xeros-developoer-community)

@@ -677,7 +678,17 @@ try {
System.out.println(e.getMessage());
}
```
## Running Test(s) in Local
For Running Test cases PRISM Mock Server needs to be started in the local machine.
Steps to Run Test(s)
* Install PRISM from npm using the command: **npm install -g @stoplight/prism-cli**
* Verify Installation: **prism --version**
* Navigate to **Xero-Java--> src--> test--> util** folder in the terminal
* Execute the script **./start-prism.sh**
* This will start the PRISM Server in Local
* Run **mvn clean verify -DskipTests=false** to build the Java code along with Test Cases.

---
## SDK conventions

### Working with dates
Loading