Str 774 Docs, tests and refactors #173
Workflow file for this run
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
# Runs unit tests. | |
name: Unit Tests | |
on: | |
pull_request: | |
merge_group: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
inputs: | |
RUST_LOG: | |
description: "Log level" | |
required: false | |
default: "info" | |
type: string | |
env: | |
CARGO_TERM_COLOR: always | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Run unit tests and generate report | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 # better fail-safe than the default 360 in github actions | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install bitcoind | |
env: | |
BITCOIND_VERSION: "28.0" | |
BITCOIND_ARCH: "x86_64-linux-gnu" | |
SHASUM: "7fe294b02b25b51acb8e8e0a0eb5af6bbafa7cd0c5b0e5fcbb61263104a82fbc" | |
run: | | |
curl -fsSLO --proto "=https" --tlsv1.2 "https://bitcoincore.org/bin/bitcoin-core-${{ env.BITCOIND_VERSION }}/bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" | |
sha256sum -c <<< "$SHASUM bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" | |
tar xzf "bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" | |
sudo install -m 0755 -t /usr/local/bin bitcoin-${{ env.BITCOIND_VERSION }}/bin/* | |
bitcoind --version | |
rm -rf "bitcoin-${{ env.BITCOIND_VERSION }}" "bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" | |
- name: Install llvm-tools-preview | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: llvm-tools-preview | |
toolchain: nightly-2024-11-01 | |
- name: Install latest nextest release | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: nextest | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-llvm-cov | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: true | |
- name: Set RUST_LOG | |
run: echo "RUST_LOG=${{ github.event.inputs.RUST_LOG }}" >> $GITHUB_ENV | |
- name: Install sqlx-cli | |
run: cargo install sqlx-cli --locked | |
- name: Run db migrations | |
run: make migrate | |
- name: Run tests with coverage | |
run: | | |
cargo llvm-cov --workspace nextest -F mock --profile ci --no-capture --lcov --output-path lcov.info | |
env: | |
DATABASE_URL: sqlite://./operator.db | |
RUST_BACKTRACE: 1 | |
SKIP_GUEST_BUILD: 1 | |
- name: Test Summary | |
uses: test-summary/action@v2 | |
if: always() | |
with: | |
paths: "target/nextest/ci/junit.xml" | |
- name: Publish Test Coverage | |
uses: codecov/codecov-action@v5.1.2 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
files: lcov.info | |
unit-success: | |
name: Check that unit tests pass | |
runs-on: ubuntu-latest | |
if: always() | |
needs: [test] | |
timeout-minutes: 60 | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} |