Skip to content

Enable hash based stellar consensus for latestledger (#673) #5702

Enable hash based stellar consensus for latestledger (#673)

Enable hash based stellar consensus for latestledger (#673) #5702

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
merge_group:
env:
# Ensure that a cached go version is used:
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md#go
GO_VERSION: 1.26.2
GOPRIVATE: github.com/smartcontractkit/capabilities
jobs:
affected:
runs-on: ubuntu-latest
outputs:
nx: ${{ steps.affected.outputs.affected }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
# There's no need to setup Node as it is pre-installed:
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
- name: Cache NX
uses: actions/cache@v4
with:
path: |
.nx
~/.npm
key: ${{ runner.os }}-nx
# Outputs:
# {
# "base": "main",
# "projects": [
# "project_name_1",
# "project_name_2",
# ],
# "project_name_1": {
# "root": "project_1_root",
# "go_sum": "project_1_root/go.sum"
# },
# "project_name_2": {
# "root": "project_2_root",
# "go_sum": "project_2_root/go.sum"
# }
# "run_checks": true
# }
- name: Setup nodejs and install nx
uses: smartcontractkit/.github/actions/setup-nodejs@setup-nodejs/v1
- name: Get affected projects
id: affected
run: |
if [[ "${GITHUB_REF_NAME}" == "main" ]]; then
BASE="origin/main~1"
else
BASE="origin/main"
fi
echo "affected=$(./.github/scripts/affected-projects.sh $BASE)" >> $GITHUB_OUTPUT
build:
needs: affected
if: ${{fromJson(needs.affected.outputs.nx).projects_with_build != null && contains(fromJson(needs.affected.outputs.nx).projects_with_build, fromJson(needs.affected.outputs.nx).projects_with_build[0])}}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
projects: ${{fromJson(needs.affected.outputs.nx).projects_with_build}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up project environment
uses: ./.github/actions/setup
with:
project: ${{ matrix.projects }}
go-module-file: ${{ fromJson(needs.affected.outputs.nx)[matrix.projects].go_sum }}
task: "build"
- name: Support private Go modules
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/scripts/support-private-gomods.sh
- name: Build ${{ matrix.projects }}
run: ./.github/scripts/nx-run-if-exists.sh ${{ matrix.projects }} build
test:
needs: affected
if: ${{fromJson(needs.affected.outputs.nx).projects_with_test != null && contains(fromJson(needs.affected.outputs.nx).projects_with_test, fromJson(needs.affected.outputs.nx).projects_with_test[0])}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projects: ${{fromJson(needs.affected.outputs.nx).projects_with_test}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up project environment
uses: ./.github/actions/setup
with:
project: ${{ matrix.projects }}
go-module-file: ${{ fromJson(needs.affected.outputs.nx)[matrix.projects].go_sum }}
task: "test"
- name: Support private Go modules
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/scripts/support-private-gomods.sh
- name: Install Solana CLI
if: matrix.projects == 'solana'
run: ./.github/scripts/install-solana-ci.sh
- name: Setup Test DB
if: matrix.projects == 'solana'
id: setup-testdb
uses: ./.github/actions/setup-testdb
- name: Unit Test solana
if: matrix.projects == 'solana'
run: ./nx run solana:test
env:
CL_DATABASE_URL: ${{ steps.setup-testdb.outputs.cl-db-url }}
- name: Unit Test ${{ matrix.projects }}
if: matrix.projects != 'solana'
run: ./nx run ${{ matrix.projects }}:test
- name: Upload Unit Tests Artifacts
if: always()
uses: actions/upload-artifact@v4.4.3
with:
# name artifacts differently per each report
name: ${{ matrix.projects }}_go_test_results
# the path to a generated report (per directory)
path: |
./${{fromJson(needs.affected.outputs.nx)[matrix.projects].root}}/coverage.txt
race:
needs: affected
if: ${{fromJson(needs.affected.outputs.nx).projects_with_race != null && contains(fromJson(needs.affected.outputs.nx).projects_with_race, fromJson(needs.affected.outputs.nx).projects_with_race[0])}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projects: ${{fromJson(needs.affected.outputs.nx).projects_with_race}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up project environment
uses: ./.github/actions/setup
with:
project: ${{ matrix.projects }}
go-module-file: ${{ fromJson(needs.affected.outputs.nx)[matrix.projects].go_sum }}
task: "race"
- name: Support private Go modules
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/scripts/support-private-gomods.sh
- name: Install Solana CLI
if: matrix.projects == 'solana'
run: ./.github/scripts/install-solana-ci.sh
- name: Setup Test DB
if: matrix.projects == 'solana'
id: setup-testdb
uses: ./.github/actions/setup-testdb
- name: Race Test solana
if: matrix.projects == 'solana'
run: ./nx run solana:race
env:
CL_DATABASE_URL: ${{ steps.setup-testdb.outputs.cl-db-url }}
- name: Race Test ${{ matrix.projects }}
if: matrix.projects != 'solana'
run: ./nx run ${{ matrix.projects }}:race
integration-tests:
uses: ./.github/workflows/integration-tests.yml
tidy-and-generate:
needs: affected
if: ${{fromJson(needs.affected.outputs.nx).run_checks}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projects: ${{fromJson(needs.affected.outputs.nx).projects}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up project environment
uses: ./.github/actions/setup
with:
project: ${{ matrix.projects }}
go-module-file: ${{ fromJson(needs.affected.outputs.nx)[matrix.projects].go_sum }}
task: "tidy-and-generate"
- name: Support private Go modules
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/scripts/support-private-gomods.sh
- name: Install mockery
run: go install github.com/vektra/mockery/v2/...@v2.53.5
- name: Run "tidy" and "generate"
run: |
./nx run ${{ matrix.projects }}:tidy
./.github/scripts/nx-run-if-exists.sh ${{ matrix.projects }} generate
- name: Ensure no diff
run: |
git diff
git diff --stat --exit-code
lint:
needs: affected
if: ${{fromJson(needs.affected.outputs.nx).run_checks}}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
actions: read
strategy:
fail-fast: false
matrix:
projects: ${{fromJson(needs.affected.outputs.nx).projects}}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
persist-credentials: false
- name: Set up project environment
id: setup
uses: ./.github/actions/setup
with:
project: ${{ matrix.projects }}
go-module-file: ${{ fromJson(needs.affected.outputs.nx)[matrix.projects].go_sum }}
task: "lint"
- name: Support private Go modules
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/scripts/support-private-gomods.sh
- name: Get golangci-lint version from asdf
id: get-version
run: |
version=$(grep '^golangci-lint ' .tool-versions | awk '{print $2}')
echo "version=${version}" | tee -a "$GITHUB_OUTPUT"
- name: golangci-lint (${{ matrix.projects }})
uses: smartcontractkit/.github/actions/ci-lint-go@ci-lint-go/3.1.0
with:
checkout-repo: false
golangci-lint-config: ${{ github.workspace }}/.golangci.yml
golangci-lint-version: v${{ steps.get-version.outputs.version }}
go-directory: ${{fromJson(needs.affected.outputs.nx)[matrix.projects].root}}
modgraph:
runs-on: ubuntu-latest
name: modgraph
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Go
uses: actions/setup-go@v5
- name: Support private Go modules
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/scripts/support-private-gomods.sh
- run: make modgraph
- name: Ensure clean modgraph
run: git diff --minimal --exit-code
checks:
runs-on: ubuntu-latest
needs:
- lint
- build
- test
- race
- tidy-and-generate
- integration-tests
- modgraph
if: always()
steps:
- name: All tests ok
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
run: exit 0
- name: Some tests failed or were cancelled
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1
sonarqube:
name: SonarQube Scan
needs: [test, lint]
if: ${{ always() && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: SonarQube Scan
uses: smartcontractkit/.github/actions/ci-sonarqube-go@5f4a9c9c3407dd499a1ebbc658a45b9beb9bf675 # v0.3.0
with:
include-lint: "true"
sonar-token: ${{ secrets.SONAR_TOKEN }}
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}