-
Notifications
You must be signed in to change notification settings - Fork 68
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 #385
Open
Raghunath-S-S-J
wants to merge
14
commits into
master
Choose a base branch
from
feature/sdk-automation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d588de2
adds step in the pipeline
vigneshk-tw dcbefd4
removed exit code for testing
vigneshk-tw 885b430
re-ordered workflows
vigneshk-tw edd0523
final order
vigneshk-tw 0302af6
upgrade package versions
vigneshk-tw 4d5e089
removed empty test case files
vigneshk-tw b25810c
updates readme file
vigneshk-tw 112e935
testing --> dummy commit
vigneshk-tw 18c9aa6
Revert "testing --> dummy commit"
vigneshk-tw 93326f4
corrected php version
vigneshk-tw 94efaff
updates version
vigneshk-tw 513c770
corrected readme values
vigneshk-tw 1c61820
Merge pull request #376 from XeroAPI/PETOSS-518-Find-package-vulnerab…
vigneshk-tw 6ec08cf
ci: 576 Added the slack alert code
sangeet-joy-tw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}}" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Check Packagist Publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
check-publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: XeroAPI/xero-php-oauth2 | ||
path: xero-php-oauth2 | ||
|
||
- 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 "php_version=${latest_version}" >> $GITHUB_ENV | ||
working-directory: xero-php-oauth2 | ||
env: | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Get latest version from packgist | ||
id: get_packagist_version | ||
run: | | ||
RESPONSE=$(curl -s https://repo.packagist.org/p2/xeroapi/xero-php-oauth2.json) | ||
LATEST_VERSION=$(echo $RESPONSE | jq -r '.packages["xeroapi/xero-php-oauth2"][0].version') | ||
echo "latest packagist version: $LATEST_VERSION" | ||
echo "latest_packagist_version=${LATEST_VERSION}" >> $GITHUB_ENV | ||
|
||
- name: Compare versions | ||
id: compare_versions | ||
run: | | ||
if [ "${{env.php_version}}" == "${{env.latest_packagist_version}}" ]; then | ||
echo "Packagist is up-to-date" | ||
echo "packagist_status=success" >> $GITHUB_ENV | ||
else | ||
echo "Packagist is not updated yet" | ||
echo "packagist_status=failure" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Send slack Notification on Success | ||
if: ${{ env.packagist_status == 'success' }} | ||
uses: ./xero-php-oauth2/.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: ${{env.php_version}} | ||
repo_link: ${{github.server_url}}/${{github.repository}} | ||
|
||
- name: Send slack Notification on Failure | ||
if: ${{ env.packagist_status == 'failure' }} | ||
uses: ./xero-php-oauth2/.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: ${{env.php_version}} | ||
repo_link: ${{github.server_url}}/${{github.repository}} | ||
|
||
- name: Fail job if status is Failure | ||
if: ${{env.packagist_status == 'failure'}} | ||
run: | | ||
echo "Job failed because packagist is not updated" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite the jump and with Xero updating API responses server side that are validated against an hardcoded list client side (the last one being the identifier of the subscription plans) please consider keeping this range very wide. Or remove the hardcoded validations to avoid breaking existing installs on sites that haven't yet been able to run on later versions of php.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest bumping to support php version 7.1 as a minimum as that will allow you to use nullable parameters which you will need to get past errors like
on php 8.4 - see
https://wiki.php.net/rfc/deprecate-implicitly-nullable-types
and
https://www.php.net/manual/en/migration71.new-features.php