Skip to content

Generate Solidity compatible metadata #3115

Generate Solidity compatible metadata

Generate Solidity compatible metadata #3115

Workflow file for this run

name: ci
on:
pull_request:
push:
branches:
- master
tags:
- v*
paths-ignore:
- 'README.md'
- 'CHANGELOG.md'
env:
# Image can be edited at https://github.com/use-ink/docker-images
IMAGE: useink/ci
CARGO_TARGET_DIR: /ci-cache/${{ github.repository }}/targets/${{ github.ref_name }}/${{ github.job }}
concurrency:
# Cancel in-progress jobs triggered only on pull_requests
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
set-image:
# GitHub Actions does not allow using 'env' in a container context.
# This workaround sets the container image for each job using the 'set-image' job output.
runs-on: ubuntu-latest
outputs:
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
steps:
- id: set_image
run: echo "IMAGE=${{ env.IMAGE }}" >> $GITHUB_OUTPUT
fmt:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check Formatting
run: |
cargo +nightly fmt --all -- --check
# Runs `cargo check` on each individual crate in the `crates` directory.
#
# This is required because the other commands build on the workspace level,
# or bring in `dev-dependencies` via the `test` target and it is possible
# for a crate to compile successfully in those cases, but fail when compiled
# on its own.
#
# Specifically, this happens where a dependency is missing features, but
# when building as part of the workspace or together with a `dev-dependency`
# those features are brought in via feature unification with another
# crate.
#
# When publishing, `cargo publish` will run a `check` on the individual
# crate being released. So this check is intended to catch any errors that
# may occur there, but otherwise would not be caught by the `test` and
# `clippy` commands which operate on the workspace and enable all targets.
check:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Checkout
uses: actions/checkout@v4
- name: Check each crate
run: |
for crate in ./crates/*/; do
echo "Checking $crate";
cargo check --manifest-path ${crate}/Cargo.toml;
done
clippy:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Checkout
uses: actions/checkout@v4
# Check permissions of GITHUB_TOKEN, workaround for permission issues
# with @dependabot PRs. See https://github.com/actions-rs/clippy-check/issues/2#issuecomment-807878478
- name: Check workflow permissions
id: check_permissions
uses: scherermichael-oss/[email protected]
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clippy with features
if: ${{ steps.check_permissions.outputs.has-permission }}
run: cargo +nightly clippy --all-features --all-targets -- -D warnings
- name: Clippy without features
if: ${{ steps.check_permissions.outputs.has-permission }}
run: cargo +nightly clippy --all-targets -- -D warnings
# Runs if the GITHUB_TOKEN does not have `write` permissions e.g. @dependabot
- name: Clippy with features (no annotations)
if: ${{ !steps.check_permissions.outputs.has-permission }}
run: cargo +nightly clippy --all-features --all-targets -- -D warnings
# Runs if the GITHUB_TOKEN does not have `write` permissions e.g. @dependabot
- name: Clippy without features (no annotations)
if: ${{ !steps.check_permissions.outputs.has-permission }}
run: cargo +nightly clippy --all-targets -- -D warnings
build-tests:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [ set-image ]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Install nextest
uses: taiki-e/[email protected]
with:
tool: nextest
- name: Build and archive tests
run: cargo nextest archive --workspace --all-features --archive-file nextest-archive-${{ matrix.os }}.tar.zst
- name: Upload archive to workflow
uses: actions/upload-artifact@v4
with:
name: nextest-archive-${{ matrix.os }}
path: nextest-archive-${{ matrix.os }}.tar.zst
run-tests:
needs: [ set-image, build-tests ]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
partition: [1, 2]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Install nextest
uses: taiki-e/[email protected]
with:
tool: nextest
- name: Download archive
uses: actions/download-artifact@v4
with:
name: nextest-archive-${{ matrix.os }}
- name: Run tests
run: cargo nextest run --archive-file nextest-archive-${{ matrix.os }}.tar.zst --partition count:${{ matrix.partition }}/2 -E 'not (test(integration_tests) | package(contract-build))'
- name: Run contract build tests
# The contract build tests cannot be run in parallel
run: cargo nextest run --archive-file nextest-archive-${{ matrix.os }}.tar.zst --partition count:${{ matrix.partition }}/2 -j 1 -E 'package(contract-build)'
run-integration-test:
needs: [ set-image, build-tests ]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
partition: [1, 2]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Install nextest
uses: taiki-e/[email protected]
with:
tool: nextest
- name: Download archive
uses: actions/download-artifact@v4
with:
name: nextest-archive-${{ matrix.os }}
- name: Run integration tests
# The integration tests cannot be run in parallel
run: cargo nextest run --archive-file nextest-archive-${{ matrix.os }}.tar.zst --partition count:${{ matrix.partition }}/2 -j 1 -E 'test(integration_tests)'
template:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04", "macos-15", "windows-2022"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-12-28
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
components: rust-src
- name: Check Template
run: >-
# The linter requires two crates
cargo install cargo-dylint dylint-link
cargo -vV &&
cargo run -- contract --version &&
cargo run -- contract new --target-dir ${{ runner.temp }} foobar &&
# Build with linting
cargo run -- contract build --lint --manifest-path=${{ runner.temp }}/foobar/Cargo.toml &&
cargo run -- contract check --manifest-path=${{ runner.temp }}/foobar/Cargo.toml &&
cargo run -- contract build --manifest-path=${{ runner.temp }}/foobar/Cargo.toml --release &&
# Run tests
cargo test --all-features -- --test-threads=1