Fix actions issues with artifacts #5140
Workflow file for this run
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: Verify PR Commit | |
concurrency: | |
group: ${{github.workflow}}-${{github.ref}} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: | |
- main | |
- "*-development" # Feature Branches should suffix with -development | |
env: | |
BIN_DIR: target/release | |
PR_LABEL_METADATA_CHANGED: metadata-changed | |
PR_LABEL_METADATA_VERSION_NOT_INCREMENTED: metadata-version-not-incremented | |
jobs: | |
changes: | |
name: Determine Changed Files | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
outputs: | |
rust: ${{steps.filter.outputs.rust}} | |
build-binary: ${{steps.filter.outputs.build-binary}} | |
cargo-lock: ${{steps.filter.outputs.cargo-lock}} | |
run-e2e: ${{steps.filter.outputs.run-e2e}} | |
ci-docker-image: ${{steps.filter.outputs.ci-docker-image}} | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Check for Changed Files | |
uses: dorny/paths-filter@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a | |
id: filter | |
with: | |
filters: | | |
rust: | |
- '**/*.rs' | |
- '**/*.hbs' | |
- '.rustfmt.toml' | |
- '**/Cargo.toml' | |
- '**/Cargo.lock' | |
build-binary: | |
- '**/*.rs' | |
- '**/*.hbs' | |
- '.rustfmt.toml' | |
- '**/Cargo.toml' | |
- '**/Cargo.lock' | |
- 'js/api-augment/**' | |
- 'e2e/**/*.{ts,json}' | |
cargo-lock: | |
- '**/Cargo.toml' | |
- '**/Cargo.lock' | |
run-e2e: | |
- '**/*.rs' | |
- '**/Cargo.toml' | |
- 'e2e/**/*.{ts,json}' | |
ci-docker-image: | |
- 'tools/ci/docker/ci-base-image.dockerfile' | |
clear-metadata-labels: | |
name: Clear Metadata Labels | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Clear Metadata Changed Label | |
if: contains(github.event.pull_request.labels.*.name, env.PR_LABEL_METADATA_CHANGED) | |
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
LABELS_TO_REMOVE: ${{env.PR_LABEL_METADATA_CHANGED}} | |
- name: Clear Metadata Version Not Incremented Label | |
if: contains(github.event.pull_request.labels.*.name, env.PR_LABEL_METADATA_VERSION_NOT_INCREMENTED) | |
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
LABELS_TO_REMOVE: ${{env.PR_LABEL_METADATA_VERSION_NOT_INCREMENTED}} | |
# Workaround to handle skipped required check inside matrix | |
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks | |
build-binaries-dummy: | |
needs: changes | |
if: needs.changes.outputs.build-binary != 'true' | |
runs-on: ubuntu-22.04 | |
name: Build ${{matrix.network}} Binary on ${{matrix.branch_alias}} Branch | |
strategy: | |
matrix: | |
# Match this to the real build-binaries job | |
include: | |
- network: dev | |
git_branch: ${{github.head_ref}} | |
spec: frequency-no-relay | |
branch_alias: pr | |
- network: local | |
git_branch: ${{github.head_ref}} | |
spec: frequency-local | |
branch_alias: pr | |
- network: local | |
git_branch: main | |
spec: frequency-local | |
branch_alias: main | |
- network: testnet | |
spec: frequency-testnet | |
branch_alias: pr | |
- network: mainnet | |
spec: frequency | |
branch_alias: pr | |
steps: | |
- run: echo "Just a dummy matrix to satisfy GitHub required checks that were skipped" | |
build-binaries: | |
needs: changes | |
if: needs.changes.outputs.build-binary == 'true' | |
name: Build ${{matrix.network}} Binary on ${{matrix.branch_alias}} Branch | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- network: dev | |
git_branch: ${{github.head_ref}} | |
spec: frequency-no-relay | |
branch_alias: pr | |
- network: local | |
git_branch: ${{github.head_ref}} | |
spec: frequency-local | |
branch_alias: pr | |
- network: local | |
git_branch: main | |
spec: frequency-local | |
branch_alias: main | |
- network: testnet | |
spec: frequency-testnet | |
branch_alias: pr | |
- network: mainnet | |
spec: frequency | |
branch_alias: pr | |
runs-on: [self-hosted, Linux, X64, build, v2] | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
env: | |
NETWORK: mainnet | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{matrix.git_branch}} | |
- name: Set Env Vars | |
run: | | |
export BUILT_BIN_FILENAME=frequency; echo "BUILT_BIN_FILENAME=$BUILT_BIN_FILENAME" >> $GITHUB_ENV | |
echo "FINAL_BIN_FILENAME=$BUILT_BIN_FILENAME.${{matrix.network}}.${{matrix.spec}}.${{matrix.branch_alias}}" >> $GITHUB_ENV | |
# # XXX Keep this step as it lets us skip full binary builds during development/testing | |
# - name: Cache Binary for Testing | |
# id: cache-binary | |
# uses: actions/cache@v3 | |
# with: | |
# path: ${{env.BIN_DIR}}/${{env.FINAL_BIN_FILENAME}} | |
# key: binaries-${{runner.os}}-${{env.NETWORK}}-${{github.head_ref}} | |
- name: Compile Binary | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
run: | | |
CARGO_INCREMENTAL=0 RUSTFLAGS="-D warnings" cargo build --locked --release \ | |
--features ${{matrix.spec}} | |
- name: Run Sanity Checks | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
file ${{env.BUILT_BIN_FILENAME}} && \ | |
./${{env.BUILT_BIN_FILENAME}} --version | |
- name: Rename Reference Binary | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
working-directory: ${{env.BIN_DIR}} | |
run: cp ${{env.BUILT_BIN_FILENAME}} ${{env.FINAL_BIN_FILENAME}} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-binary-${{matrix.network}}-${-${{github.run_id}} | |
path: ${{env.BIN_DIR}}/${{env.FINAL_BIN_FILENAME}}* | |
if-no-files-found: error | |
check-for-vulnerable-crates: | |
needs: changes | |
if: needs.changes.outputs.cargo-lock == 'true' | |
name: Check for Vulnerable Crates | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set Up Cargo Deny | |
run: | | |
cargo install --force --locked cargo-deny | |
cargo generate-lockfile | |
- name: Run Cargo Deny | |
run: cargo deny check --hide-inclusion-graph -c deny.toml | |
verify-rust-code-format: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Verify Rust Code Format | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Check | |
run: | | |
cargo +nightly-2024-03-01 fmt --check | |
lint-rust-code: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Lint Rust Code | |
runs-on: [self-hosted, Linux, X64, build, v2] | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Lint | |
run: | | |
SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy \ | |
--features runtime-benchmarks,frequency-lint-check \ | |
-- \ | |
-D warnings | |
verify-rust-developer-docs: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Verify Rust Developer Docs | |
runs-on: [self-hosted, Linux, X64, build, v2] | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Build Docs | |
run: | | |
rustup target add wasm32-unknown-unknown --toolchain nightly-2024-03-01 | |
RUSTDOCFLAGS="--enable-index-page --check -Zunstable-options" cargo +nightly-2024-03-01 doc --no-deps --features frequency | |
verify-rust-packages-and-deps: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Verify Rust Packages and Dependencies | |
runs-on: [self-hosted, Linux, X64, build, v2] | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Check | |
run: SKIP_WASM_BUILD= cargo check --features runtime-benchmarks,frequency-lint-check | |
run-rust-tests: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Run Rust Tests | |
runs-on: [self-hosted, Linux, X64, build, v2] | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Init Git | |
run: | | |
git config --global --add safe.directory /__w/frequency/frequency | |
- name: Run Tests | |
run: cargo test --features runtime-benchmarks,frequency-lint-check --workspace --release | |
calc-code-coverage: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Calculate Code Coverage | |
runs-on: [self-hosted, Linux, X64, build, v2] | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Generate and Upload Code Coverage | |
id: codecov | |
uses: ./.github/workflows/common/codecov | |
with: | |
code-cov-token: ${{ secrets.CODECOV_TOKEN }} | |
# Workaround to handle skipped required check inside matrix | |
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks | |
verify-build-runtimes-dummy: | |
needs: changes | |
if: needs.changes.outputs.rust != 'true' | |
name: Verify Build Runtime for ${{matrix.network}} | |
strategy: | |
matrix: | |
# Should match `verify-build-runtimes` | |
network: [dev, rococo, paseo, mainnet] | |
runs-on: ubuntu-22.04 | |
steps: | |
- run: echo "Just a dummy matrix to satisfy GitHub required checks that were skipped" | |
# Could not port this job to container because this creates docker-in-docker | |
# situation and fails when srtool-ci container is trying to process files in | |
# the mapped volume which don't exist on the host | |
verify-build-runtimes: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Verify Build Runtime for ${{matrix.network}} | |
strategy: | |
fail-fast: true | |
matrix: | |
# Remember, runtimes are separate for each relay chain | |
# We do not release frequency-*-local runtimes however | |
# Also should match `verify-build-runtimes-dummy` | |
network: [dev, rococo, paseo, mainnet] | |
include: | |
- network: dev | |
build-profile: release | |
package: frequency-runtime | |
runtime-dir: runtime/frequency | |
built-wasm-file-name-prefix: frequency_runtime | |
features: frequency-no-relay | |
wasm-core-version: frequency-testnet | |
- network: rococo | |
build-profile: release | |
package: frequency-runtime | |
runtime-dir: runtime/frequency | |
built-wasm-file-name-prefix: frequency_runtime | |
features: frequency-testnet | |
wasm-core-version: frequency-testnet | |
- network: paseo | |
build-profile: release | |
package: frequency-runtime | |
runtime-dir: runtime/frequency | |
built-wasm-file-name-prefix: frequency_runtime | |
features: frequency-testnet | |
wasm-core-version: frequency-testnet | |
- network: mainnet | |
build-profile: release | |
package: frequency-runtime | |
runtime-dir: runtime/frequency | |
built-wasm-file-name-prefix: frequency_runtime | |
features: frequency | |
wasm-core-version: frequency | |
runs-on: [self-hosted, Linux, X64, build, v2] | |
steps: | |
- name: Install Required Packages | |
run: | | |
sudo apt-get update | |
sudo apt install -y wget file build-essential curl | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Install Rust Toolchain | |
# Match installation steps to CI base docker image | |
run: | | |
curl https://sh.rustup.rs -sSf | bash -s -- -y | |
echo "PATH=$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV | |
- name: Extract Runtime Spec Version | |
run: | | |
echo "RUNTIME_SPEC_VERSION=$(awk '/spec_version:/ {match($0, /[0-9]+/); print substr($0, RSTART, RLENGTH); exit}' \ | |
${{matrix.runtime-dir}}/src/lib.rs)" >> $GITHUB_ENV | |
- name: Validate Extracted Version | |
shell: bash | |
run: | | |
echo "Runtime Spec Version: ${{env.RUNTIME_SPEC_VERSION}}" | |
[[ $RUNTIME_SPEC_VERSION == ?(-)+([0-9]) ]] || \ | |
(echo "ERROR: \"${{env.RUNTIME_SPEC_VERSION}}\" is not a valid integer" && exit 1) | |
- name: Set Env Vars | |
run: | | |
echo "WASM_DIR=${{matrix.runtime-dir}}/target/srtool/${{matrix.build-profile}}/wbuild/${{matrix.package}}" >> $GITHUB_ENV | |
echo "BUILT_WASM_FILENAME=${{matrix.built-wasm-file-name-prefix}}.compact.compressed.wasm" >> $GITHUB_ENV | |
# # XXX Keep this step as it lets us skip WASM builds during development/testing | |
# - name: Cache WASM for Testing | |
# id: cache-wasm | |
# uses: actions/cache@v3 | |
# with: | |
# path: ${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}} | |
# key: runtimes-${{runner.os}}-${{matrix.network}}-${{github.head_ref}} | |
- name: Install srtool-cli | |
if: steps.cache-wasm.outputs.cache-hit != 'true' | |
run: | | |
rustup show | |
cargo install --locked --git https://github.com/chevdor/srtool-cli | |
echo "PATH=$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV | |
- name: Test srtool-cli Install | |
run: | | |
echo "PATH: $PATH" | |
which srtool | |
srtool --version | |
- name: Build Deterministic WASM | |
if: steps.cache-wasm.outputs.cache-hit != 'true' | |
run: | | |
RUST_LOG=debug SRTOOL_TAG="1.75.0" srtool build \ | |
--build-opts="'--features on-chain-release-build,no-metadata-docs,${{matrix.features}}'" \ | |
--profile=${{matrix.build-profile}} \ | |
--package=${{matrix.package}} | |
- name: Check Deterministic WASM Build Exists | |
if: steps.cache-wasm.outputs.cache-hit != 'true' | |
run: file ${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}} | |
- name: Install Subwasm | |
run: | | |
cargo install --locked --git https://github.com/chevdor/subwasm --tag v0.19.1 --force | |
subwasm --version | |
- name: Test WASM file | |
run: | | |
subwasm info ${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}} | |
subwasm info ${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}} | grep "Core version:.*${{matrix.wasm-core-version}}-${{env.RUNTIME_SPEC_VERSION}}" || \ | |
(echo "ERROR: WASM Core version didn't match ${{matrix.wasm-core-version}}-${{env.RUNTIME_SPEC_VERSION}}" && exit 1) | |
verify-js-api-augment: | |
needs: build-binaries | |
name: Verify JS API Augment | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set Env Vars | |
run: | | |
echo "BIN_FILENAME=frequency.local.frequency-local.pr" >> $GITHUB_ENV | |
- name: Set up NodeJs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: "npm" | |
cache-dependency-path: js/api-augment/package-lock.json | |
- name: Install Latest Versions | |
run: npm install # DO NOT use `npm ci` as we want the latest polkadot/api possible | |
working-directory: js/api-augment | |
- name: Lint | |
run: npm run lint | |
working-directory: js/api-augment | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-*-${{github.run_id}} | |
path: ${{env.BIN_DIR}} | |
merge-multiple: true | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Set Binary Permissions | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
chmod 755 ${{env.BIN_FILENAME}} | |
- name: Output Metadata | |
run: ${{env.BIN_DIR}}/${{env.BIN_FILENAME}} export-metadata --chain=frequency-paseo-local --tmp ./js/api-augment/metadata.json | |
- name: Build | |
run: npm run build | |
working-directory: js/api-augment | |
- name: Test | |
run: npm test | |
working-directory: js/api-augment | |
- name: Build & Publish Dry Run | |
run: npm publish --dry-run | |
working-directory: js/api-augment/dist | |
- name: Generate npm tarball | |
run: npm pack | |
working-directory: js/api-augment/dist | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-api-augment-${{github.run_id}} | |
path: js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz | |
if-no-files-found: error | |
verify-node-docker-images: | |
needs: build-binaries | |
name: Verify Node Docker Images | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set Env Vars | |
run: | | |
echo "BUILT_BIN_FILENAME=frequency.mainnet.frequency.pr" >> $GITHUB_ENV | |
echo "DOCKER_BIN_FILENAME=frequency" >> $GITHUB_ENV | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-*-${{github.run_id}} | |
path: ${{env.BIN_DIR}} | |
merge-multiple: true | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Rename Binary | |
working-directory: ${{env.BIN_DIR}} | |
run: mv ${{env.BUILT_BIN_FILENAME}} ${{env.DOCKER_BIN_FILENAME}} | |
- name: Set Binary Permissions | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
chmod 755 ${{env.DOCKER_BIN_FILENAME}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: "amd64" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build collator image in instant seal mode | |
env: | |
IMAGE_NAME: instant-seal-node | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
file: ./docker/${{env.IMAGE_NAME}}.dockerfile | |
- name: Build collator standalone | |
env: | |
IMAGE_NAME: standalone-node | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
file: ./docker/${{env.IMAGE_NAME}}.dockerfile | |
- name: Build collator image for local relay chain | |
env: | |
IMAGE_NAME: collator-node-local | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
file: docker/${{env.IMAGE_NAME}}.dockerfile | |
verify-ci-docker-image: | |
needs: changes | |
if: needs.changes.outputs.ci-docker-image == 'true' | |
name: Verify CI Docker Image | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: "amd64" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build CI image | |
env: | |
IMAGE_PATH: tools/ci/docker | |
IMAGE_NAME: ci-base-image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
file: ${{env.IMAGE_PATH}}/${{env.IMAGE_NAME}}.dockerfile | |
execute-binary-checks: | |
needs: build-binaries | |
name: Execute Binary Checks | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set Env Vars | |
run: | | |
echo "TEST_BIN_FILENAME=frequency.mainnet.frequency.pr" >> $GITHUB_ENV | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-*-${{github.run_id}} | |
path: ${{env.BIN_DIR}} | |
merge-multiple: true | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Set Binary Permissions | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
chmod 755 ${{env.TEST_BIN_FILENAME}} | |
- name: Output Binary Version | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
file ./${{env.TEST_BIN_FILENAME}} && ./${{env.TEST_BIN_FILENAME}} --version | |
check-metadata-and-spec-version: | |
needs: build-binaries | |
name: Check Metadata and Spec Version | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set Env Vars | |
run: | | |
echo "TEST_BIN_FILENAME=frequency.local.frequency-local.pr" >> $GITHUB_ENV | |
echo "REF_BIN_FILENAME=frequency.local.frequency-local.main" >> $GITHUB_ENV | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-*-${{github.run_id}} | |
path: ${{env.BIN_DIR}} | |
merge-multiple: true | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Set Binary Permissions | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
chmod 755 $TEST_BIN_FILENAME | |
chmod 755 $REF_BIN_FILENAME | |
- name: Compare Metadata | |
id: compare-metadata | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
set -x | |
./$REF_BIN_FILENAME export-metadata --chain=frequency-paseo-local --tmp metadata-ref.json | |
metadata_ref=$(cat metadata-ref.json | jq -r .result) | |
./$TEST_BIN_FILENAME export-metadata --chain=frequency-paseo-local --tmp metadata.json | |
metadata=$(cat metadata.json | jq -r .result) | |
matches=$([ "$metadata" = "$metadata_ref" ] && echo 'true' || echo 'false') | |
echo "Metadata matches?: $match" | |
echo "metadata_matches=$matches" >> $GITHUB_OUTPUT | |
- name: Assign Metadata Changed Label | |
if: steps.compare-metadata.outputs.metadata_matches != 'true' | |
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
LABELS_TO_ADD: ${{env.PR_LABEL_METADATA_CHANGED}} | |
- name: Check Spec Version | |
if: steps.compare-metadata.outputs.metadata_matches != 'true' | |
id: check-spec-version | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
set -x | |
spec_version_ref=$(./$REF_BIN_FILENAME export-runtime-version | jq -r .specVersion) | |
spec_version=$(./$TEST_BIN_FILENAME export-runtime-version | jq -r .specVersion) | |
incremented=$([ $spec_version -gt $spec_version_ref ] && echo 'true' || echo 'false') | |
echo "spec_version_ref=$spec_version_ref" >> $GITHUB_OUTPUT | |
echo "spec_version=$spec_version" >> $GITHUB_OUTPUT | |
echo "metadata_version_incremented=$incremented" >> $GITHUB_OUTPUT | |
- name: Assign Metadata Version Not Incremented Label | |
if: | | |
(steps.compare-metadata.outputs.metadata_matches != 'true') && | |
(steps.check-spec-version.outputs.metadata_version_incremented != 'true') | |
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
LABELS_TO_ADD: ${{env.PR_LABEL_METADATA_VERSION_NOT_INCREMENTED}} | |
- name: Fail CI | |
if: | | |
(steps.compare-metadata.outputs.metadata_matches != 'true') && | |
(steps.check-spec-version.outputs.metadata_version_incremented != 'true') | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
spec_version=${{steps.check-spec-version.outputs.spec_version}} | |
spec_version_ref=${{steps.check-spec-version.outputs.spec_version_ref}} | |
echo "ERROR: When metadata is updated, the new spec version ($spec_version)\ | |
must be greater than the latest version on main branch ($spec_version_ref)" | |
exit 1 | |
run-e2e: | |
if: needs.changes.outputs.run-e2e == 'true' | |
needs: [build-binaries, verify-js-api-augment] | |
name: Run E2E Tests | |
runs-on: [self-hosted, Linux, X64, build, v2] | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set Env Vars | |
run: | | |
echo "BIN_FILENAME=frequency.dev.frequency-no-relay.pr" >> $GITHUB_ENV | |
echo "FREQUENCY_PROCESS_NAME=frequency" >> $GITHUB_ENV | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-*-${{github.run_id}} | |
path: ${{env.BIN_DIR}} | |
merge-multiple: true | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Download api-augment tarball | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts-api-augment-${{github.run_id}} | |
path: js/api-augment/dist | |
- name: Set Binaries Permissions | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
chmod 755 $BIN_FILENAME | |
- name: Start Local Node | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
./${{env.BIN_FILENAME}} \ | |
-lruntime=debug \ | |
--dev \ | |
--sealing=instant \ | |
--wasm-execution=compiled \ | |
--no-telemetry \ | |
--no-prometheus \ | |
--port $((30333)) \ | |
--rpc-port $((9944)) \ | |
--rpc-external \ | |
--rpc-cors all \ | |
--rpc-methods=Unsafe \ | |
--tmp \ | |
& | |
- name: Set up NodeJs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: "npm" | |
cache-dependency-path: e2e/package-lock.json | |
- name: Install Built api-augment | |
run: npm install ../js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz | |
working-directory: e2e | |
- name: Install NPM Modules | |
run: npm ci | |
working-directory: e2e | |
- name: Lint | |
run: npm run lint | |
working-directory: e2e | |
- name: Run E2E Tests | |
working-directory: e2e | |
env: | |
CHAIN_ENVIRONMENT: dev | |
WS_PROVIDER_URL: ws://127.0.0.1:9944 | |
run: npm test | |
- name: Stop Local Node | |
if: always() | |
run: pkill ${{env.FREQUENCY_PROCESS_NAME}} | |
verify-genesis-state: | |
needs: build-binaries | |
name: Verify Genesis State | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
steps: | |
- name: Set Env Vars | |
run: | | |
echo "EXPECTED_GENESIS_STATE_PASEO=0x000000000000000000000000000000000000000000000000000000000000000000d1912c5cd40e89fe2f4e1391801d17f6905cf84d961cbf4abb49139f03c2d85503170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV | |
echo "EXPECTED_GENESIS_STATE_ROCOCO=0x000000000000000000000000000000000000000000000000000000000000000000e3495742b019f5ad49dff7de4040bc965b75eaf46769c24db1027d4ff86fc92703170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV | |
echo "EXPECTED_GENESIS_STATE_MAINNET=0x000000000000000000000000000000000000000000000000000000000000000000393a2a0f7778716d006206c5a4787cbf2ea3b26a67379b7a38ee54519d7fd4be03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV | |
echo "BIN_FILENAME_TESTNET=frequency.testnet.frequency-testnet.pr" >> $GITHUB_ENV | |
echo "BIN_FILENAME_MAINNET=frequency.mainnet.frequency.pr" >> $GITHUB_ENV | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-*-${{github.run_id}} | |
path: ${{env.BIN_DIR}} | |
merge-multiple: true | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Set Binary Permissions | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
chmod 755 $BIN_FILENAME_TESTNET | |
chmod 755 $BIN_FILENAME_MAINNET | |
- name: Test Frequency Rococo Genesis State | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
expected_genesis_state=${{env.EXPECTED_GENESIS_STATE_ROCOCO}} | |
echo "Expected genesis state: $expected_genesis_state" | |
actual_genesis_state=$(./${{env.BIN_FILENAME_TESTNET}} export-genesis-state --chain=frequency-rococo) | |
echo "Actual genesis state: $actual_genesis_state" | |
[ $actual_genesis_state = $expected_genesis_state ] || \ | |
(echo "ERROR: The actual genesis state does not match the expected" && exit 1) | |
- name: Test Frequency Paseo Genesis State | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
expected_genesis_state=${{env.EXPECTED_GENESIS_STATE_PASEO}} | |
echo "Expected genesis state: $expected_genesis_state" | |
actual_genesis_state=$(./${{env.BIN_FILENAME_TESTNET}} export-genesis-state --chain=frequency-paseo) | |
echo "Actual genesis state: $actual_genesis_state" | |
[ $actual_genesis_state = $expected_genesis_state ] || \ | |
(echo "ERROR: The actual genesis state does not match the expected" && exit 1) | |
- name: Test Frequency Mainnet Genesis State | |
working-directory: ${{env.BIN_DIR}} | |
run: | | |
expected_genesis_state=${{env.EXPECTED_GENESIS_STATE_MAINNET}} | |
echo "Expected genesis state: $expected_genesis_state" | |
actual_genesis_state=$(./${{env.BIN_FILENAME_MAINNET}} export-genesis-state) | |
echo "Actual genesis state: $actual_genesis_state" | |
[ $actual_genesis_state = $expected_genesis_state ] || \ | |
(echo "ERROR: The actual genesis state does not match the expected" && exit 1) | |
should-run-benchmarks: | |
if: github.repository == 'LibertyDSNP/frequency' | |
name: Run Benchmarks? | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest | |
outputs: | |
should_run_benchmarks: ${{steps.run-benchmarks.outputs.run}} | |
pallets: ${{steps.run-benchmarks.outputs.pallets}} | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{github.event.pull_request.head.sha}} | |
- name: Run Benchmarks? | |
id: run-benchmarks | |
shell: bash | |
run: | | |
git config --global --add safe.directory /__w/frequency/frequency | |
commit_message=$(git show -s --format=%s) | |
echo "commit_message: $commit_message" | |
regex='\[run-benchmarks (.*)\]$' | |
if [[ $commit_message =~ $regex ]]; then | |
echo "Yes, need to run benchmarks." | |
pallets="${BASH_REMATCH[1]}" | |
echo "Pallets: $pallets" | |
echo "run=true" >> $GITHUB_OUTPUT | |
echo "pallets=$pallets" >> $GITHUB_OUTPUT | |
else | |
echo "No, do not need to run benchmarks." | |
echo "run=false" >> $GITHUB_OUTPUT | |
fi | |
run-benchmarks: | |
if: github.repository == 'LibertyDSNP/frequency' && | |
needs.should-run-benchmarks.outputs.should_run_benchmarks == 'true' | |
needs: should-run-benchmarks | |
name: Run Benchmarks | |
runs-on: [self-hosted, Linux, X64, benchmark] | |
steps: | |
- name: Print Info | |
run: | | |
echo "Running benchmarks..." | |
echo "Pallets: ${{needs.should-run-benchmarks.outputs.pallets}}" | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{secrets.GHA_GIT_COMMIT || github.token}} | |
ref: ${{github.event.pull_request.head.sha}} | |
- name: Get Current Job Log URL | |
id: jobs | |
uses: Tiryoh/gha-jobid-action@7528cee9716384209bafcbd000d6689e851c5dda | |
with: | |
github_token: ${{secrets.GITHUB_TOKEN}} | |
job_name: "Run Benchmarks" | |
- name: Set PR Commit Status to Pending | |
uses: ouzi-dev/commit-status-updater@219d3f932547cad092e384c7a36bf4d963739c35 | |
with: | |
name: "GithubActions - Run Benchmarks" | |
status: "pending" | |
addHoldComment: "true" | |
pendingComment: >- | |
:hourglass_flowing_sand: [Running benchmarks](${{steps.jobs.outputs.html_url}}) | |
and calculating weights. DO NOT MERGE! A new commit will be added upon completion... | |
failComment: "ERROR: Failed to set PR commit to pending status!" | |
- name: Install Required Packages | |
run: | | |
sudo apt-get update | |
sudo apt install -y protobuf-compiler libclang-dev clang cmake | |
- name: Install Rust Toolchain | |
# Match installation steps to CI base docker image | |
run: | | |
curl https://sh.rustup.rs -sSf | bash -s -- -y | |
echo "PATH=$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV | |
- name: Update Weights | |
run: | | |
rustup show | |
pallets_str="${{needs.should-run-benchmarks.outputs.pallets}}" | |
echo "Pallets: $pallets_str" | |
if [ -z "${pallets_str}" -o $pallets_str = 'all' ]; then | |
echo "Running benchmarks for all pallets..." | |
make benchmarks | |
else | |
IFS=',' read -r -a pallets <<< "$pallets_str" | |
echo "Running benchmarks for pallets: ${pallets[*]}..." | |
make benchmarks-multi PALLETS="${pallets[*]}" | |
echo "Finished benchmarks for pallets: ${pallets[*]}." | |
fi | |
- name: Print Updated Weights | |
run: | | |
git status | |
git diff | |
- name: Commit Updated Weights | |
id: commit-updated-weights | |
uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d | |
with: | |
commit_message: "Update weights for PR #${{github.event.pull_request.number}}" | |
commit_user_name: Frequency CI [bot] | |
commit_user_email: [email protected] | |
commit_author: Frequency CI [bot] <[email protected]> | |
- name: Set PR Commit Status to Success | |
uses: ouzi-dev/commit-status-updater@219d3f932547cad092e384c7a36bf4d963739c35 | |
with: | |
name: "GithubActions - Run Benchmarks" | |
status: "success" | |
addHoldComment: "true" | |
successComment: >- | |
:white_check_mark: [Finished running benchmarks](${{steps.jobs.outputs.html_url}}). | |
Updated weights have been committed to this PR branch in | |
commit ${{steps.commit-updated-weights.outputs.commit_hash}}. | |
failComment: "ERROR: Failed to set PR commit to success status!" |