Repository navigation
132 lines (116 loc) · 3.97 KB
/
Copy pathgo-mod-cache.yml
File metadata and controls
132 lines (116 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Go Module Cache
# This workflow is responsible for updating the Go Module Cache.
# It will maintain the cache: linux-gomod-1-<hash>
# All other workflows should only restore this cache.
# This workflow is useful because it will:
# 1. Create the cache if it doesn't exist
# - This can be a problem when multiple jobs load the same cache.
# Only one will get priority to create the cache.
# 2. Should not fail, therefore creating a cache
# - When a Job errors/fails it will not upload a new cache.
# So when test/build jobs are responsible for creating the new cache,
# they can fail causing cache misses on subsequent runs. Even though
# the dependencies haven't changed.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- develop
pull_request:
workflow_dispatch:
jobs:
filter:
name: Detect Go module changes
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
changed: ${{ steps.changes.outputs.src || 'true' }}
spot_flag: ${{ steps.spot.outputs.spot_flag }}
spot_param: ${{ steps.spot.outputs.spot_param }}
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Resolve Spot Setting
id: spot
uses: $/.github/actions/setup-runner-spot
- uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
if: github.event_name == 'pull_request'
id: changes
with:
filters: |
src:
- '**/go.mod'
- '**/go.sum'
- '.github/actions/setup-go/**'
go-cache:
name: Go Cache ${{ matrix.suffix }}
needs: [filter]
if: needs.filter.outputs.changed == 'true'
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
suffix: "Core (Github-hosted)"
- runs-on: ubuntu-latest
suffix: "Deployment (Github-hosted)"
go-mod-directory: "deployment/"
- runs-on:
- runs-on=${{ github.run_id }}-core
- cpu=8
- ram=16
- family=c6id
- ${{ needs.filter.outputs.spot_param }}
- extras=s3-cache
suffix: "Core (Self-hosted)"
- runs-on:
- runs-on=${{ github.run_id }}-deployment
- cpu=8
- ram=16
- family=c6id
- ${{ needs.filter.outputs.spot_param }}
- extras=s3-cache
suffix: "Deployment (Self-hosted)"
go-mod-directory: "deployment/"
runs-on: ${{ matrix.runs-on }}
permissions:
contents: read
pull-requests: read
steps:
- name: Enable S3 Cache for Self-Hosted Runners
uses: runs-on/action@4e5f72399b6b17f2e79c511c1b38a315a64d22dc # v2.2.0
- name: Checkout the repo
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setup Go
id: setup-go
uses: ./.github/actions/setup-go
with:
only-modules: "true"
restore-module-cache-only: "false"
go-version-file: ${{ matrix.go-mod-directory }}go.mod
go-module-file: ${{ matrix.go-mod-directory }}go.sum
- name: go mod download
if: ${{ steps.setup-go.outputs.primary-cache-hit-modules != 'true' }}
shell: bash
working-directory: ${{ matrix.go-mod-directory || '.' }}
run: |
echo "::group::go mod download"
go mod download
echo "::endgroup::"
- name: Fetch other dependencies
if: ${{ steps.setup-go.outputs.primary-cache-hit-modules != 'true' }}
shell: bash
run: |
echo "::group::Install LOOP plugins"
make install-plugins-public
echo "::endgroup::"
echo "::group::Install testing tools"
go install gotest.tools/gotestsum@v1.13.0
echo "::endgroup::"