From 90eae0c561a15f901ed28da73c58a9aa2cadeb2e Mon Sep 17 00:00:00 2001 From: James Brown Date: Fri, 14 Jun 2024 10:42:09 -0700 Subject: [PATCH] fix: include more tool paths in the cache slug for pre-commit action runs (#1) --- .github/workflows/main.yml | 7 ++++++- action.yml | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 116a2d7..4ddbcd1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,6 +8,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' - name: self test action uses: ./ diff --git a/action.yml b/action.yml index 18ded0d..de5c04b 100644 --- a/action.yml +++ b/action.yml @@ -12,9 +12,21 @@ runs: shell: bash - run: python -m pip freeze --local shell: bash + - run: | + tf=$(mktemp) + echo "arch=$(uname -p)" >> "$tf" + for program in python ruby go cargo ; do + if command -v $program >/dev/null 2>&1 ; then + echo "$program=$(which $program)" >> "$tf" + fi + done + hash="$(sha256sum < "$tf" | awk '{print $1}')" + echo "dependencyHash=${hash}" >> $GITHUB_OUTPUT + shell: bash + id: computeDependencies - uses: actions/cache@v4 with: path: ~/.cache/pre-commit - key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + key: pre-commit-3|${{ steps.computeDependencies.outputs.dependencyHash }}|${{ hashFiles('.pre-commit-config.yaml') }} - run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }} shell: bash