diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..e1561fce --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,21 @@ +## Description + +Please provide a brief description of the issue. + +## Version + +Please provide your SSV version and Rust version. Are you building from +`stable` or `unstable`, which commit? + +## Present Behaviour + +Describe the present behaviour of the application, with regards to this +issue. + +## Expected Behaviour + +How _should_ the application behave? + +## Steps to resolve + +Please describe the steps required to resolve this issue, if known. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..01ca90a7 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +## Issue Addressed + +Which issue # does this PR address? + +## Proposed Changes + +Please list or describe the changes introduced by this PR. + +## Additional Info + +Please provide any additional information. For example, future considerations +or information useful for reviewers. diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml new file mode 100644 index 00000000..031a88b0 --- /dev/null +++ b/.github/workflows/book.yml @@ -0,0 +1,34 @@ +name: mdbook + +on: + push: + branches: + - unstable + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-upload-to-s3: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: 'latest' + + - run: mdbook build + working-directory: book + + - uses: jakejarvis/s3-sync-action@be0c4ab89158cac4278689ebedd8407dd5f35a83 + with: + args: --follow-symlinks --delete + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BOOK_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: 'ap-southeast-2' + SOURCE_DIR: 'book/book' diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..c29ff337 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,163 @@ +# TODO: Setup docker +# name: docker +# +# on: +# push: +# branches: +# - stable +# tags: +# - v* +# +# concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true +# +# env: +# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} +# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} +# # Enable self-hosted runners for the sigp repo only. +# SELF_HOSTED_RUNNERS: ${{ github.repository == 'sigp/anchor' }} +# +# jobs: +# # Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX +# # which is either empty or `-unstable`. +# # +# # It would be nice if the arch didn't get spliced into the version between `latest` and +# # `unstable`, but for now we keep the two parts of the version separate for backwards +# # compatibility. +# extract-version: +# runs-on: ubuntu-22.04 +# steps: +# - name: Extract version (if stable) +# if: github.event.ref == 'refs/heads/stable' +# run: | +# echo "VERSION=latest" >> $GITHUB_ENV +# echo "VERSION_SUFFIX=" >> $GITHUB_ENV +# - name: Extract version (if unstable) +# if: github.event.ref == 'refs/heads/unstable' +# run: | +# echo "VERSION=latest" >> $GITHUB_ENV +# echo "VERSION_SUFFIX=-unstable" >> $GITHUB_ENV +# - name: Extract version (if tagged release) +# if: startsWith(github.event.ref, 'refs/tags') +# run: | +# echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV +# echo "VERSION_SUFFIX=" >> $GITHUB_ENV +# outputs: +# VERSION: ${{ env.VERSION }} +# VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }} +# build-docker-single-arch: +# name: build-docker-${{ matrix.binary }}-${{ matrix.cpu_arch }}${{ matrix.features.version_suffix }} +# # Use self-hosted runners only on the sigp repo. +# runs-on: ${{ github.repository == 'sigp/anchor' && fromJson('["self-hosted", "linux", "release"]') || 'ubuntu-22.04' }} +# strategy: +# matrix: +# binary: [anchor] +# cpu_arch: [aarch64, x86_64] +# include: +# - profile: maxperf +# +# needs: [extract-version] +# env: +# VERSION: ${{ needs.extract-version.outputs.VERSION }} +# VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }} +# steps: +# - uses: actions/checkout@v4 +# - name: Update Rust +# if: env.SELF_HOSTED_RUNNERS == 'false' +# run: rustup update stable +# - name: Dockerhub login +# run: | +# echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin +# +# - name: Sets env vars for Anchor +# if: startsWith(matrix.binary, 'anchor') +# run: | +# echo "CROSS_FEATURES=gnosis,spec-minimal,slasher-lmdb,jemalloc" >> $GITHUB_ENV +# +# - name: Set `make` command for anchor +# if: startsWith(matrix.binary, 'anchor') +# run: | +# echo "MAKE_CMD=build-${{ matrix.cpu_arch }}" >> $GITHUB_ENV +# +# - name: Set `make` command for lcli +# if: startsWith(matrix.binary, 'lcli') +# run: | +# echo "MAKE_CMD=build-lcli-${{ matrix.cpu_arch }}" >> $GITHUB_ENV +# +# - name: Cross build binaries +# run: | +# cargo install cross +# env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ env.CROSS_FEATURES }} make ${{ env.MAKE_CMD }} +# +# - name: Make bin dir +# run: mkdir ./bin +# +# - name: Move cross-built binary into Docker scope +# run: mv ./target/${{ matrix.cpu_arch }}-unknown-linux-gnu/${{ matrix.profile }}/${{ matrix.binary }} ./bin +# +# - name: Map aarch64 to arm64 short arch +# if: startsWith(matrix.cpu_arch, 'aarch64') +# run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV +# +# - name: Map x86_64 to amd64 short arch +# if: startsWith(matrix.cpu_arch, 'x86_64') +# run: echo "SHORT_ARCH=amd64" >> $GITHUB_ENV; +# +# - name: Install QEMU +# if: env.SELF_HOSTED_RUNNERS == 'false' +# run: sudo apt-get update && sudo apt-get install -y qemu-user-static +# +# - name: Set up Docker Buildx +# if: env.SELF_HOSTED_RUNNERS == 'false' +# uses: docker/setup-buildx-action@v3 +# +# - name: Build and push (Anchor) +# if: startsWith(matrix.binary, 'anchor') +# uses: docker/build-push-action@v5 +# with: +# file: ./Dockerfile.cross +# context: . +# platforms: linux/${{ env.SHORT_ARCH }} +# push: true +# tags: | +# ${{ github.repository_owner}}/${{ matrix.binary }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }} +# +# - name: Build and push (lcli) +# if: startsWith(matrix.binary, 'lcli') +# uses: docker/build-push-action@v5 +# with: +# file: ./lcli/Dockerfile.cross +# context: . +# platforms: linux/${{ env.SHORT_ARCH }} +# push: true +# +# tags: | +# ${{ github.repository_owner}}/${{ matrix.binary }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }} +# +# +# build-docker-multiarch: +# name: build-docker-${{ matrix.binary }}-multiarch +# runs-on: ubuntu-22.04 +# strategy: +# matrix: +# binary: [anchor, +# lcli] +# needs: [build-docker-single-arch, extract-version] +# env: +# VERSION: ${{ needs.extract-version.outputs.VERSION }} +# VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }} +# steps: +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v3 +# +# - name: Dockerhub login +# run: | +# echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin +# +# - name: Create and push multiarch manifests +# run: | +# docker buildx imagetools create -t ${{ github.repository_owner}}/${{ matrix.binary }}:${VERSION}${VERSION_SUFFIX} \ +# ${{ github.repository_owner}}/${{ matrix.binary }}:${VERSION}-arm64${VERSION_SUFFIX} \ +# ${{ github.repository_owner}}/${{ matrix.binary }}:${VERSION}-amd64${VERSION_SUFFIX}; +# diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml new file mode 100644 index 00000000..5ceca2e6 --- /dev/null +++ b/.github/workflows/linkcheck.yml @@ -0,0 +1,37 @@ +# TODO: Setup mdbook +# name: linkcheck +# +# on: +# push: +# branches: +# - unstable +# pull_request: +# paths: +# - 'book/**' +# merge_group: +# +# concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true +# +# jobs: +# linkcheck: +# name: Check broken links +# runs-on: ubuntu-latest +# +# steps: +# - name: Checkout code +# uses: actions/checkout@v4 +# +# - name: Run mdbook server +# run: | +# docker run -v ${{ github.workspace }}/book:/book --name book -p 3000:3000 -d peaceiris/mdbook:latest serve --hostname 0.0.0.0 +# sleep 5 +# +# - name: Print logs +# run: docker logs book +# +# - name: Run linkcheck +# run: | +# curl -sL https://github.com/filiph/linkcheck/releases/download/3.0.0/linkcheck-3.0.0-linux-x64.tar.gz | tar xvzf - linkcheck/linkcheck --strip 1 +# ./linkcheck localhost:3000 -d diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f5c8b39b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,251 @@ +# TODO: Setup release pipeline +# name: Release Suite +# +# on: +# push: +# tags: +# - v* +# +# concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true +# +# env: +# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} +# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} +# REPO_NAME: ${{ github.repository_owner }}/anchor +# IMAGE_NAME: ${{ github.repository_owner }}/anchor +# # Enable self-hosted runners for the sigp repo only. +# SELF_HOSTED_RUNNERS: ${{ github.repository == 'sigp/anchor' }} +# +# jobs: +# extract-version: +# runs-on: ubuntu-latest +# steps: +# - name: Extract version +# run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT +# id: extract_version +# outputs: +# VERSION: ${{ steps.extract_version.outputs.VERSION }} +# build: +# name: Build Release +# strategy: +# matrix: +# arch: [aarch64-unknown-linux-gnu, +# x86_64-unknown-linux-gnu, +# x86_64-apple-darwin, +# x86_64-windows] +# include: +# - arch: aarch64-unknown-linux-gnu +# runner: ${{ github.repository == 'sigp/anchor' && fromJson('["self-hosted", "linux", "release", "large"]') || 'ubuntu-latest' }} +# profile: maxperf +# - arch: x86_64-unknown-linux-gnu +# runner: ${{ github.repository == 'sigp/anchor' && fromJson('["self-hosted", "linux", "release", "large"]') || 'ubuntu-latest' }} +# profile: maxperf +# - arch: x86_64-apple-darwin +# runner: macos-13 +# profile: maxperf +# - arch: x86_64-windows +# runner: ${{ github.repository == 'sigp/anchor' && fromJson('["self-hosted", "windows", "release"]') || 'windows-2019' }} +# profile: maxperf +# +# runs-on: ${{ matrix.runner }} +# needs: extract-version +# steps: +# - name: Checkout sources +# uses: actions/checkout@v4 +# - name: Get latest version of stable Rust +# if: env.SELF_HOSTED_RUNNERS == 'false' +# run: rustup update stable +# +# # ============================== +# # Windows dependencies +# # ============================== +# +# - uses: KyleMayes/install-llvm-action@v1 +# if: env.SELF_HOSTED_RUNNERS == 'false' && startsWith(matrix.arch, 'x86_64-windows') +# with: +# version: "17.0" +# directory: ${{ runner.temp }}/llvm +# - name: Set LIBCLANG_PATH +# if: startsWith(matrix.arch, 'x86_64-windows') +# run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV +# +# # ============================== +# # Builds +# # ============================== +# +# - name: Build Anchor for aarch64-unknown-linux-gnu +# if: matrix.arch == 'aarch64-unknown-linux-gnu' +# run: | +# cargo install cross +# env CROSS_PROFILE=${{ matrix.profile }} make build-aarch64 +# +# - name: Build Anchor for x86_64-unknown-linux-gnu +# if: matrix.arch == 'x86_64-unknown-linux-gnu' +# run: | +# cargo install cross +# env CROSS_PROFILE=${{ matrix.profile }} make build-x86_64 +# +# - name: Move cross-compiled binary +# if: contains(matrix.arch, 'unknown-linux-gnu') +# run: mv target/${{ matrix.arch }}/${{ matrix.profile }}/anchor ~/.cargo/bin/anchor +# +# - name: Build Anchor for x86_64-apple-darwin +# if: matrix.arch == 'x86_64-apple-darwin' +# run: cargo install --path anchor --force --locked --features portable,gnosis --profile ${{ matrix.profile }} +# +# - name: Build Anchor for Windows +# if: matrix.arch == 'x86_64-windows' +# run: cargo install --path anchor --force --locked --features portable,gnosis --profile ${{ matrix.profile }} +# +# - name: Configure GPG and create artifacts +# if: startsWith(matrix.arch, 'x86_64-windows') != true +# env: +# GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} +# GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} +# run: | +# export GPG_TTY=$(tty) +# echo "$GPG_SIGNING_KEY" | gpg --batch --import +# mkdir artifacts +# mv ~/.cargo/bin/anchor ./artifacts +# cd artifacts +# tar -czf anchor-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz anchor +# echo "$GPG_PASSPHRASE" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch -ab anchor-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz +# for ext in "tar.gz" "tar.gz.asc";\ +# do for f in *.$ext;\ +# do cp $f "../${f%.$ext}.$ext";\ +# done;\ +# done +# mv *tar.gz* .. +# +# - name: Configure GPG and create artifacts Windows +# if: startsWith(matrix.arch, 'x86_64-windows') +# env: +# GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} +# GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} +# run: | +# echo $env:GPG_SIGNING_KEY | gpg --batch --import +# mkdir artifacts +# move $env:USERPROFILE/.cargo/bin/anchor.exe ./artifacts +# cd artifacts +# tar -czf anchor-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz anchor.exe +# gpg --passphrase "$env:GPG_PASSPHRASE" --batch --pinentry-mode loopback -ab anchor-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz +# move *tar.gz* .. +# +# # ======================================================================= +# # Upload artifacts +# # This is required to share artifacts between different jobs +# # ======================================================================= +# +# - name: Upload artifact +# uses: actions/upload-artifact@v4 +# with: +# name: anchor-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz +# path: anchor-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz +# compression-level: 0 +# +# - name: Upload signature +# uses: actions/upload-artifact@v4 +# with: +# name: anchor-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz.asc +# path: anchor-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz.asc +# compression-level: 0 +# +# draft-release: +# name: Draft Release +# needs: [build, extract-version] +# runs-on: ubuntu-latest +# env: +# VERSION: ${{ needs.extract-version.outputs.VERSION }} +# steps: +# # This is necessary for generating the changelog. It has to come before "Download Artifacts" or else it deletes the artifacts. +# - name: Checkout sources +# uses: actions/checkout@v4 +# with: +# fetch-depth: 0 +# +# # ============================== +# # Download artifacts +# # ============================== +# +# - name: Download artifacts +# uses: actions/download-artifact@v4 +# +# # ============================== +# # Create release draft +# # ============================== +# +# - name: Generate Full Changelog +# id: changelog +# run: | +# echo "CHANGELOG<> $GITHUB_OUTPUT +# echo "$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 ${{ env.VERSION }}^)..${{ env.VERSION }})" >> $GITHUB_OUTPUT +# echo "EOF" >> $GITHUB_OUTPUT +# +# - name: Create Release Draft +# env: +# GITHUB_USER: ${{ github.repository_owner }} +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# +# # The formatting here is borrowed from OpenEthereum: https://github.com/openethereum/openethereum/blob/main/.github/workflows/build.yml +# run: | +# body=$(cat <<- "ENDBODY" +# +# +# ## Testing Checklist (DELETE ME) +# +# - [ ] Run on synced Holesky Sigma Prime nodes. +# - [ ] Run on synced Canary (mainnet) Sigma Prime nodes. +# - [ ] Resync a Holesky node. +# - [ ] Resync a mainnet node. +# +# ## Release Checklist (DELETE ME) +# +# - [ ] Merge `unstable` -> `stable`. +# - [ ] Ensure docker images are published (check `latest` and the version tag). +# - [ ] Prepare Discord post. +# - [ ] Prepare Twitter post. +# - [ ] Prepare mailing list email. +# +# ## Summary +# +# Add a summary. +# +# ## Update Priority +# +# This table provides priorities for which classes of users should update particular components. +# +# |User Class |Beacon Node | Validator Client| +# --- | --- | --- +# |Staking Users| | | +# |Non-Staking Users| |---| +# +# *See [Update +# Priorities](https://anchor-book.sigmaprime.io/installation-priorities.html) +# more information about this table.* +# +# ## All Changes +# +# ${{ steps.changelog.outputs.CHANGELOG }} +# +# ## Binaries +# +# [See pre-built binaries documentation.](https://anchor-book.sigmaprime.io/installation-binaries.html) +# +# The binaries are signed with Sigma Prime's PGP key: `15E66D941F697E28F49381F426416DC3F30674B0` +# +# | System | Architecture | Binary | PGP Signature | +# |:---:|:---:|:---:|:---| +# | | x86_64 | [anchor-${{ env.VERSION }}-x86_64-apple-darwin.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/anchor-${{ env.VERSION }}-x86_64-apple-darwin.tar.gz) | [PGP Signature](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/anchor-${{ env.VERSION }}-x86_64-apple-darwin.tar.gz.asc) | +# | | x86_64 | [anchor-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/anchor-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz) | [PGP Signature](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/anchor-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz.asc) | +# | | aarch64 | [anchor-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/anchor-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz) | [PGP Signature](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/anchor-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz.asc) | +# | | x86_64 | [anchor-${{ env.VERSION }}-x86_64-windows.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/anchor-${{ env.VERSION }}-x86_64-windows.tar.gz) | [PGP Signature](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/anchor-${{ env.VERSION }}-x86_64-windows.tar.gz.asc) | +# | | | | | +# | **System** | **Option** | - | **Resource** | +# | | Docker | [${{ env.VERSION }}](https://hub.docker.com/r/${{ env.IMAGE_NAME }}/tags?page=1&ordering=last_updated&name=${{ env.VERSION }}) | [${{ env.IMAGE_NAME }}](https://hub.docker.com/r/${{ env.IMAGE_NAME }}) | +# ENDBODY +# ) +# assets=(./anchor-*.tar.gz*/anchor-*.tar.gz*) +# tag_name="${{ env.VERSION }}" +# echo "$body" | gh release create --draft -F "-" "$tag_name" "${assets[@]}" diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml new file mode 100644 index 00000000..8222ace0 --- /dev/null +++ b/.github/workflows/test-suite.yml @@ -0,0 +1,180 @@ +name: test-suite + +on: + push: + branches: + - stable + - 'pr/*' + pull_request: + merge_group: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + # Deny warnings in CI + # Disable debug info (see https://github.com/sigp/lighthouse/issues/4005) + RUSTFLAGS: "-D warnings -C debuginfo=0" + # Prevent Github API rate limiting. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Enable self-hosted runners for the Anchor repo only. + SELF_HOSTED_RUNNERS: false # ${{ github.repository == 'sigp/anchor' }} + # Self-hosted runners need to reference a different host for `./watch` tests. + WATCH_HOST: ${{ github.repository == 'sigp/anchor' && 'host.docker.internal' || 'localhost' }} + # Disable incremental compilation + CARGO_INCREMENTAL: 0 + # Enable portable to prevent issues with caching `blst` for the wrong CPU type + # TEST_FEATURES: portable +jobs: + check-labels: + runs-on: ubuntu-latest + name: Check for 'skip-ci' label + outputs: + skip_ci: ${{ steps.set-output.outputs.SKIP_CI }} + steps: + - name: check for skip-ci label + id: set-output + env: + LABELS: ${{ toJson(github.event.pull_request.labels) }} + run: | + SKIP_CI="false" + if [ -z "${LABELS}" ] || [ "${LABELS}" = "null" ]; then + LABELS="none"; + else + LABELS=$(echo ${LABELS} | jq -r '.[].name') + fi + for label in ${LABELS}; do + if [ "$label" = "skip-ci" ]; then + SKIP_CI="true" + break + fi + done + echo "skip_ci=$SKIP_CI" >> $GITHUB_OUTPUT + + target-branch-check: + name: target-branch-check + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' || github.event_name == 'merge_group' + steps: + - name: Check that the pull request is not targeting the stable branch + run: test ${{ github.base_ref }} != "stable" + release-tests-ubuntu: + name: release-tests-ubuntu + needs: [check-labels] + if: needs.check-labels.outputs.skip_ci != 'true' + # Use self-hosted runners only on the sigp repo. + runs-on: ubuntu-latest #${{ github.repository == 'sigp/anchor' && fromJson('["self-hosted", "linux", "CI", "large"]') || 'ubuntu-latest' }} + steps: + - uses: actions/checkout@v4 + - name: Get latest version of stable Rust + if: env.SELF_HOSTED_RUNNERS == 'false' + uses: moonrepo/setup-rust@v1 + with: + channel: stable + cache-target: release + bins: cargo-nextest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Run tests in release + run: make nextest-release + - name: Show cache stats + if: env.SELF_HOSTED_RUNNERS == 'true' + run: sccache --show-stats + debug-tests-ubuntu: + name: debug-tests-ubuntu + needs: [check-labels] + if: needs.check-labels.outputs.skip_ci != 'true' + # Use self-hosted runners only on the sigp repo. + runs-on: ubuntu-latest #${{ github.repository == 'sigp/anchor' && fromJson('["self-hosted", "linux", "CI", "large"]') || 'ubuntu-latest' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + - name: Get latest version of stable Rust + if: env.SELF_HOSTED_RUNNERS == 'false' + uses: moonrepo/setup-rust@v1 + with: + channel: stable + bins: cargo-nextest + - name: Run tests in debug + run: make nextest-debug + - name: Show cache stats + if: env.SELF_HOSTED_RUNNERS == 'true' + run: sccache --show-stats + check-code: + name: check-code + runs-on: ubuntu-latest + env: + CARGO_INCREMENTAL: 1 + steps: + - uses: actions/checkout@v4 + - name: Get latest version of stable Rust + uses: moonrepo/setup-rust@v1 + with: + channel: stable + cache-target: release + components: rustfmt,clippy + bins: cargo-audit + - name: Check formatting with cargo fmt + run: make cargo-fmt + - name: Lint code for quality and style with Clippy + run: make lint + - name: Certify Cargo.lock freshness + run: git diff --exit-code Cargo.lock + - name: Run cargo audit + run: make audit-CI + - name: Run cargo vendor to make sure dependencies can be vendored for packaging, reproducibility and archival purpose + run: CARGO_HOME=$(readlink -f $HOME) make vendor + - name: Markdown-linter + run: make mdlint + check-msrv: + name: check-msrv + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Rust at Minimum Supported Rust Version (MSRV) + run: | + metadata=$(cargo metadata --no-deps --format-version 1) + msrv=$(echo $metadata | jq -r '.packages | map(select(.name == "anchor")) | .[0].rust_version') + rustup override set $msrv + - name: Run cargo check + run: cargo check --workspace + cargo-udeps: + name: cargo-udeps + needs: [check-labels] + if: needs.check-labels.outputs.skip_ci != 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Get latest version of nightly Rust + uses: moonrepo/setup-rust@v1 + with: + channel: nightly + bins: cargo-udeps + cache: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Cargo config dir + run: mkdir -p .cargo + - name: Install custom Cargo config + run: cp -f .github/custom/config.toml .cargo/config.toml + - name: Run cargo udeps to identify unused crates in the dependency graph + run: make udeps + env: + # Allow warnings on Nightly + RUSTFLAGS: "" +# cli-check: +# name: cli-check +# needs: [check-labels] +# if: needs.check-labels.outputs.skip_ci != 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - name: Get latest version of stable Rust +# uses: moonrepo/setup-rust@v1 +# with: +# channel: stable +# cache-target: release +# - name: Run Makefile to trigger the bash script +# run: make cli