Skip to content

develop

develop #2

Workflow file for this run

## The main Github Actions workflow
name: CI
on:
merge_group:
types:
- checks_requested
push:
branches:
- master
- develop
paths-ignore:
- "**.md"
- "**.yml"
workflow_dispatch:
pull_request:
types:
- opened
- reopened
- synchronize
defaults:
run:
shell: bash
concurrency:
group: ci-${{ github.head_ref || github.ref || github.run_id }}
## Always cancel duplicate jobs
cancel-in-progress: true
run-name: ${{ github.ref_name }}
jobs:
##
## Jobs to execute everytime workflow runs
## do not run if the trigger is any of the following:
## - PR review submitted (not approved)
## and any of:
## - PR review comment
## - PR change is requested
rustfmt:
name: Rust Format
runs-on: ubuntu-latest
steps:
- name: Rustfmt
id: rustfmt
uses: stacks-network/actions/rustfmt@main
with:
alias: "fmt-stacks"
changelog-check:
name: Changelog Check
uses: ./.github/workflows/changelog-check.yml
######################################################################################
## Check if the branch that this workflow is being run against is a release branch
##
## Outputs:
## - node_tag: Tag of the stacks-node if the branch is a release one (example: release/3.4.0.0.1), null otherwise
## - node_docker_tag: Version of the stacks-node if the branch is a release one (example: 3.4.0.0.1), null otherwise
## - signer_tag: Tag of the stacks-signer if the branch is a release one (example: release/3.4.0.0.1.0), null otherwise
## - signer_docker_tag: Version of the stacks-signer if the branch is a release one (example: 3.4.0.0.1.0), null otherwise
## - is_node_release: True if the branch represents a 'stacks-node' release, false otherwise.
## If this is true, 'is_signer_release' will also be true, since a 'stacks-signer' binary
## is always released alongside 'stacks-node'.
## - is_signer_release: True if the branch represents a 'stacks-signer' release, false otherwise.
check-release:
name: Check Release
needs:
- rustfmt
- changelog-check
runs-on: ubuntu-latest
outputs:
node_tag: ${{ steps.check_release.outputs.node_tag }}
node_docker_tag: ${{ steps.check_release.outputs.node_docker_tag }}
signer_tag: ${{ steps.check_release.outputs.signer_tag }}
signer_docker_tag: ${{ steps.check_release.outputs.signer_docker_tag }}
is_node_release: ${{ steps.check_release.outputs.is_node_release }}
is_signer_release: ${{ steps.check_release.outputs.is_signer_release }}
steps:
- name: Check Release
id: check_release
uses: stacks-network/actions/stacks-core/release/check-release@main
with:
tag: ${{ github.ref_name }}
######################################################################################
## Create a tagged github release
##
## Runs when:
## - it is either a node release or a signer release
## create-release will call the reusable workflows to:
# - build the binary artifacts
# - create the release docker images
# - create the github release.
create-release:
if: |
needs.check-release.outputs.is_node_release == 'true' ||
needs.check-release.outputs.is_signer_release == 'true'
name: Create Release
needs:
- rustfmt
- changelog-check
- check-release
secrets: inherit
uses: ./.github/workflows/release-github.yml
with:
node_tag: ${{ needs.check-release.outputs.node_docker_tag }} # 5 place version format like x.x.x.x.x
signer_tag: ${{ needs.check-release.outputs.signer_docker_tag }} # 6 place version format like x.x.x.x.x.x
is_node_release: ${{ needs.check-release.outputs.is_node_release }} # used in matrix conitional in release-github.yml
## Create a reusable cache for tests
##
## Runs when:
## - it is a node release run
## or any of:
## - this workflow is called manually
## - PR is opened
## - PR added to merge queue
create-cache:
if: |
needs.check-release.outputs.is_node_release == 'true' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
github.event_name == 'merge_group'
name: Create Test Cache
needs:
- rustfmt
- changelog-check
- check-release
uses: ./.github/workflows/create-cache.yml
## Tests to run regularly
##
## Runs when:
## - it is a node or signer-only release run
## or any of:
## - this workflow is called manually
## - PR is opened
## - PR added to merge queue
stacks-core-tests:
if: |
needs.check-release.outputs.is_node_release == 'true' ||
needs.check-release.outputs.is_signer_release == 'true' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
github.event_name == 'merge_group'
name: Stacks Core Tests
needs:
- rustfmt
- changelog-check
- create-cache
- check-release
uses: ./.github/workflows/stacks-core-tests.yml
## Validate constants dumped by stacks-inspect
##
## Runs when:
## - it is a node or signer-only release run
## or any of:
## - this workflow is called manually
## - PR is opened
## - PR added to merge queue
constants-check:
if: |
needs.check-release.outputs.is_node_release == 'true' ||
needs.check-release.outputs.is_signer_release == 'true' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
github.event_name == 'merge_group'
name: Constants Check
needs:
- rustfmt
- changelog-check
- check-release
uses: ./.github/workflows/constants-check.yml
## Checks to run on built binaries
##
## Runs when:
## - it is a node or signer-only release run
## or any of:
## - this workflow is called manually
## - PR is opened
## - PR added to merge queue
cargo-hack-check:
if: |
needs.check-release.outputs.is_node_release == 'true' ||
needs.check-release.outputs.is_signer_release == 'true' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
github.event_name == 'merge_group'
name: Cargo Hack Check
needs:
- rustfmt
- changelog-check
- check-release
uses: ./.github/workflows/cargo-hack-check.yml
## Checks to run on built binaries
##
## Runs when:
## - it is a node release run
## or any of:
## - this workflow is called manually
## - PR is opened
## - PR added to merge queue
bitcoin-tests:
if: |
needs.check-release.outputs.is_node_release == 'true' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
github.event_name == 'merge_group'
name: Bitcoin Tests
needs:
- rustfmt
- changelog-check
- create-cache
- check-release
uses: ./.github/workflows/bitcoin-tests.yml
## Checks to run on built binaries
##
## Runs when:
## - it is a node release run
## or any of:
## - this workflow is called manually
## - PR is opened
## - PR added to merge queue
bitcoin-rpc-tests:
if: |
needs.check-release.outputs.is_node_release == 'true' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
github.event_name == 'merge_group'
name: Bitcoin RPC Tests
needs:
- rustfmt
- create-cache
- check-release
uses: ./.github/workflows/bitcoin-rpc-tests.yml
p2p-tests:
if: |
needs.check-release.outputs.is_node_release == 'true' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
github.event_name == 'merge_group'
name: P2P Tests
needs:
- rustfmt
- changelog-check
- create-cache
- check-release
uses: ./.github/workflows/p2p-tests.yml
## Test to run on a tagged release
##
## Runs when:
## - it is a node release run
epoch-tests:
if: needs.check-release.outputs.is_node_release == 'true'
name: Epoch Tests
needs:
- rustfmt
- changelog-check
- create-cache
- check-release
uses: ./.github/workflows/epoch-tests.yml
## Merge and upload code coverage report files once all tests are done
##
## Runs when:
## - always (unless workflow is cancelled OR either blockchain or core tests are skipped)
trigger-code-coverage-report:
if: always() && !cancelled() && !contains(needs.stacks-core-tests.result, 'skipped') && !contains(needs.bitcoin-tests.result, 'skipped')
name: Merge & Upload Code Coverage Report
runs-on: ubuntu-latest
needs:
- stacks-core-tests
- bitcoin-tests
- p2p-tests
- epoch-tests
env:
REPORT_FILES_DIR: "code_coverage_files"
REPORT_FILES_EXT: "info"
REPORT_MERGE_CHUNK_SIZE: 80
steps:
# Checkout the code (Coveralls requires source code to be available when action is called)
- name: Checkout the latest code
id: git_checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# Download the code coverage .info files generated by tests from artifacts (prefixed by commit SHA)
- name: Download code coverage artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # 8.0.1
with:
pattern: ${{ github.sha }}-*.${{ env.REPORT_FILES_EXT }}
path: ${{ env.REPORT_FILES_DIR }}
merge-multiple: true
# Check for at least 1 code coverage files
- name: Check for at least 1 code coverage file
shell: bash
run: |
EXT="${{ env.REPORT_FILES_EXT }}"
DIR="${{ env.REPORT_FILES_DIR }}"
file_count=$(find -type f -wholename "./$DIR/*.$EXT" | wc -l)
if [ "$file_count" -eq 0 ]; then
echo "ERROR: no code coverage files of type .$EXT found to merge. Verify that they were correctly generated and uploaded in prior CI steps"
exit 1
fi
# Install lcov for merging the reports
- name: Install lcov
shell: bash
run: |
sudo apt-get install -y --no-install-recommends lcov
# Merge n coverage report files into 1 file using lcov
- name: Merge code coverage files
shell: bash
run: |
EXT="${{ env.REPORT_FILES_EXT }}"
DIR="${{ env.REPORT_FILES_DIR }}"
CHUNK_SIZE=${{ env.REPORT_MERGE_CHUNK_SIZE }}
INTERMEDIATE_FILES=()
cd "$DIR" || exit 1
# 1. Collect all files into an array
mapfile -d '' ALL_FILES < <(find . -type f -name "*.$EXT" -print0)
# 2. Process in chunks
TOTAL_FILES=${#ALL_FILES[@]}
for (( i=0; i<TOTAL_FILES; i+=CHUNK_SIZE )); do
# Slice the array for the current chunk
CHUNK=("${ALL_FILES[@]:i:CHUNK_SIZE}")
# Build the lcov arguments for this specific chunk
CHUNK_ARGS=()
for file in "${CHUNK[@]}"; do
CHUNK_ARGS+=(-a "$file")
done
# Define a unique name for the intermediate report
PART_FILE="code_coverage_part_$((i / CHUNK_SIZE)).$EXT"
INTERMEDIATE_FILES+=("$PART_FILE")
# Run lcov in the background
echo "Processing chunk $((i / CHUNK_SIZE + 1))..."
lcov "${CHUNK_ARGS[@]}" -o "$PART_FILE" &
done
# 3. Wait for all background processes to finish
wait
# 4. Final Merge: Combine the intermediate files into the final report
FINAL_ARGS=()
for part in "${INTERMEDIATE_FILES[@]}"; do
FINAL_ARGS+=(-a "$part")
done
echo "Performing final merge of ${#INTERMEDIATE_FILES[@]} intermediate files..."
lcov "${FINAL_ARGS[@]}" -o "code-coverage-report.$EXT"
cd ..
# Upload the merged code coverage file to Coveralls
- name: Upload code coverage to Coveralls
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
file: ${{ env.REPORT_FILES_DIR }}/code-coverage-report.${{ env.REPORT_FILES_EXT }}
compare-ref: ${{ github.base_ref }} # defaults to master if this isn't supplied
fail-on-error: true