4141 packages : ' read' # Required to read GitHub packages/container registry
4242 pull-requests : ' write' # Required to post coverage comment on PR
4343 runs-on : large_ubuntu_16
44+ env :
45+ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER : clang
46+ RUSTFLAGS : " -C link-arg=-fuse-ld=mold"
4447 steps :
4548 - name : Checkout code
4649 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5154 - name : Checkout LFS objects
5255 run : git lfs checkout
5356
57+ - name : Login to GitHub Container Registry
58+ uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
59+ with :
60+ registry : ghcr.io
61+ username : ${{ github.actor }}
62+ password : ${{ secrets.GITHUB_TOKEN }}
63+
64+ - name : Login to GitHub Chainguard Registry
65+ uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
66+ with :
67+ registry : cgr.dev
68+ username : ${{ secrets.CGR_USERNAME }}
69+ password : ${{ secrets.CGR_PASSWORD }}
70+
71+ - name : Start database services (background)
72+ run : |
73+ nohup docker compose up -d --build db-migration > /tmp/db-init.log 2>&1 &
74+ working-directory : coprocessor/fhevm-engine/tfhe-worker
75+
5476 - name : Setup Rust toolchain file
5577 run : cp coprocessor/fhevm-engine/rust-toolchain.toml .
5678
6587 - name : Install cargo dependencies
6688 run : |
6789 sudo apt-get update
68- sudo apt-get install -y protobuf-compiler && \
90+ sudo apt-get install -y protobuf-compiler mold clang && \
6991 cargo install sqlx-cli --version 0.7.2 --no-default-features --features postgres --locked
7092
7193 - name : Install foundry
@@ -81,42 +103,55 @@ jobs:
81103 key : ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
82104 restore-keys : ${{ runner.os }}-cargo-coverage-
83105
84- - name : Login to GitHub Container Registry
85- uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
86- with :
87- registry : ghcr.io
88- username : ${{ github.actor }}
89- password : ${{ secrets.GITHUB_TOKEN }}
90-
91- - name : Login to GitHub Chainguard Registry
92- uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
93- with :
94- registry : cgr.dev
95- username : ${{ secrets.CGR_USERNAME }}
96- password : ${{ secrets.CGR_PASSWORD }}
97-
98- - name : Init database
99- run : make init_db
100- working-directory : coprocessor/fhevm-engine/tfhe-worker
101-
102106 - name : Use Node.js
103107 uses : actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
104108 with :
105109 node-version : 20.x
106110
107111 - name : Start localstack
108- run : |
109- docker run --rm -d -p 4566:4566 --name localstack localstack/localstack:latest
112+ run : docker run --rm -d -p 4566:4566 --name localstack localstack/localstack:4.14.0
110113
111114 - name : Clean previous coverage data
112115 run : cargo llvm-cov clean --workspace --profile coverage
113116 working-directory : coprocessor/fhevm-engine
114117
118+ - name : Compile tests with coverage instrumentation
119+ run : |
120+ cargo llvm-cov show-env --sh > /tmp/llvm-cov-env.sh
121+ source /tmp/llvm-cov-env.sh
122+ DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor \
123+ SQLX_OFFLINE=true \
124+ cargo test --no-run --workspace --profile coverage
125+ working-directory : coprocessor/fhevm-engine
126+
127+ - name : Wait for database migration
128+ run : |
129+ SECONDS=0
130+ while ! docker container inspect db-migration > /dev/null 2>&1; do
131+ if [ "$SECONDS" -ge 900 ]; then
132+ echo "Timed out waiting for db-migration container after 15 minutes"
133+ cat /tmp/db-init.log
134+ exit 1
135+ fi
136+ echo "Waiting for db-migration container to be created..."
137+ sleep 2
138+ done
139+ EXIT_CODE=$(docker wait db-migration)
140+ if [ "$EXIT_CODE" != "0" ]; then
141+ echo "Database migration failed with exit code $EXIT_CODE"
142+ docker logs db-migration
143+ cat /tmp/db-init.log
144+ exit 1
145+ fi
146+ echo "Database migration completed"
147+
115148 - name : Run tests with coverage
116149 run : |
150+ source /tmp/llvm-cov-env.sh
117151 DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor \
118152 TEST_GLOBAL_LOCALSTACK=1 \
119- cargo llvm-cov --no-report --workspace --profile coverage
153+ SQLX_OFFLINE=true \
154+ cargo test --workspace --profile coverage
120155 working-directory : coprocessor/fhevm-engine
121156
122157 - name : Generate coverage report
0 commit comments