-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add workflow to update ic commit and ic artifacts in dfx cache
- Loading branch information
Jason I
committed
Apr 29, 2024
1 parent
2270eac
commit 888dba9
Showing
5 changed files
with
133 additions
and
0 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
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# Download latest ic artifacts | ||
curl -O "https://download.dfinity.systems/ic/$latest_sha/binaries/x86_64-linux/replica.gz" | ||
curl -O "https://download.dfinity.systems/ic/$latest_sha/binaries/x86_64-linux/canister_sandbox.gz" | ||
curl -O "https://download.dfinity.systems/ic/$latest_sha/binaries/x86_64-linux/ic-admin.gz" | ||
curl -O "https://download.dfinity.systems/ic/$latest_sha/binaries/x86_64-linux/ic-btc-adapter.gz" | ||
curl -O "https://download.dfinity.systems/ic/$latest_sha/binaries/x86_64-linux/ic-https-outcalls-adapter.gz" | ||
curl -O "https://download.dfinity.systems/ic/$latest_sha/binaries/x86_64-linux/ic-nns-init.gz" | ||
curl -O "https://download.dfinity.systems/ic/$latest_sha/binaries/x86_64-linux/ic-starter.gz" | ||
curl -O "https://download.dfinity.systems/ic/$latest_sha/binaries/x86_64-linux/sandbox_launcher.gz" | ||
curl -O "https://download.dfinity.systems/ic/$latest_sha/binaries/x86_64-linux/sns.gz" | ||
|
||
# Overwrite artifacts in dfx cache | ||
gzip -d replica.gz | ||
mv replica $(dfx cache show) | ||
gzip -d canister_sandbox.gz | ||
mv canister_sandbox $(dfx cache show) | ||
gzip -d ic-admin.gz | ||
mv ic-admin $(dfx cache show) | ||
gzip -d ic-btc-adapter.gz | ||
mv ic-btc-adapter $(dfx cache show) | ||
gzip -d ic-https-outcalls-adapter.gz | ||
mv ic-https-outcalls-adapter $(dfx cache show) | ||
gzip -d ic-nns-init.gz | ||
mv ic-nns-init $(dfx cache show) | ||
gzip -d ic-starter.gz | ||
mv ic-starter $(dfx cache show) | ||
gzip -d sandbox_launcher.gz | ||
mv sandbox_launcher $(dfx cache show) | ||
gzip -d sns.gz | ||
mv sns $(dfx cache show) |
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# A GitHub Actions workflow that regularly creates a pull request to update the IC artifacts | ||
name: IC Artifacts Update | ||
|
||
on: | ||
# TODO: remove `push` trigger. this is just for testing | ||
push: | ||
schedule: | ||
# create a new pull request every monday | ||
- cron: '0 0 * * MON' | ||
|
||
jobs: | ||
ic-update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# First, check if there is a newer version and update the file referencing the version | ||
- name: Check new ic version | ||
id: update | ||
run: | | ||
# Not all ic commits are built and released, so we go through the last commits until we found one | ||
# which has associated artefacts | ||
while read -r sha | ||
do | ||
echo "sha: $sha" | ||
# Send a HEAD to the URL to see if it exists | ||
if curl --fail --head --silent --location \ | ||
"https://download.dfinity.systems/ic/$sha/binaries/x86_64-linux/ic-test-state-machine.gz" | ||
then | ||
echo "$sha appears to have associated binary, using" | ||
latest_sha="$sha" | ||
break | ||
else | ||
echo "$sha does not seem to have associated binary" | ||
fi | ||
done < <(curl \ | ||
-SsL \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/dfinity/ic/commits | jq -cMr '.[] | .sha') | ||
# If we couldn't find any sha with associated artefacts, abort | ||
if [ -z "${latest_sha:-}" ] | ||
then | ||
echo no sha found | ||
exit 1 | ||
fi | ||
# Compare the current and latest shas, and potentially update the relevant files | ||
current_sha=$(sed <.ic-commit 's/#.*$//' | sed '/^$/d') | ||
echo current sha is "$current_sha" | ||
if [ "$current_sha" != "$latest_sha" ]; then | ||
echo "updating $current_sha to $latest_sha" | ||
sed -i -e \ | ||
"s/$current_sha/$latest_sha/g" \ | ||
".ic-commit" | ||
# This updates the download hint when tests are run with a missing binary | ||
sed -i -e \ | ||
"s/$current_sha/$latest_sha/g" \ | ||
"src/canister_tests/src/framework.rs" | ||
echo "updated=1" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "not updating $current_sha" | ||
echo "updated=0" >> "$GITHUB_OUTPUT" | ||
fi | ||
cat ".ic-commit" | ||
# If the ic commit was updated, create a PR. | ||
- name: Create Pull Request | ||
if: ${{ steps.update.outputs.updated == '1' }} | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GIX_BOT_PAT }} | ||
base: main | ||
add-paths: ./.ic-commit | ||
commit-message: Update commit of IC artifacts | ||
committer: GitHub <noreply@github.com> | ||
author: SDK <team-sdk@dfinity.org> | ||
branch: bot-ic-update | ||
delete-branch: true | ||
title: 'Update commit of IC artefacts' |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
63acf4f88b20ec0c6384f4e18f0f6f69fc5d9b9f |