Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 19 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down
Loading