From 79b6dd8477287b2d0daef2613f7b554e41974aa2 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 27 Oct 2026 14:33:07 -0700 Subject: [PATCH 1/2] Cache by arch and fix bug with 'latest' --- README.md | 2 +- action.yml | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1768207..76bee2a 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ If both `drivers` and `driver-list-file` inputs are provided, the explicit `driv ## Caching -This action automatically caches the dbc CLI binary based on the version and OS. Subsequent runs with the same version will be significantly faster. +This action automatically caches the dbc CLI binary based on the version, OS, and architecture. When `version` is `latest`, it is resolved to the current release first, so new releases are picked up automatically. Subsequent runs with the same version will be significantly faster. ## Error Handling diff --git a/action.yml b/action.yml index 3cce6fa..8fd5476 100644 --- a/action.yml +++ b/action.yml @@ -41,8 +41,24 @@ runs: - name: Determine cache key shell: bash id: cache-key + env: + INPUT_VERSION: ${{ inputs.version }} run: | - echo "key=dbc-cli-${{ runner.os }}-${{ inputs.version }}" >> $GITHUB_OUTPUT + # Resolve "latest" to a concrete version so new releases get a new cache key. + # Uses the releases/latest web redirect rather than the API to avoid rate limits. + VERSION="$INPUT_VERSION" + if [ "$VERSION" = "latest" ]; then + VERSION=$(curl -fsSI https://github.com/columnar-tech/dbc/releases/latest \ + | grep -i '^location:' | sed -E 's#.*/tag/([^[:space:]]+).*#\1#') + if [ -z "$VERSION" ]; then + echo "::error::Could not resolve latest dbc version" + exit 1 + fi + fi + # Normalize so "v0.3.1" and "0.3.1" share a cache entry + VERSION="${VERSION#v}" + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "key=dbc-cli-${{ runner.os }}-${{ runner.arch }}-$VERSION" >> $GITHUB_OUTPUT - name: Cache dbc CLI id: cache @@ -63,14 +79,14 @@ runs: if: runner.os != 'Windows' && steps.cache.outputs.cache-hit != 'true' shell: bash run: | - ${{ github.action_path }}/install-unix.sh "${{ inputs.version }}" + ${{ github.action_path }}/install-unix.sh "${{ steps.cache-key.outputs.version }}" - name: Install dbc CLI (Windows) id: install-windows if: runner.os == 'Windows' && steps.cache.outputs.cache-hit != 'true' shell: pwsh run: | - & "${{ github.action_path }}/install-windows.ps1" -Version "${{ inputs.version }}" + & "${{ github.action_path }}/install-windows.ps1" -Version "${{ steps.cache-key.outputs.version }}" - name: Add dbc to PATH (Unix) if: runner.os != 'Windows' && (steps.cache.outputs.cache-hit == 'true' || steps.install-unix.outcome == 'success') From b621a878c591032db35659a1bc96e8113d931dbc Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 27 Oct 2026 14:42:44 -0700 Subject: [PATCH 2/2] Separate out cache test into two jobs --- .github/workflows/test.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e70fcf..fa6565c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,24 +55,23 @@ jobs: with: drivers: 'sqlite' - test-cache: - name: Test caching + # actions/cache only saves in its post-job step, so populating and restoring + # the cache must happen in separate jobs. + test-cache-populate: + name: Test caching (populate) runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: First run - id: first uses: ./ - - name: Remove dbc and cached files - run: | - DBC_PATH=$(command -v dbc) - if [ -n "$DBC_PATH" ]; then - rm -f "$DBC_PATH" - fi - # Remove Linux-specific cached paths to test cache restoration - rm -rf ~/.local/bin/dbc ~/.local/share/dbc ~/.config/dbc + test-cache: + name: Test caching + needs: test-cache-populate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Second run (should restore from cache) id: second