diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..1799848f --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,86 @@ +name: CI + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: Swift Lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Check swift codestyle + uses: cirruslabs/swiftlint-action@v1 + with: + args: --config .swiftlint.yml --strict + + test: + name: Build and Test + runs-on: [self-hosted, linux] + timeout-minutes: 30 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + - run: sudo apt-get update + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: librocksdb-dev libzstd-dev libbz2-dev liblz4-dev + # - name: Cache SPM + # uses: actions/cache@v4 + # with: + # path: '**/.build' + # key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} + # restore-keys: | + # ${{ runner.os }}-spm- + - name: Cache Cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Cache bandersnatch_vrfs static lib + uses: actions/cache@v4 + with: + path: .lib/libbandersnatch_vrfs.a + key: ${{ runner.os }}-libs-libbandersnatch-${{ hashFiles('Utils/Sources/bandersnatch/**') }} + restore-keys: | + ${{ runner.os }}-libs-libbandersnatch + - name: Cache bls static lib + uses: actions/cache@v4 + with: + path: .lib/libbls.a + key: ${{ runner.os }}-libs-libbls-${{ hashFiles('Utils/Sources/bls/**') }} + restore-keys: | + ${{ runner.os }}-libs-libbls + - name: Cache erasure-coding static lib + uses: actions/cache@v4 + with: + path: .lib/libec.a + key: ${{ runner.os }}-libs-libec-${{ hashFiles('Utils/Sources/erasure-coding/**') }} + restore-keys: | + ${{ runner.os }}-libs-libec + - name: Setup Swift + uses: SwiftyLab/setup-swift@latest + - name: Setup Rust + uses: dtolnay/rust-toolchain@nightly + - name: Test Coverage + run: make test-coverage + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true # optional (default = false) + token: ${{ secrets.CODECOV_TOKEN }} # required + verbose: true # optional (default = false) diff --git a/Makefile b/Makefile index 6c261c65..0d07c7d9 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,10 @@ test-cargo: .PHONY: test-all test-all: test test-cargo +.PHONY: test-coverage +test-coverage: + ./scripts/runTests.sh test --enable-code-coverage + .PHONY: build build: githooks deps ./scripts/run.sh build