Skip to content
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

Workflow to update IC #468

Merged
merged 19 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/update-ic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# A GitHub Actions workflow that regularly makes a PR to update
# the IC candid and code bindings.
name: Update IC
on:
schedule:
# Checks for new IC commit weekly
- cron: '30 3 * * MON'
workflow_dispatch:
# Provides an option to run this manually
ic_ref:
description: "The IC commit or tag to update to."
required: false
push:
branches:
# Runs if there is a change to the development branch for this workflow
- "update-ic"
jobs:
update-ic:
runs-on: ubuntu-latest
steps:
- name: Checkout ic-js
uses: actions/checkout@v3
- name: Choose IC ref
id: choose_ic_ref
run: |
ref="${{ inputs.ic_ref }}"
if [[ "${requested_ref:-}" == "" ]]
then # Use the latest release
ref="$(gh release --repo dfinity/ic view --json tagName -q .tagName)"
fi
echo "ic_ref=$ref" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
- name: Checkout ic repo
uses: actions/checkout@v3
with:
repository: dfinity/ic
ref: ${{ steps.choose_ic_ref.outputs.ic_ref }}
path: ic
- name: Check new IC commit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this step?

How about "Update candid and related JS and TS files"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

id: update
run: |
set -euxo pipefail
# Gets didc
echo "$PATH" | tr : "\n"
mkdir -p "$HOME/.local/bin"
curl -Lf https://github.com/dfinity/candid/releases/download/2023-09-27/didc-linux64 | install -m 755 /dev/stdin "$HOME/.local/bin/didc"
# Gets prettier in a minute
npm ci
# Gets candid
./scripts/import-candid ic
# Derives consequences
./scripts/compile-idl-js
# Checks whether it was all for nothing.
# ... Note: Ignores how we got here.
set +x # Printing the diff to stderr repeatedly can be very noisy.
DIFF_IGNORING_PROVENANCE="$(git diff -I '\/\/ Generated from IC repo.*')"
if [[ "${DIFF_IGNORING_PROVENANCE:-}" == "" ]]
then
commit="$(cd ic && git rev-parse --short HEAD)"
echo "No signficant differences found in IC ref ${{ inputs.ic_ref }} (commit $commit)."
echo "updated=0" >> "$GITHUB_OUTPUT"
else
echo "API changes detected!"
git status
echo "updated=1" >> "$GITHUB_OUTPUT"
fi
- name: Create Pull Request
if: ${{ steps.update.outputs.updated == '1' }}
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GIX_CREATE_PR_PAT }}
base: main
add-paths: |
packages/**/*.did
packages/**/*.js
packages/**/*.ts
commit-message: Update IC commit
committer: GitHub <[email protected]>
author: gix-bot <[email protected]>
branch: bot-ic-update
branch-suffix: timestamp # Creates a new branch & PR with every run. If this gets spammy, please delete this line and instead block the PR from making a PR if there is already an open one.
delete-branch: true
title: 'Update IC Candid Files'
body: |
# Motivation
The Internet Computer APIs have updated.

# Changes
* Updated the interface description files for the Internet Computer.
* Updated the javascript bindings for the latest IC interface.

# Tests
- [ ] Please check the API updates for any breaking changes that affect our code.
- name: Notify Slack on failure
# 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.
uses: dfinity/internet-identity/.github/actions/slack@release-2023-08-28
if: ${{ failure() }}
with:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MESSAGE: "IC commit update failed"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,6 @@ dist

# Built documentation
/docs/

# IC if checked out, e.g. in CI
/ic/
Loading