Skip to content

Commit

Permalink
ci: fix caching for golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Świątek authored and Mikołaj Świątek committed Jun 26, 2023
1 parent 4ceccb1 commit daf3622
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/dev_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,34 @@ jobs:
arch_os: [ 'linux_amd64' ]
steps:
- uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
cache: false

- name: Get GOCACHE and GOMODCACHE
run: |
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_ENV"
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_ENV"
- uses: actions/cache/restore@v3
with:
path: |
${{ env.GOMODCACHE }}/cache
${{ env.GOCACHE }}
key: go-test-${{ env.GO_VERSION }}-${{matrix.arch_os}}-${{ hashFiles('pkg/**/go.sum', 'otelcolbuilder/.otelcol-builder.yaml') }}
restore-keys: |
go-test-${{ env.GO_VERSION }}-${{matrix.arch_os}}-
- uses: actions/cache@v3
with:
path: |
/home/runner/.cache/golangci-lint
key: ${{matrix.arch_os}}-golangcilint-${{ hashFiles('**/go.sum') }}
key: golangci-lint-${{ env.GO_VERSION }}-${{matrix.arch_os}}-${{ hashFiles('pkg/**/go.sum', 'otelcolbuilder/.otelcol-builder.yaml') }}
restore-keys: |
${{matrix.arch_os}}-golangcilint-
golangci-lint-${{ env.GO_VERSION }}-${{matrix.arch_os}}-
- name: Install golangci-lint
run: make install-golangci-lint
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,31 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
cache: false

- name: Get GOCACHE and GOMODCACHE
if: steps.changed-files.outputs.any_changed == 'true'
run: |
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_ENV"
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_ENV"
- uses: actions/cache@v3
- uses: actions/cache/restore@v3
if: steps.changed-files.outputs.any_changed == 'true'
with:
path: |
${{ env.GOMODCACHE }}/cache
${{ env.GOCACHE }}
key: go-test-${{ env.GO_VERSION }}-${{matrix.arch_os}}-${{ hashFiles('pkg/**/go.sum', 'otelcolbuilder/.otelcol-builder.yaml') }}
restore-keys: |
go-test-${{ env.GO_VERSION }}-${{matrix.arch_os}}-
- uses: actions/cache/restore@v3
with:
path: |
/home/runner/.cache/golangci-lint
key: ${{matrix.arch_os}}-golangcilint-${{ hashFiles('**/go.sum') }}
key: golangci-lint-${{ env.GO_VERSION }}-${{matrix.arch_os}}-${{ hashFiles('pkg/**/go.sum', 'otelcolbuilder/.otelcol-builder.yaml') }}
restore-keys: |
${{matrix.arch_os}}-golangcilint-
golangci-lint-${{ env.GO_VERSION }}-${{matrix.arch_os}}-
- name: Install golangci-lint
if: steps.changed-files.outputs.any_changed == 'true'
Expand Down

0 comments on commit daf3622

Please sign in to comment.