shallow #41
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
name: Verify PR Commit | |
on: | |
pull_request: | |
branches: | |
- main | |
- "*-development" # Feature Branches should suffix with -development | |
push: | |
branches: | |
- ubicloud | |
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@0bc4621a3135347011ad047f9ecf449bf72ce2bd | |
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' | |
# 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: | |
network: [rococo, 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 | |
name: Verify Build Runtime for ${{matrix.network}} | |
env: | |
GIT_TRACE_PACKET: 1 | |
GIT_TRACE: 1 | |
GIT_CURL_VERBOSE: 1 | |
strategy: | |
fail-fast: false | |
matrix: | |
network: [dev, rococo, mainnet, dev, rococo, mainnet, dev, rococo, 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-rococo | |
- network: rococo | |
build-profile: release | |
package: frequency-runtime | |
runtime-dir: runtime/frequency | |
built-wasm-file-name-prefix: frequency_runtime | |
features: frequency-rococo-testnet | |
wasm-core-version: frequency-rococo | |
- 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 | |
- 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-rococo | |
- network: rococo | |
build-profile: release | |
package: frequency-runtime | |
runtime-dir: runtime/frequency | |
built-wasm-file-name-prefix: frequency_runtime | |
features: frequency-rococo-testnet | |
wasm-core-version: frequency-rococo | |
- 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 | |
- 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-rococo | |
- network: rococo | |
build-profile: release | |
package: frequency-runtime | |
runtime-dir: runtime/frequency | |
built-wasm-file-name-prefix: frequency_runtime | |
features: frequency-rococo-testnet | |
wasm-core-version: frequency-rococo | |
- 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: ubicloud-standard-4 | |
steps: | |
- name: Create tcpdump logs | |
run: | | |
sudo tcpdump -levni ens3 -w /home/runner/tcpdump.tcap & | |
pwd | |
ls -alh | |
- 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: | | |
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: Configure Git to use HTTP/1.1 | |
run: git config --global http.version HTTP/1.1 | |
- name: Set tcp_keepalive | |
run: | | |
sudo sysctl -w net.ipv4.tcp_keepalive_intvl=3 | |
sudo sysctl -w net.ipv4.tcp_keepalive_probes=500 | |
- name: Build Deterministic WASM | |
if: steps.cache-wasm.outputs.cache-hit != 'true' | |
run: | | |
GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_CURL_VERBOSE=1 RUST_LOG=debug SRTOOL_TAG="1.70.0" srtool build \ | |
--build-opts="'--features on-chain-release-build,no-metadata-docs,${{matrix.features}}'" \ | |
--profile=${{matrix.build-profile}} \ | |
--package=${{matrix.package}} \ | |
--root | |
--verbose | |
- 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) |