Identity Rebased alpha tracking hub #5211
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: Build and run tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [ opened, synchronize, reopened, ready_for_review ] | |
branches: | |
- main | |
- 'feat/**' | |
- 'support/**' | |
paths: | |
- '.github/workflows/build-and-test.yml' | |
- '.github/actions/**' | |
- '**.rs' | |
- '**.toml' | |
- 'bindings/**' | |
- '!bindings/**.md' | |
- 'bindings/wasm/README.md' # the Readme contain txm tests | |
env: | |
RUST_BACKTRACE: full | |
CARGO_INCREMENTAL: 0 # disabled to reduce target cache size and improve sccache (https://github.com/mozilla/sccache#known-caveats) | |
SCCACHE_CACHE_SIZE: 2G | |
SCCACHE_IDLE_TIMEOUT: 0 | |
# SCCACHE_RECACHE: 1 # uncomment to clear sccache cache, then re-comment | |
jobs: | |
check-for-run-condition: | |
runs-on: ubuntu-24.04 | |
outputs: | |
should-run: ${{ !github.event.pull_request || github.event.pull_request.draft == false }} | |
steps: | |
- run: | | |
# this run step does nothing, but is needed to get the job output | |
check-for-modification: | |
needs: check-for-run-condition | |
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} | |
runs-on: ubuntu-24.04 | |
outputs: | |
core-modified: ${{ steps.change-detection.outputs.core-modified }} # map step output to job output | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Run change detection | |
id: change-detection | |
run: | | |
echo comparing $(git rev-parse HEAD^) and $(git rev-parse HEAD) | |
#https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-emgitdiffemltoptionsgt--ltpathgt82308203 | |
if [[ $(git diff HEAD^ HEAD -- ':!bindings') != '' ]]; then | |
# modified | |
CORE_MODIFIED=true | |
else | |
# unmodified | |
CORE_MODIFIED=false | |
fi | |
echo CORE_MODIFIED=$CORE_MODIFIED | |
echo "core-modified=$CORE_MODIFIED" >> $GITHUB_OUTPUT | |
build-and-test: | |
runs-on: ${{ matrix.os }} | |
needs: [ check-for-run-condition, check-for-modification ] | |
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' && needs.check-for-modification.outputs.core-modified == 'true' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-24.04, macos-latest, windows-latest ] | |
include: | |
- os: ubuntu-24.04 | |
sccache-path: /home/runner/.cache/sccache | |
- os: macos-latest | |
sccache-path: /Users/runner/Library/Caches/Mozilla.sccache | |
- os: windows-latest | |
sccache-path: C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache\\cache | |
env: | |
SCCACHE_DIR: ${{ matrix.sccache-path }} | |
RUSTC_WRAPPER: sccache | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Ensure, OpenSSL is available in Windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append | |
vcpkg install openssl:x64-windows-static-md | |
- name: Setup Rust and cache | |
uses: './.github/actions/rust/rust-setup' | |
with: | |
os: ${{ runner.os }} | |
job: ${{ github.job }} | |
cargo-cache-enabled: true | |
target-cache-enabled: true | |
sccache-enabled: true | |
sccache-path: ${{ matrix.sccache-path }} | |
- name: Setup sccache | |
uses: './.github/actions/rust/sccache/setup-sccache' | |
with: | |
os: ${{matrix.os}} | |
- name: Check --no-default-features | |
if: matrix.os == 'ubuntu-24.04' | |
run: | | |
cargo metadata --format-version 1 | \ | |
jq -r '.workspace_members[]' | \ | |
awk '{print $1}' | \ | |
xargs -I {} cargo check -p {} --no-default-features | |
- name: Check default features | |
if: matrix.os == 'ubuntu-24.04' | |
run: | | |
cargo metadata --format-version 1 | \ | |
jq -r '.workspace_members[]' | \ | |
awk '{print $1}' | \ | |
xargs -I {} cargo check -p {} | |
# Clean debug target to avoid bloating the GitHub Actions cache. | |
# The previous builds cannot be re-used at all for the full --all-features --release build anyway. | |
- name: Clean target | |
if: matrix.os == 'ubuntu-24.04' | |
run: cargo clean | |
# Build the library, tests, and examples without running them to avoid recompilation in the run tests step | |
- name: Build with default features | |
run: cargo build --workspace --tests --examples --release | |
- name: Start iota sandbox | |
if: matrix.os != 'windows-latest' | |
uses: './.github/actions/iota-rebase-sandbox/setup' | |
with: | |
platform: ${{ matrix.os == 'ubuntu-24.04' && 'linux' || 'macos' }} | |
- name: publish IotaIdentity package | |
if: matrix.os != 'windows-latest' | |
# publish the package and set the IOTA_IDENTITY_PKG_ID env variable | |
run: | | |
json_output=$(iota client publish --skip-dependency-verification --with-unpublished-dependencies --json --gas-budget 500000000 .) | |
package_id=$(echo $json_output | jq --raw-output '.objectChanges[] | select(.type | contains("published")) | .packageId') | |
echo "IOTA_IDENTITY_PKG_ID=$package_id" >> "$GITHUB_ENV" | |
working-directory: ./identity_iota_core/packages/iota_identity | |
- name: Run tests excluding `custom_time` feature | |
if: matrix.os != 'windows-latest' | |
run: cargo test --workspace --release | |
- name: Run tests with `custom_time` feature | |
run: cargo test --test custom_time --features="custom_time" | |
- name: Run Rust examples | |
# run examples only on ubuntu for now | |
if: matrix.os == 'ubuntu-24.04' | |
run: | | |
cargo metadata --format-version 1 --manifest-path ./examples/Cargo.toml | \ | |
jq -r '.packages[] | select(.name == "examples") | .targets[].name' | \ | |
awk '$1 ~ /[0-9].*/' | \ | |
parallel -k -j 4 --retries 3 --joblog report.log ./target/release/examples/{} | |
cat report.log | |
- name: Run Rust Readme examples | |
# run examples only on ubuntu for now | |
if: matrix.os == 'ubuntu-24.04' | |
run: | | |
cd bindings/wasm | |
npm ci | |
npm run test:readme:rust | |
- name: Stop sccache | |
uses: './.github/actions/rust/sccache/stop-sccache' | |
with: | |
os: ${{matrix.os}} | |
build-wasm: | |
needs: check-for-run-condition | |
# if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} | |
if: ${{ false }} # disable for now, as the wasm bindings are not yet ready | |
# owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 | |
uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main | |
with: | |
output-artifact-name: identity-wasm-bindings-build | |
test-wasm: | |
needs: build-wasm | |
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-24.04 ] | |
include: | |
- os: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
- name: Install JS dependencies | |
run: npm ci | |
working-directory: bindings/wasm | |
- name: Download bindings/wasm artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: identity-wasm-bindings-build | |
path: bindings/wasm | |
- name: Start iota sandbox | |
uses: './.github/actions/iota-rebase-sandbox/setup' | |
- name: Run Wasm examples | |
run: npm run test:readme && npm run test:node | |
working-directory: bindings/wasm | |
test-wasm-firefox: | |
needs: build-wasm | |
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-24.04 ] | |
include: | |
- os: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
- name: Install JS dependencies | |
run: npm ci | |
working-directory: bindings/wasm | |
- name: Download bindings/wasm artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: identity-wasm-bindings-build | |
path: bindings/wasm | |
- name: Start iota sandbox | |
uses: './.github/actions/iota-rebase-sandbox/setup' | |
- name: Build Docker image | |
uses: docker/[email protected] | |
with: | |
context: bindings/wasm/ | |
file: bindings/wasm/cypress/Dockerfile | |
push: false | |
tags: cypress-test:latest | |
load: true | |
- name: Run cypress | |
run: docker run --network host cypress-test test:browser:parallel:firefox | |
test-wasm-chrome: | |
needs: build-wasm | |
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-24.04 ] | |
include: | |
- os: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
- name: Install JS dependencies | |
run: npm ci | |
working-directory: bindings/wasm | |
- name: Download bindings/wasm artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: identity-wasm-bindings-build | |
path: bindings/wasm | |
- name: Start iota sandbox | |
uses: './.github/actions/iota-rebase-sandbox/setup' | |
- name: Build Docker image | |
uses: docker/[email protected] | |
with: | |
context: bindings/wasm/ | |
file: bindings/wasm/cypress/Dockerfile | |
push: false | |
tags: cypress-test:latest | |
load: true | |
- name: Run cypress | |
run: docker run --network host cypress-test test:browser:parallel:chrome |