Skip to content

Commit

Permalink
Fix github action cache schema (#9918)
Browse files Browse the repository at this point in the history
* There were multiple workflows with same cache key, but no dependency between them, and also caching different paths.
* When the tests were changed to run on different go version, cache was not updated to include the version.
* Race condition between go1.17-test/go1.18-test/lint to update the same cache key, split into 3 caches.

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored May 10, 2022
1 parent 912a43c commit b607aa2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
path: |
\Users\runneradmin\go\pkg\mod
%LocalAppData%\go-build
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Run Unit tests
# use default Go build tags from Makefile.common
run: go test --tags containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper ./...
Expand Down
119 changes: 42 additions & 77 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,18 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install dependencies
if: steps.module-cache.outputs.hit != 'true'
if: steps.go-cache.outputs.hit != 'true'
run: make -j2 gomoddownload
- name: Install Tools
if: steps.tool-cache.outputs.cache-hit != 'true'
if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-tools
check-collector-module-version:
runs-on: ubuntu-latest
Expand All @@ -64,23 +59,18 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
- name: Cache Build
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Lint Build
uses: actions/cache@v3
with:
path: /home/runner/.cache/go-build
key: go-build-lint-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
key: go-lint-build-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Lint
run: make -j2 golint
checks:
Expand All @@ -98,23 +88,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
- name: Cache Build
uses: actions/cache@v3
with:
path: /home/runner/.cache/go-build
key: go-build-lint-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: CheckDoc
run: make checkdoc
- name: Porto
Expand Down Expand Up @@ -149,23 +129,18 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
- name: Cache Build
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Test Build
uses: actions/cache@v3
with:
path: /home/runner/.cache/go-build
key: go-build-unittest-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
key: go-test-build-${{ runner.os }}-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
- name: Run Unit Tests
run: make gotest
integration-tests:
Expand All @@ -183,18 +158,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Run Integration Tests
run: make integration-tests-with-cover

Expand All @@ -213,18 +183,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Correctness
run: make -C testbed run-correctness-traces-tests
correctness-metrics:
Expand All @@ -242,18 +207,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Correctness
run: make -C testbed run-correctness-metrics-tests

Expand Down Expand Up @@ -289,12 +249,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Build Collector ${{ matrix.binary }}
run: make otelcontribcol-${{ matrix.binary }}
- name: Upload Collector Binaries
Expand Down Expand Up @@ -416,12 +377,14 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
mkdir bin/ dist/
- name: Cache Tools
id: tool-cache
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Download Binaries
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -475,12 +438,14 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
mkdir bin/ dist/
- name: Cache Tools
id: tool-cache
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Set Release Tag
id: github_tag
run: ./.github/workflows/scripts/set_release_tag.sh
Expand Down
26 changes: 6 additions & 20 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,15 @@ jobs:
cache-name: cache-go-modules
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
env:
cache-name: cache-tool-binaries
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
- name: Install dependencies
key: loadtest-go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install Dependencies
if: steps.module-cache.outputs.hit != 'true'
run: make -j2 gomoddownload
- name: Install Tools
if: steps.tool-cache.outputs.cache-hit != 'true'
if: steps.module-cache.outputs.hit != 'true'
run: make install-tools
- run: make otelcontribcol-testbed
- name: Upload Collector Binaries
Expand All @@ -65,14 +58,6 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
env:
cache-name: cache-tool-binaries
with:
path: /home/runner/go/bin
key: v1-tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
- run: sudo chmod 0777 -R /opt
- name: Fluentbit Cache
id: fluentbit-cache
Expand Down Expand Up @@ -103,9 +88,10 @@ jobs:
cache-name: cache-go-modules
with:
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
key: loadtest-go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- run: mkdir -p results && touch results/TESTRESULTS.md
- name: Download Collector Binaries
uses: actions/download-artifact@v3
Expand Down

0 comments on commit b607aa2

Please sign in to comment.