Update proposals candid bindings #143
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
# A GitHub Actions workflow that regularly updates the proposals rendering code | |
# and creates a PR for any changes. | |
name: Update proposals candid bindings | |
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 | |
jobs: | |
update-proposals: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install didc | |
run: scripts/install-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' }} | |
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 | |
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." | |
- name: Create Pull Request | |
id: cpr | |
# Note: If there were no changes, this step creates no PR. | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.GIX_CREATE_PR_PAT }} | |
commit-message: Update proposals | |
committer: GitHub <[email protected]> | |
author: gix-bot <[email protected]> | |
branch: bot-proposals-update | |
branch-suffix: timestamp | |
reviewers: mstrasinskis, dskloetd, yhabib | |
# 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 | |
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. | |
body: | | |
# Motivation | |
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. | |
# 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. | |
- 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." | |
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" |