From 0f06d366f1e738e71dfa3a032cc987082dcde016 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Mon, 16 Dec 2024 17:35:45 +1100 Subject: [PATCH] feat: only load docker when needed --- .github/actions/build-cache/action.yml | 6 ++++++ .github/workflows/ci.yml | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-cache/action.yml b/.github/actions/build-cache/action.yml index a6635d4a93..21403b2517 100644 --- a/.github/actions/build-cache/action.yml +++ b/.github/actions/build-cache/action.yml @@ -1,5 +1,10 @@ name: Build Cache description: Cache builds +inputs: + docker: + description: If the test should load docker images + required: false + default: false runs: using: "composite" # Make sure to keep these cache entries in sync with those in writecache.yml @@ -22,6 +27,7 @@ runs: ${{ runner.os }}-hermit-cache- - name: Restore Docker Images uses: ScribeMD/docker-cache@0.5.0 + if: inputs.docker == 'true' with: key: docker-${{ runner.os }}-${{ hashFiles('docker-compose.yml') }} read-only: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0a7c10b4c..e39a6cb1aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -267,12 +267,23 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: Check if Docker Required + id: check-docker + run: | + result="$(git grep -E '//ftl:subscribe|DefaultPostgresDatabaseConfig|DefaultMySQLDatabaseConfig' -- "$(git grep -l '^//go:build integration' | xargs grep -l '^func ${{ matrix.test }}' | xargs -I {} dirname ./{})/testdata" || true)" + if [ -z "$result" ]; then + echo "docker not required" + echo "docker_req=false" >> "$GITHUB_ENV" + else + echo "docker required" + echo "docker_req=true" >> "$GITHUB_ENV" + fi - name: Build Cache uses: ./.github/actions/build-cache + with: + docker: ${{ env.docker_req }} - name: Init Hermit uses: cashapp/activate-hermit@v1.1.3 - - name: Docker Compose - run: just compose-up - name: Download Go Modules run: go mod download - name: Build Language Plugins