Files
stacks-puppet-node/.github/workflows/stacks-core-tests.yml
2024-03-21 13:10:21 -04:00

200 lines
6.2 KiB
YAML

## Github workflow to run full genesis and unit tests
name: Tests::Stacks Core
on:
workflow_call:
## env vars are transferred to composite action steps
env:
BITCOIND_TEST: 1
RUST_BACKTRACE: full
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
TEST_TIMEOUT: 30
concurrency:
group: stacks-core-tests-${{ github.head_ref || github.ref || github.run_id }}
## Only cancel in progress if this is for a PR
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# Full genesis test with code coverage
full-genesis:
name: Full Genesis Test
runs-on: ubuntu-latest
strategy:
## Continue with the test matrix even if we've had a failure
fail-fast: false
## Run a maximum of 2 concurrent tests from the test matrix
max-parallel: 2
matrix:
test-name:
- neon_integrations::bitcoind_integration_test
steps:
## Setup test environment
- name: Setup Test Environment
id: setup_tests
uses: stacks-network/actions/stacks-core/testenv@main
with:
genesis: true
btc-version: "25.0"
## Run test matrix using restored cache of archive file
## - Test will timeout after env.TEST_TIMEOUT minutes
- name: Run Tests
id: run_tests
timeout-minutes: ${{ fromJSON(env.TEST_TIMEOUT) }}
uses: stacks-network/actions/stacks-core/run-tests@main
with:
test-name: ${{ matrix.test-name }}
threads: 1
archive-file: ~/genesis_archive.tar.zst
## Upload code coverage file
- name: Code Coverage
id: codecov
uses: stacks-network/actions/codecov@main
with:
test-name: large_genesis
filename: ./lcov.info
- name: Status Output
run: |
echo "run_tests: ${{ steps.run_tests.outputs.status }}"
echo "codecov: ${{ steps.codecov.outputs.status }}"
- name: Check Failures
if: steps.run_tests.outputs.status == 'failure' || steps.codecov.outputs.status == 'failure'
run: exit 1
# Unit tests with code coverage
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
## Continue the workflow in case a step fails (ex a single test fails)
continue-on-error: true
strategy:
## Continue the workflow in case a step fails (ex a single test fails)
fail-fast: false
matrix:
## Partition the tests into 8 jobs
## - This is used in a later step when running `cargo nextest run ... --partition count:num/8`
partition: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
## Setup test environment
- name: Setup Test Environment
id: setup_tests
uses: stacks-network/actions/stacks-core/testenv@main
with:
btc-version: "25.0"
## Run test matrix using restored cache of archive file
## - Test will timeout after env.TEST_TIMEOUT minutes
- name: Run Tests
id: run_tests
timeout-minutes: ${{ fromJSON(env.TEST_TIMEOUT) }}
uses: stacks-network/actions/stacks-core/run-tests/partition@main
with:
partition: ${{ matrix.partition }}
total-partitions: 8
## Create and upload code coverage file
- name: Code Coverage
id: codecov
uses: stacks-network/actions/codecov@main
with:
test-name: ${{ matrix.test-name }}
## Generate and upload openapi html artifact
open-api-validation:
name: OpenAPI Validation
runs-on: ubuntu-latest
steps:
- name: OpenAPI
id: openapi
uses: stacks-network/actions/openapi@main
with:
input: ./docs/rpc/openapi.yaml
output: ./open-api-docs.html
## Disabled
## - this test can take several hours to run
nettest:
if: ${{ false }}
name: Net-Test
runs-on: ubuntu-latest
steps:
## checkout the code
- name: Checkout the latest code
id: git_checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Run network relay tests
id: nettest
env:
DOCKER_BUILDKIT: 1
run: docker build -f ./.github/actions/bitcoin-int-tests/Dockerfile.net-tests .
# Core contract tests
core-contracts-clarinet-test:
name: Core Contracts Test
defaults:
run:
working-directory: "./contrib/core-contract-tests/"
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
id: git_checkout
uses: actions/checkout@v3
- name: Execute core contract unit tests with clarinet-sdk
id: clarinet_unit_test
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "npm"
cache-dependency-path: "./contrib/core-contract-tests/package-lock.json"
- run: npm ci -f # need to force the update as long as we are using a beta version of the clarinet-sdk
- run: npm test
## Upload code coverage file
- name: Code Coverage
id: codecov
uses: stacks-network/actions/codecov@main
with:
# We'd like to uncomment the below line once the codecov upload is working
# fail_ci_if_error: true
test-name: ${{ matrix.test-name }}
upload-only: true
filename: ./contrib/core-contract-tests/lcov.info
# Core contract tests on Clarinet v1
# Check for false positives/negatives
core-contracts-clarinet-test-clarinet-v1:
name: Core Contracts Test Clarinet V1
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
id: git_checkout
uses: actions/checkout@v3
- name: Execute core contract unit tests in Clarinet
id: clarinet_unit_test_v1
uses: docker://hirosystems/clarinet:1.7.1
with:
args: test --manifest-path=./contrib/core-contract-tests/Clarinet.toml contrib/core-contract-tests/tests/bns/name_register_test.ts
check-tests:
name: Check Tests
runs-on: ubuntu-latest
if: always()
needs:
- full-genesis
- unit-tests
- open-api-validation
- core-contracts-clarinet-test
steps:
- name: Check Tests Status
id: check_tests_status
uses: stacks-network/actions/check-jobs-status@main
with:
jobs: ${{ toJson(needs) }}
summary_print: "true"