Skip to content

Commit

Permalink
feat: use shared cache for go
Browse files Browse the repository at this point in the history
  • Loading branch information
jose-fully-ported committed Sep 27, 2023
1 parent c4a6bd1 commit 1fce83d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 22 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/pr_push_checks_go.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
name: Go PR Checks

on:
pull_request:
paths:
- '**.go'
- '**.mod'
- '**.sum'
- '.github/workflows/pr_push_checks_go.yaml'
workflow_dispatch: {}

concurrency:
group: pr-go-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -23,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup Go Cache
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: |
~/.cache/go-build
Expand All @@ -32,7 +27,6 @@ jobs:
- uses: actions/setup-go@v4
with:
cache: false
go-version: '1.20.5'
go-version-file: go.mod
- name: Download Go Modules
run: go mod download
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/pr_push_checks_go_cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Go Cache PR Checks

on:
push:
paths:
- '**.go'
- '**.mod'
- '**.sum'
- '.github/golangci-lint.yaml'
- '.github/workflows/pr_push_checks_go.yaml'
- '.github/workflows/pr_push_checks_go_cache.yaml'
- '.github/workflows/pr_push_checks_go_lint.yaml'

concurrency:
group: pr-go-cache-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
testing_matrix:
name: Setup cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go Cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: porter-go-${{ hashFiles('**/go.sum') }}
restore-keys: porter-go-
- uses: actions/setup-go@v4
with:
cache: false
go-version-file: go.mod
- name: Download Go Modules
run: go mod download
- name: Trigger lint workflow
run: |
if [[ -n "$GITHUB_HEAD_REF" ]]; then
branch="$GITHUB_HEAD_REF"
elif [[ -n "$GITHUB_REF_NAME" ]]; then
branch="$GITHUB_REF_NAME"
fi
gh workflow run pr_push_checks_go_lint.yaml -r "$branch"
gh workflow run pr_push_checks_go.yaml -r "$branch"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 6 additions & 14 deletions .github/workflows/pr_push_checks_go_lint.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
name: Go Lint PR Checks

on:
pull_request:
paths:
- '**.go'
- '**.mod'
- '**.sum'
- '.github/golangci-lint.yaml'
- '.github/workflows/pr_push_checks_go_lint.yaml'
workflow_dispatch: {}

concurrency:
group: pr-go-lint-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -18,20 +12,18 @@ jobs:
name: Go Linter
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
cache: false
go-version: '1.20.5'
go-version-file: go.mod
- uses: actions/checkout@v3
- name: Setup Go Cache
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: porter-go-${{ hashFiles('**/go.sum') }}
restore-keys: porter-go-`
- uses: actions/setup-go@v4
with:
cache: false
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down

0 comments on commit 1fce83d

Please sign in to comment.