-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
83 deletions.
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 |
---|---|---|
@@ -1,119 +1,76 @@ | ||
# A GitHub Actions workflow that regularly updates the proposals rendering code | ||
# and creates a PR for any changes. | ||
name: Update proposals candid bindings | ||
# A GitHub Actions workflow that can be used to trigger updates of npm package | ||
# dependencies. | ||
name: Update next npm package dependencies | ||
on: | ||
schedule: | ||
# Check for updates on candid interface for the proposals every thursday at 3:30am. | ||
- cron: '30 3 * * MON' | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
# Run when the development branch for this workflow is updated. | ||
- update-proposals | ||
inputs: | ||
gix_components: | ||
description: 'Update gix-components' | ||
default: true | ||
type: boolean | ||
ic_js: | ||
description: 'Update ic-js' | ||
default: true | ||
type: boolean | ||
jobs: | ||
update-proposals: | ||
update-next-dependencies: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install didc | ||
run: | | ||
USER_BIN="$HOME/.local/bin" | ||
mkdir -p "$USER_BIN" | ||
echo "$USER_BIN" >> $GITHUB_PATH | ||
version="$(jq -r .defaults.build.config.DIDC_VERSION dfx.json)" | ||
# TODO: Make `didc` support `binstall`, then use `binstall` here. | ||
curl -Lf "https://github.com/dfinity/candid/releases/download/${version}/didc-linux64" | install -m 755 /dev/stdin "$USER_BIN/didc" | ||
- name: Find newer IC release, if any | ||
id: update | ||
run: | | ||
current_release="$(jq -r .defaults.build.config.IC_COMMIT_FOR_PROPOSALS dfx.json)" | ||
echo "Current IC release: $current_release" | ||
latest_release=$(curl -sSL https://api.github.com/repos/dfinity/ic/releases/latest | jq .tag_name -r) | ||
echo "Latest IC release: $latest_release" | ||
{ | ||
if [ "$current_release" == "$latest_release" ] | ||
then | ||
echo "updated=0" | ||
else | ||
echo "updated=1" | ||
echo "release=$latest_release" | ||
fi | ||
} >> "$GITHUB_OUTPUT" | ||
- name: Install sponge | ||
if: ${{ steps.update.outputs.updated == '1' }} | ||
run: sudo apt-get update -yy && sudo apt-get install -yy moreutils && command -v sponge | ||
- name: Update candid files | ||
if: ${{ steps.update.outputs.updated == '1' }} | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Install latest npm | ||
run: npm install -g npm@latest | ||
- name: Update gix-components | ||
if: ${{ inputs.gix_components }} | ||
run: | | ||
# Update candid files | ||
scripts/update_ic_commit --crate proposals --ic_commit "${{ steps.update.outputs.release }}" | ||
# Show changes | ||
echo "Git status:" | ||
git status | ||
echo "Note: The git diff is likely to be long so is not logged. Please see the PR." | ||
- name: Update to the latest declared APIs | ||
cd frontend | ||
npm run update:gix | ||
git commit -a -m "Bump gix-components" | ||
- name: Update ic-js | ||
if: ${{ inputs.ic_js }} | ||
run: | | ||
# Derive rust files | ||
./scripts/proposals/did2rs | ||
# Show changes | ||
echo "Git status:" | ||
git status | ||
echo "Note: The git diff may be long so is not logged. Please see the PR." | ||
cd frontend | ||
npm run upgrade:next | ||
git commit -a -m "Bump ic-js" | ||
- name: Create Pull Request | ||
id: cpr | ||
# Note: If there were no changes, this step creates no PR. | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ secrets.GIX_CREATE_PR_PAT }} | ||
commit-message: Update proposals | ||
commit-message: Bump | ||
committer: GitHub <[email protected]> | ||
author: gix-bot <[email protected]> | ||
branch: bot-proposals-update | ||
branch: bot-bump-next | ||
branch-suffix: timestamp | ||
reviewers: mstrasinskis, dskloetd | ||
# Note: Please be careful when updating the add-paths field. We have had the snsdemo committed by accident, with a pattern that matches nothing seemingly committing everything. | ||
add-paths: | | ||
dfx.json | ||
declarations/*/*.did | ||
rs/proposals/src/canisters/*/api.rs | ||
frontend | ||
delete-branch: true | ||
title: 'bot: Update proposals candid bindings' | ||
# Note: It is _likely_ but not guaranteed that the .did files match the `IC_COMMIT` in `dfx.json`. The files in the PR have a header that give this information reliably. | ||
# We do _not_ put a commit in the PR title as it could be misleading. | ||
title: 'bot: Bump' | ||
body: | | ||
# Motivation | ||
We want to pull in the latest changes. | ||
We would like to render all the latest proposal types. | ||
Even with no changes, just updating the reference is good practice. | ||
# Changes | ||
* Update the version of `IC_COMMIT_FOR_PROPOSALS` specified in `dfx.json`. | ||
* Updated the `proposals` candid files to the versions in that commit. | ||
* Updated the Rust code derived from `.did` files in the proposals payload rendering crate. | ||
${{ inputs.gix_components && '* Ran `npm run update:gix`' || '' }} | ||
${{ inputs.ic_js && '* Ran `npm run upgrade:next' || '' }} | ||
# Tests | ||
- [ ] Please check the API updates for any breaking changes that affect our code. | ||
- [ ] Please check for new proposal types and add tests for them. | ||
Breaking changes are: | ||
* New mandatory fields | ||
* Removing mandatory fields | ||
* Renaming fields | ||
* Changing the type of a field | ||
* Adding new variants | ||
# Since the this is a scheduled job, a failure won't be shown on any | ||
# PR status. To notify the team, we send a message to our Slack channel on failure. | ||
* CI should pass | ||
* The pulled in changes should have been tested before being committed to their repositories. | ||
- name: Report on the action | ||
run: | | ||
( | ||
echo "## Proposals Update" | ||
if test -n "${{ steps.cpr.outputs.pull-request-number }}" | ||
then echo "Created [PR #${{ steps.cpr.outputs.pull-request-number }}](${{ steps.cpr.outputs.pull-request-url }}) with proposal payload updates." | ||
then echo "Created [PR #${{ steps.cpr.outputs.pull-request-number }}](${{ steps.cpr.outputs.pull-request-url }})." | ||
else echo "No changes needed." | ||
fi | ||
) | tee -a $GITHUB_STEP_SUMMARY | ||
- name: Notify Slack on failure | ||
uses: dfinity/internet-identity/.github/actions/slack@release-2023-08-28 | ||
if: ${{ failure() }} | ||
with: | ||
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
MESSAGE: "Proposals update failed" |