-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use unified bootrap script and action (#688)
* Use unified bootrap script and action This adds a new bootstrap script and boostrap action, which calls the script. The script sets up rustup and ic-cdk-optimizer, and the action caches the ic-cdk-optimizer install. This has various direct and indirect benefits: * Dependencies can be installed and checked from a single place (see also https://github.com/github/scripts-to-rule-them-all) * The rust version is sourced from a single source of truth, `rust-toolchain.toml`, which itself has many benefits: * The rust version can be updated programatically * The build description now lives entirely in the actual codebase and not anymore in GHA workflow description files, meaning we can implement scheduled clean builds to check against the latest release without having potentially updated workflow descriptions interfering * GHA jobs can use the bootstrap action which DRYs the code; note that the action also caches ic-cdk-optimizer, which transparently reduces CI time from e.g. clean builds from 12mn to 5mn * Remove uname action
- Loading branch information
Showing
6 changed files
with
68 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: 'bootstrap' | ||
description: Bootstrap the Internet Identity build environment | ||
runs: | ||
using: "composite" | ||
steps: | ||
- id: uname | ||
shell: bash | ||
run: | | ||
# print include system info relevant for cache compatibility | ||
uname="$(uname -mpsr)" | ||
echo "uname value: $uname" | ||
uname_hash="$(echo "$uname" | shasum -a 256 | head -c 10)" | ||
echo "uname hash value: $uname_hash" | ||
echo "::set-output name=uname-hash::$uname_hash" | ||
# cache ic-cdk-optimizer | ||
# NOTE: here we make sure to only cache ic-cdk-optimizer and _not_ e.g. the cargo target, since in some cases | ||
# (clean builds) we build from scratch | ||
# NOTE: we include the output of uname to ensure binary compatibility (e.g. same glibc) | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.cargo/bin | ||
key: cargo-bin-${{ hashFiles('**/Cargo.lock', 'rust-toolchain.toml') }}-${{ steps.uname.outputs.uname-hash }} | ||
|
||
- name: Bootstrap | ||
shell: bash | ||
run: ./scripts/bootstrap |
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
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,30 @@ | ||
#!/usr/bin/env bash | ||
# install build dependencies (rustup + ic-cdk-optimizer) | ||
|
||
set -euo pipefail | ||
|
||
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
cd "$SCRIPTS_DIR/.." | ||
|
||
function run() { | ||
1>&2 echo "running $@" | ||
rc=0 && "$@" || rc="$?" | ||
if ! [ "$rc" -eq 0 ] | ||
then | ||
1>&2 echo "Bootstrap command failed: $@" | ||
exit "$rc" | ||
fi | ||
} | ||
|
||
rust_version=$(cat ./rust-toolchain.toml | sed -n 's/^channel[[:space:]]*=[[:space:]]"\(.*\)"/\1/p') | ||
echo "using rust version '$rust_version'" | ||
|
||
# here we set the toolchain to 'none' and rustup will pick up on ./rust-toolchain.toml | ||
run curl --fail https://sh.rustup.rs -sSf | run sh -s -- -y --default-toolchain "none" --no-modify-path | ||
|
||
echo "looking for ic-cdk-optimizer" | ||
if ! command -v ic-cdk-optimizer | ||
then | ||
echo "installing ic-cdk-optimizer" | ||
run cargo install ic-cdk-optimizer --version 0.3.1 | ||
fi |