Skip to content

feat: e2e tests on live node (testnet) #6470

feat: e2e tests on live node (testnet)

feat: e2e tests on live node (testnet) #6470

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
DASEL_VERSION: https://github.com/TomWright/dasel/releases/download/v2.3.6/dasel_linux_amd64
RUSTFLAGS: "-D warnings"
FUEL_CORE_VERSION: 0.40.0
FUEL_CORE_PATCH_BRANCH: ""
FUEL_CORE_PATCH_REVISION: ""
RUST_VERSION: 1.79.0
FORC_VERSION: 0.65.2
FORC_PATCH_BRANCH: ""
FORC_PATCH_REVISION: ""
NEXTEST_HIDE_PROGRESS_BAR: "true"
NEXTEST_STATUS_LEVEL: "fail"
TEST_WALLET_SECRET_KEY_1: ${{ secrets.TEST_WALLET_SECRET_KEY_1 }}
TEST_WALLET_SECRET_KEY_2: ${{ secrets.TEST_WALLET_SECRET_KEY_2 }}
TEST_WALLET_SECRET_KEY_3: ${{ secrets.TEST_WALLET_SECRET_KEY_3 }}
jobs:
setup-test-projects:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
# selecting a toolchain either by action or manual `rustup` calls should happen
# before the cache plugin, as it uses the current rustc version as its cache key
- uses: buildjet/cache@v3
with:
prefix-key: "v1-rust"
- name: Set git config
run: |
git config --global core.bigfilethreshold 100m
- name: Install forc and forc-fmt
run: |
if [[ -n $FORC_PATCH_BRANCH ]]; then
cargo install --locked forc forc-fmt --git https://github.com/FuelLabs/sway --branch $FORC_PATCH_BRANCH
elif [[ -n $FORC_PATCH_REVISION ]]; then
cargo install --locked forc forc-fmt --git https://github.com/FuelLabs/sway --rev $FORC_PATCH_REVISION
else
curl -sSLf https://github.com/FuelLabs/sway/releases/download/v${{ env.FORC_VERSION }}/forc-binaries-linux_amd64.tar.gz -L -o forc.tar.gz
tar -xvf forc.tar.gz
chmod +x forc-binaries/forc
mv forc-binaries/forc /usr/local/bin/forc
mv forc-binaries/forc-fmt /usr/local/bin/forc-fmt
fi
- name: Check format of Sway test projects
run: forc fmt --check --path e2e
- name: Build Sway test projects
run: forc build --release --terse --error-on-warnings --path e2e
- uses: actions/upload-artifact@v4
with:
retention-days: 2
name: sway-examples
path: |
e2e/sway/**/out/*
get-workspace-members:
runs-on: buildjet-4vcpu-ubuntu-2204
outputs:
members: ${{ steps.set-members.outputs.members }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- id: set-members
run: |
# install dasel
curl -sSLf "$DASEL_VERSION" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
members=$(cat Cargo.toml | dasel -r toml -w json 'workspace.members' | jq -r ".[]" | xargs -I '{}' dasel -f {}/Cargo.toml 'package.name' | jq -R '[.]' | jq -s -c 'add')
echo "members=$members" >> $GITHUB_OUTPUT
verify-rust-version:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
# Ensure CI is using the same minimum toolchain specified in fuels Cargo.toml
- run: |
curl -sSLf "$DASEL_VERSION" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
MIN_VERSION=$(cat Cargo.toml | dasel -r toml 'workspace.package.rust-version' -w plain)
RUST_VERSION="${{ env.RUST_VERSION }}"
echo "Comparing minimum supported toolchain ($MIN_VERSION) with ci toolchain (RUST_VERSION)"
test "$MIN_VERSION" == "$RUST_VERSION"
# Fetch Fuel Core and upload as artifact, useful when we build the core from a
# revision so that we can repeat flaky tests without rebuilding the core.
fetch-fuel-core:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: wasm32-unknown-unknown
# selecting a toolchain either by action or manual `rustup` calls should happen
# before the cache plugin, as it uses the current rustc version as its cache key
- uses: buildjet/cache@v3
continue-on-error: true
with:
key: "fuel-core-build"
- name: Install Fuel Core
run: |
if [[ -n $FUEL_CORE_PATCH_BRANCH ]]; then
cargo install --locked fuel-core-bin --git https://github.com/FuelLabs/fuel-core --branch "$FUEL_CORE_PATCH_BRANCH" --root fuel-core-install
elif [[ -n $FUEL_CORE_PATCH_REVISION ]]; then
cargo install --locked fuel-core-bin --git https://github.com/FuelLabs/fuel-core --rev "$FUEL_CORE_PATCH_REVISION" --root fuel-core-install
else
curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ env.FUEL_CORE_VERSION }}/fuel-core-${{ env.FUEL_CORE_VERSION }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz
tar -xvf fuel-core.tar.gz
chmod +x fuel-core-${{ env.FUEL_CORE_VERSION }}-x86_64-unknown-linux-gnu/fuel-core
mkdir -p fuel-core-install/bin
mv fuel-core-${{ env.FUEL_CORE_VERSION }}-x86_64-unknown-linux-gnu/fuel-core fuel-core-install/bin/fuel-core
fi
- uses: actions/upload-artifact@v4
with:
name: fuel-core
path: fuel-core-install/bin/fuel-core
# Ensure workspace is publishable
publish-crates-check:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Publish crate check
uses: FuelLabs/publish-crates@v1
with:
dry-run: true
check-repo: false
ignore-unpublished-changes: true
cargo-verifications:
needs:
- setup-test-projects
- verify-rust-version
- get-workspace-members
- publish-crates-check
- fetch-fuel-core
runs-on: buildjet-4vcpu-ubuntu-2204
strategy:
matrix:
cargo_command: [check]
args: [--all-features]
package: ${{fromJSON(needs.get-workspace-members.outputs.members)}}
include:
- cargo_command: fmt
args: --all --verbose -- --check
- cargo_command: clippy
args: --all-targets
download_sway_artifacts: sway-examples
- cargo_command: nextest
args: run --all-targets --features "default fuel-core-lib coin-cache" --workspace --cargo-quiet --no-fail-fast
download_sway_artifacts: sway-examples
install_fuel_core: true
- cargo_command: nextest
args: run --all-targets --workspace --cargo-quiet --no-fail-fast
download_sway_artifacts: sway-examples
install_fuel_core: true
- cargo_command: nextest
args: run --package e2e --profile ci-testnet --no-fail-fast
download_sway_artifacts: sway-examples
install_fuel_core: true
target_testnet: true
if: |
(github.event_name == 'push' && github.event.base_ref == 'master') ||
(github.event_name == 'pull_request' && contains(github.event.head_commit.message, '[testnet]'))
- cargo_command: test
args: --doc --workspace
- cargo_command: machete
args: --skip-target-dir
- command: test_wasm
args:
- command: check_fuel_core_version
args:
- command: check_doc_anchors_valid
args:
- command: check_doc_unresolved_links
args:
- command: check_typos
args:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
components: clippy,rustfmt
targets: wasm32-unknown-unknown
# selecting a toolchain either by action or manual `rustup` calls should happen
# before the cache plugin, as it uses the current rustc version as its cache key
- uses: buildjet/cache@v3
continue-on-error: true
with:
key: "${{ matrix.cargo_command }} ${{ matrix.args }} ${{ matrix.package }}"
- name: Download Fuel Core
if: ${{ matrix.install_fuel_core }}
uses: actions/download-artifact@v4
with:
name: fuel-core
- name: Install Fuel Core
if: ${{ matrix.install_fuel_core }}
run: |
chmod +x fuel-core
mv fuel-core /usr/local/bin/fuel-core
- name: Download sway example artifacts
if: ${{ matrix.download_sway_artifacts }}
uses: actions/download-artifact@v4
with:
name: ${{ matrix.download_sway_artifacts }}
# Needed because `upload-artifact` will remove 'e2e/sway' because it is shared between all matched files
path: e2e/sway/
- name: Install nextest
if: ${{ matrix.cargo_command == 'nextest' }}
uses: taiki-e/install-action@nextest
- name: Install cargo-machete
if: ${{ matrix.cargo_command == 'machete' }}
uses: taiki-e/install-action@cargo-machete
- name: Cargo (workspace-level)
if: ${{ matrix.cargo_command && !matrix.package }}
run: cargo ${{ matrix.cargo_command }} ${{ matrix.args }}
- name: Cargo (workspace-level, testnet)
if: ${{ matrix.cargo_command && !matrix.package && matrix.target_testnet }}
env:
E2E_TARGET: testnet
run: cargo ${{ matrix.cargo_command }} ${{ matrix.args }}
- name: Cargo (package-level)
if: ${{ matrix.cargo_command && matrix.package }}
run: cargo ${{ matrix.cargo_command }} -p ${{ matrix.package }} ${{ matrix.args }}
- name: Install NodeJS for WASM testing
if: ${{ matrix.command == 'test_wasm' }}
uses: actions/setup-node@v3
with:
node-version: 18
- name: Test WASM
if: ${{ matrix.command == 'test_wasm' }}
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
cd wasm-tests
wasm-pack test --node
- name: Check that fuel_core version.rs file is up to date
if: ${{ matrix.command == 'check_fuel_core_version' }}
run: cargo run --bin fuel-core-version -- --manifest-path ./Cargo.toml verify
- name: Check for invalid documentation anchors
if: ${{ matrix.command == 'check_doc_anchors_valid' }}
run: cargo run --bin check-docs
- name: Check for unresolved documentation links
if: ${{ matrix.command == 'check_doc_unresolved_links' }}
run: |
! cargo doc --document-private-items |& grep -A 6 "warning: unresolved link to"
- name: Check for typos
if: ${{ matrix.command == 'check_typos' }}
uses: crate-ci/[email protected]
publish:
needs:
- cargo-verifications
- publish-crates-check
# Only do this job if publishing a release
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Verify tag version
run: |
curl -sSLf "$DASEL_VERSION" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} Cargo.toml
- name: Publish crate
uses: FuelLabs/publish-crates@v1
with:
publish-delay: 30000
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}