Skip to content

Commit

Permalink
ci: add CI script for contract integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chungquantin committed Aug 22, 2024
1 parent 6482a43 commit c0fe680
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 3 deletions.
49 changes: 46 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: ci

on:
push:
branches: [ main ]
branches: [main]
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
types: [opened, synchronize, reopened, ready_for_review]

jobs:
lint:
Expand Down Expand Up @@ -67,6 +67,49 @@ jobs:
- name: Run integration tests
run: cargo test --release --locked --package integration-tests

contract-integration-tests:
env:
CONTRACT_INTEGRATION_TESTS: pop-api/integration-tests
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Download and run latest `substrate-contracts-node` binary
if: matrix.os == 'macOS-latest'
run: |
curl -L -o substrate-contracts-node.zip 'https://gitlab.parity.io/parity/mirrors/substrate-contracts-node/-/jobs/artifacts/main/download?job=build-mac' && \
unzip substrate-contracts-node.zip && \
chmod +x artifacts/substrate-contracts-node-mac/substrate-contracts-node &&
./artifacts/substrate-contracts-node-mac/substrate-contracts-node -linfo,runtime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &
- name: Install and run latest `substrate-contracts-node` binary
if: matrix.os == 'windows-latest'
run: |
cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force --locked && \
substrate-contracts-node -lruntime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3

- name: Install `cargo-contract` `master`
uses: baptiste0928/cargo-install@9f6037ed331dcf7da101461a20656273fa72abf0 # v3.1.0
with:
crate: cargo-contract
git: https://github.com/use-ink/cargo-contract.git
branch: master

- name: Output versions
run: |
cargo -vV
cargo contract --version
- name: Build contracts
run: cargo contract build --release
working-directory: ${{env.CONTRACT_INTEGRATION_TESTS}}

coverage:
needs: lint
runs-on: ubuntu-latest
Expand All @@ -86,4 +129,4 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: codecov.json
fail_ci_if_error: true
fail_ci_if_error: true
63 changes: 63 additions & 0 deletions .github/workflows/contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: contract

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
integration-tests:
env:
SUBCONTRACT_DIRECTORIES: "create_token_in_constructor fungibles"
CONTRACT_INTEGRATION_TESTS: pop-api/integration-tests
strategy:
matrix:
platform:
- macos-latest
- windows-latest
toolchain:
- stable
job:
- contract build
- test
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Download and run latest `substrate-contracts-node` binary
if: matrix.os == 'macOS-latest'
run: |
curl -L -o substrate-contracts-node.zip 'https://gitlab.parity.io/parity/mirrors/substrate-contracts-node/-/jobs/artifacts/main/download?job=build-mac' && \
unzip substrate-contracts-node.zip && \
chmod +x artifacts/substrate-contracts-node-mac/substrate-contracts-node &&
./artifacts/substrate-contracts-node-mac/substrate-contracts-node -linfo,runtime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &
- name: Install and run latest `substrate-contracts-node` binary
if: matrix.os == 'windows-latest'
run: |
cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force --locked && \
substrate-contracts-node -lruntime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &
- name: Install `cargo-contract` `master`
uses: baptiste0928/cargo-install@9f6037ed331dcf7da101461a20656273fa72abf0 # v3.1.0
with:
crate: cargo-contract
git: https://github.com/use-ink/cargo-contract.git
branch: master

- name: Output versions
run: |
cargo -vV
cargo contract --version
- name: ${{ matrix.job }} integration-tests on ${{ matrix.platform }}-${{ matrix.toolchain }}
working-directory: ${{env.CONTRACT_INTEGRATION_TESTS}}
run: |
for contract in ${SUBCONTRACT_DIRECTORIES}; do
echo "Processing contract: $contract";
cargo ${{ matrix.job }} --release --manifest-path contracts/${contract}/Cargo.toml;
done

0 comments on commit c0fe680

Please sign in to comment.