Skip to content

Commit

Permalink
ci: cache build objects in between internal runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexicon226 committed Jan 17, 2025
1 parent 63544d0 commit cf8896a
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 58 deletions.
162 changes: 107 additions & 55 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: setup-zig
uses: mlugg/setup-zig@v1
Expand All @@ -25,8 +24,7 @@ jobs:
check_style:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v3
Expand All @@ -39,60 +37,87 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3

- name: setup-zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

# GitHub's CI runners for macos seem to alternate between using a x86 and an ARM machine
# which is annoying to handle and results in them having invalid hardware info configurations
# on the virtual machine. This leads to incorrect feature detection and the CI is flaky.
#
# If we at some point setup a self-hosted MacOS runner, we could work around the issue and
# enable full testing on MacOS!
- name: build
run: |
zig build -Dtarget=x86_64-linux -Dcpu=x86_64_v4
zig build -Dtarget=aarch64-macos -Dcpu=apple_m3
- uses: actions/checkout@v4

- name: setup-zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: build
run: |
zig build -Denable-tsan -p output/
zig build test -Denable-tsan=true -Dblockstore=hashmap -Dfilter="ledger" -Dno-run -p output/tsan-test/
- uses: actions/upload-artifact@v4
with:
name: zig-build
path: output/

# # GitHub's CI runners for macos seem to alternate between using a x86 and an ARM machine
# # which is annoying to handle and results in them having invalid hardware info configurations
# # on the virtual machine. This leads to incorrect feature detection and the CI is flaky.
# #
# # If we at some point setup a self-hosted MacOS runner, we could work around the issue and
# # enable full testing on MacOS!
# build-macos:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4

# - name: setup-zig
# uses: mlugg/setup-zig@v1
# with:
# version: 0.13.0

# - name: build
# run: zig build -Dtarget=aarch64-macos -Dcpu=apple_m3

test:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
needs: build
timeout-minutes: 60
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: setup-zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- uses: actions/download-artifact@v4
with:
name: zig-build
path: output/

- name: test
run: |
zig build test -Denable-tsan=true
zig build test -Denable-tsan=true -Dblockstore=hashmap -Dfilter="ledger"
output/zig-out/bin/test
output/tsan-test/bin/test
kcov_test:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
needs: build
timeout-minutes: 60
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: setup-zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- uses: actions/download-artifact@v4
with:
name: zig-build
path: output/

- name: Set up dependencies
run: sudo apt-get update

Expand All @@ -109,29 +134,50 @@ jobs:
- name: run kcov
run: |
bash scripts/kcov_test.sh
bash scripts/kcov_test.sh output/zig-out/bin/test
- name: print coverage report
run: |
python scripts/parse_kcov.py kcov-output/test/coverage.json
build-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: setup-zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: build
run: |
zig build sig fuzz -Doptimize=ReleaseSafe
- uses: actions/upload-artifact@v4
with:
name: zig-build-release
path: zig-out/

gossip:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
needs: build-release
timeout-minutes: 60
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: setup-zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: build release
run: zig build -Doptimize=ReleaseSafe
- uses: actions/download-artifact@v4
with:
name: zig-build-release
path: zig-out/

- name: run gossip
run: bash scripts/gossip_test.sh 120 # in seconds
Expand All @@ -142,17 +188,19 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
timeout-minutes: 60
needs: build-release
steps:
- name: checkout
uses: actions/checkout@v2

- uses: actions/checkout@v4

- name: setup zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: build
run: zig build -Doptimize=ReleaseSafe -Dno-run fuzz
- uses: actions/download-artifact@v4
with:
name: zig-build-release
path: zig-out/

- name: run
run: ./zig-out/bin/fuzz gossip_service 19 10000
Expand All @@ -162,21 +210,20 @@ jobs:
matrix:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
needs: build-release
timeout-minutes: 60
steps:
- name: checkout
uses: actions/checkout@v2

with:
submodules: recursive
- uses: actions/checkout@v4

- name: setup zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: build
run: zig build -Doptimize=ReleaseSafe -Dno-run fuzz
- uses: actions/download-artifact@v4
with:
name: zig-build-release
path: zig-out/

- name: run
run: ./zig-out/bin/fuzz gossip_table 19 100000
Expand All @@ -186,18 +233,20 @@ jobs:
matrix:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
needs: build-release
timeout-minutes: 60
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: setup zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: build
run: zig build -Doptimize=ReleaseSafe -Dno-run fuzz
- uses: actions/download-artifact@v4
with:
name: zig-build-release
path: zig-out/

- name: run
run: ./zig-out/bin/fuzz allocators 19 10000
Expand All @@ -207,18 +256,21 @@ jobs:
matrix:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
needs: build-release
timeout-minutes: 60
steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/checkout@v4

- name: setup zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0
- name: build
run: zig build -Doptimize=ReleaseSafe -Dno-run fuzz

- uses: actions/download-artifact@v4
with:
name: zig-build-release
path: zig-out/

- name: run
run: ./zig-out/bin/fuzz ledger 19 10000

Expand Down
11 changes: 8 additions & 3 deletions scripts/kcov_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ echo "=> Cleaning up"
rm -rf kcov-output
mkdir kcov-output

echo "=> Building Sig"
zig build
if [ -z "$1" ] then
echo "=> Building Sig"
zig build
test_bin="./zig-out/bin/test"
elif
test_bin="$1"
fi

echo "=> Running kcov on tests"
kcov \
--include-pattern=src/ \
--exclude-pattern=$HOME/.cache \
kcov-output \
./zig-out/bin/test
$test_bin

echo "=> Opening kcov-output/index.html"
open kcov-output/index.html || echo "=> Failed to open kcov-output/index.html"

0 comments on commit cf8896a

Please sign in to comment.