forked from dfinity/nns-dapp
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (110 loc) · 4.95 KB
/
update-proposals.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# 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"