Skip to content

image run tests

image run tests #3

Workflow file for this run

name: Run Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
find-examples:
runs-on: ubuntu-latest
outputs:
examples: ${{ steps.find-examples.outputs.examples }}
steps:
- uses: actions/checkout@v4
- name: Find examples with test.json
id: find-examples
run: |
examples=$(find examples -name "test.json" -exec dirname {} \; | xargs -n 1 basename | jq -R -s -c 'split("\n")[:-1]')
echo "examples=$examples" >> "$GITHUB_OUTPUT"
test:
needs: find-examples
runs-on: ubuntu-latest
strategy:
matrix:
example: ${{ fromJson(needs.find-examples.outputs.examples) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.4"
cache: true
# Set up BuildKit cache
- name: Set up BuildKit cache
uses: actions/cache@v4
with:
path: /tmp/buildkit-cache
key: ${{ runner.os }}-buildkit-${{ matrix.example }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildkit-${{ matrix.example }}-
${{ runner.os }}-buildkit-
- name: Start BuildKit
run: |
# Start BuildKit with cache configuration
docker run --rm --privileged -d \
-v /tmp/buildkit-cache:/cache \
--name buildkit \
--env BUILDKIT_DEBUG=1 \
moby/buildkit \
--debug \
--oci-worker-gc=false \
--oci-worker-snapshotter=overlayfs \
--root /cache/buildkit
# Wait for BuildKit to be ready
sleep 5
echo "BUILDKIT_HOST=docker-container://buildkit" >> $GITHUB_ENV
- name: Install dependencies
run: go mod download
- name: Run test for ${{ matrix.example }}
run: |
go test -v ./integration_tests -run "TestExamplesIntegration/${{ matrix.example }}" -timeout 30m
# Export BuildKit cache after tests
- name: Export BuildKit cache
if: always()
run: |
docker exec buildkit buildctl prune --keep-storage 5GB
docker stop buildkit