Skip to content

Commit

Permalink
feat: Add workflow to update the aggregator (#3738)
Browse files Browse the repository at this point in the history
# Motivation
We need to render SNS data accurately, so need to keep the aggregator
SNS bindings up to date.

# Changes
- Add a bot to update the SNS aggregator bindings regularly.
  - Note: If the candid API has not changed, no new PR will be created.
- Note: The code is largely identical to the bot that updates the
proposals bindings and generally matches all the other update bots.

# Tests
- The one test run showed a breaking change that needed manual
intervention. The run correctly posted the error in slack and I have
made a PR with the manual changes.
- Run again and it correctly declared that no changes are needed:
https://github.com/dfinity/nns-dapp/actions/runs/6863398505/job/18663096004

# Todos

- [x] Add entry to changelog (if necessary).
  • Loading branch information
bitdivine committed Nov 14, 2023
1 parent 4907f27 commit 93ba0d3
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/update-aggregator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# A GitHub Actions workflow that regularly updates the aggregator SNS parsing code
# and creates a PR for any changes.
name: Update aggregator candid bindings
on:
schedule:
- cron: '30 3 * * *'
workflow_dispatch:
push:
branches:
# Run when the development branch for this workflow is updated.
- update-aggregator
jobs:
update-aggregator:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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: Update to the latest declared APIs
id: update
run: scripts/mk_nns_types.sh
- 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_BOT_PAT }}
commit-message: Update aggregator
committer: GitHub <noreply@github.com>
author: gix-bot <gix-bot@users.noreply.github.com>
base: main
# 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: rs/sns_aggregator/src/types/*
branch: bot-aggregator-update
branch-suffix: timestamp
delete-branch: true
title: 'Update aggregator'
body: |
# Motivation
We would like to parse all the latest SNS data.
# Changes
* Updated the Rust code derived from `.did` files in the aggregator.
* Note: The candid files under `declarations/nns-$CANISTER` are used as inputs.
# Tests
- [ ] Please check the API updates for any breaking changes that affect our code.
- name: Report on the action
# 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.
run: |
(
echo "## Aggregator 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 aggregator 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: "Aggregator update failed"
1 change: 1 addition & 0 deletions CHANGELOG-Nns-Dapp-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ proposal is successful, the changes it released will be moved from this file to

#### Added

* Add a workflow to update the SNS aggregator bindings regularly.
* Added support for global network config.
* Cron job to update proposal types.
* Enable dependabot for Rust updates.
Expand Down

0 comments on commit 93ba0d3

Please sign in to comment.