Skip to content

Commit 4c730d9

Browse files
committed
ci(workflows): adopt loarger runner for coverage test (#1111)
Because - The unit tests are getting resource consuming especially for the component tests. This commit - update coverage workflow to use a larger runner.
1 parent 3531864 commit 4c730d9

File tree

2 files changed

+64
-25
lines changed

2 files changed

+64
-25
lines changed

.github/workflows/coverage.yml

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
codecov:
1313
name: codecov
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04-8core-amd64
1515
permissions:
1616
contents: read
1717
pull-requests: write
@@ -28,20 +28,6 @@ jobs:
2828
ports:
2929
- 5432:5432
3030
steps:
31-
# Tests can fail due to insufficient disk space, so we optimize the disk
32-
# usage.
33-
- name: Remove unnecessary files
34-
run: |
35-
sudo rm -rf \
36-
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
37-
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
38-
/usr/lib/jvm "$AGENT_TOOLSDIRECTORY"
39-
40-
- name: Remove unnecessary packages
41-
run: |
42-
sudo apt-get --purge autoremove azure-cli microsoft-edge-stable \
43-
google-cloud-cli google-chrome-stable
44-
4531
- uses: actions/checkout@v4
4632
with:
4733
token: ${{ secrets.GITHUB_TOKEN }}
@@ -57,9 +43,58 @@ jobs:
5743
go-version: ${{ env.GOLANG_VERSION }}
5844
cache: false
5945

46+
# Set up Docker Buildx for advanced caching features
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
with:
50+
driver-opts: |
51+
network=host
52+
53+
# Check if cached image exists and is recent
54+
- name: Check for cached image
55+
id: cache_check
56+
run: |
57+
# Get the hash of files that would affect the Docker build
58+
BUILD_CONTEXT_HASH=$(find . -name "Dockerfile.dev" -o -name "go.mod" -o -name "go.sum" -o -path "./pkg/component/resources/onnx/*" | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
59+
echo "build_context_hash=${BUILD_CONTEXT_HASH}" >> $GITHUB_OUTPUT
60+
61+
# Check GitHub Container Registry for cached image first
62+
echo "cache_hit=false" >> $GITHUB_OUTPUT
63+
echo "Checking for cached image with hash: ${BUILD_CONTEXT_HASH}"
64+
65+
# Build dev image with comprehensive caching strategy (only if cache miss)
66+
- name: Build dev image with cache
67+
if: steps.cache_check.outputs.cache_hit != 'true'
68+
uses: docker/build-push-action@v6
69+
with:
70+
context: .
71+
file: Dockerfile.dev
72+
load: true
73+
build-args: |
74+
SERVICE_NAME=${{ env.SERVICE_NAME }}
75+
K6_VERSION=${{ env.K6_VERSION }}
76+
XK6_VERSION=${{ env.XK6_VERSION }}
77+
XK6_SQL_VERSION=${{ env.XK6_SQL_VERSION }}
78+
XK6_SQL_POSTGRES_VERSION=${{ env.XK6_SQL_POSTGRES_VERSION }}
79+
tags: |
80+
instill/${{ env.SERVICE_NAME }}:dev
81+
instill/${{ env.SERVICE_NAME }}:cache-${{ steps.cache_check.outputs.build_context_hash }}
82+
cache-from: |
83+
type=gha,scope=${{ github.ref_name }}-dev
84+
type=gha,scope=main-dev
85+
type=gha,scope=base-deps
86+
type=gha,scope=binary-deps
87+
type=gha,scope=go-deps
88+
type=gha,scope=model-artifacts
89+
cache-to: |
90+
type=gha,mode=max,scope=${{ github.ref_name }}-dev
91+
type=gha,mode=max,scope=base-deps
92+
type=gha,mode=max,scope=binary-deps
93+
type=gha,mode=max,scope=go-deps
94+
type=gha,mode=max,scope=model-artifacts
95+
6096
- name: Generate coverage report
6197
run: |
62-
make build-dev
6398
make coverage DBTEST=true OCR=true ONNX=true
6499
65100
- name: Upload coverage report

Dockerfile.dev

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ FROM golang:${GOLANG_VERSION}-bullseye AS base-deps
88
ARG TARGETOS TARGETARCH
99

1010
# Install all system packages in a single layer for better caching
11-
RUN apt update && \
11+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
12+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
13+
apt update && \
1214
apt install -y \
1315
wget \
1416
unzip \
@@ -28,12 +30,12 @@ RUN apt update && \
2830
libsoxr-dev \
2931
chromium \
3032
qpdf \
31-
jq && \
32-
rm -rf /var/lib/apt/lists/*
33+
jq
3334

3435
# Create Python virtual environment and install packages in one layer
35-
RUN python3 -m venv /opt/venv && \
36-
/opt/venv/bin/pip install --no-cache-dir pdfplumber mistral-common tokenizers docling==2.18.0
36+
RUN --mount=type=cache,target=/root/.cache/pip \
37+
python3 -m venv /opt/venv && \
38+
/opt/venv/bin/pip install pdfplumber mistral-common tokenizers docling==2.18.0
3739

3840
# ===============================
3941
# Stage 2: Binary dependencies
@@ -85,7 +87,8 @@ WORKDIR /${SERVICE_NAME}
8587

8688
# Copy go.mod and go.sum first for better caching of Go dependencies
8789
COPY go.mod go.sum ./
88-
RUN go mod download
90+
RUN --mount=type=cache,target=/go/pkg/mod \
91+
go mod download
8992

9093
# Install Go tools with build cache mounts
9194
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg \
@@ -139,9 +142,10 @@ COPY . .
139142
COPY ./pkg/component/resources/onnx/silero_vad.onnx /${SERVICE_NAME}/pkg/component/resources/onnx/silero_vad.onnx
140143

141144
# Final cleanup - remove wget and unzip since they're no longer needed
142-
RUN apt remove -y wget unzip jq && \
143-
apt autoremove -y && \
144-
rm -rf /var/lib/apt/lists/*
145+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
146+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
147+
apt remove -y wget unzip jq && \
148+
apt autoremove -y
145149

146150
# Set up proper permissions
147151
RUN chown -R nobody:nogroup /go && \

0 commit comments

Comments
 (0)