Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use manual caching (again) #829

Merged
merged 4 commits into from
Mar 28, 2023
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
50 changes: 47 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
flags: [ "" ]
flags: [""]
arch:
- amd64
runner:
Expand All @@ -33,7 +33,35 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: true
cache: false

- name: Get Go environment
id: go-env
shell: bash
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

# Build cache key prefix, using runner OS and arch.
- name: Compute cache prefix
id: cache-prefix
shell: bash
env:
RUNNER_PREFIX: ${{ runner.os }}-${{ runner.arch }}-go
ARCH_PREFIX: ${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
RACE_PREFIX: ${{ contains(matrix.flags, '-race') && '-race' || '' }}
run:
echo "cache_prefix=$RUNNER_PREFIX$ARCH_PREFIX$RACE_PREFIX" >> $GITHUB_ENV

- name: Set up cache
uses: actions/cache@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ env.cache_prefix }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.cache_prefix }}-

- name: Run tests
env:
Expand All @@ -60,7 +88,23 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: true
cache: false

- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

- name: Set up cache
uses: actions/cache@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: test-examples-${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
test-examples-${{ runner.os }}-${{ runner.arch }}-go-

- name: Run tests
run: cd examples && go test ./...
21 changes: 20 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,26 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: true
cache: false

- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

# Notice: we're using read-only cache.
#
# See https://github.com/actions/setup-go/issues/357#issuecomment-1486486358
- name: Set up cache
uses: actions/cache/restore@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-go-

- name: Remove examples
run: rm -rf ./examples
Expand Down
25 changes: 19 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,30 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: true
cache: false

- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

- name: Download dependencies
run: go mod download && go mod tidy
- name: Set up cache
uses: actions/cache/restore@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: coverage-${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
coverage-${{ runner.os }}-${{ runner.arch }}-go-

- name: Checkout code
uses: actions/checkout@v3

- name: Run tests with coverage
run: make coverage
Expand Down
71 changes: 64 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,34 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
cache: true
go-version: '1.20'
cache: false

- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

# Notice: we're using read-only cache.
#
# See https://github.com/actions/setup-go/issues/357#issuecomment-1486486358
- name: Set up cache
uses: actions/cache/restore@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-go-

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 5m
# Package/build cache already provided by actions/setup-go.
# Package/build cache already provided above.
#
# Disable module cache.
skip-pkg-cache: true
Expand All @@ -41,8 +60,27 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
cache: true
go-version: '1.20'
cache: false

- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

# Notice: we're using read-only cache.
#
# See https://github.com/actions/setup-go/issues/357#issuecomment-1486486358
- name: Set up cache
uses: actions/cache/restore@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-go-

- name: Download dependencies
run: go mod download && go mod tidy
Expand All @@ -60,8 +98,27 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
cache: true
go-version: '1.20'
cache: false

- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

# Notice: we're using read-only cache.
#
# See https://github.com/actions/setup-go/issues/357#issuecomment-1486486358
- name: Set up cache
uses: actions/cache/restore@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-go-

- name: Download dependencies
run: go mod download && go mod tidy
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/pr-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,26 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: true
cache: false

- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

# Notice: we're using read-only cache.
#
# See https://github.com/actions/setup-go/issues/357#issuecomment-1486486358
- name: Set up cache
uses: actions/cache/restore@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-go-

- name: List dependencies
run: go list -json -m all > go.list
Expand Down