|
11 | 11 | jobs: |
12 | 12 | codecov: |
13 | 13 | name: codecov |
14 | | - runs-on: ubuntu-latest |
| 14 | + runs-on: ubuntu-24.04-8core-amd64 |
15 | 15 | permissions: |
16 | 16 | contents: read |
17 | 17 | pull-requests: write |
|
28 | 28 | ports: |
29 | 29 | - 5432:5432 |
30 | 30 | 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 | | -
|
45 | 31 | - uses: actions/checkout@v4 |
46 | 32 | with: |
47 | 33 | token: ${{ secrets.GITHUB_TOKEN }} |
|
57 | 43 | go-version: ${{ env.GOLANG_VERSION }} |
58 | 44 | cache: false |
59 | 45 |
|
| 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 | +
|
60 | 96 | - name: Generate coverage report |
61 | 97 | run: | |
62 | | - make build-dev |
63 | 98 | make coverage DBTEST=true OCR=true ONNX=true |
64 | 99 |
|
65 | 100 | - name: Upload coverage report |
|
0 commit comments