|
5 | 5 | go-version: |
6 | 6 | description: Go version to set up in go-install.ps1 format |
7 | 7 | default: 'go1.26' |
8 | | - create: |
9 | | - description: Create the cache |
10 | | - default: 'false' |
11 | | - lint-cache: |
12 | | - description: Restore the golangci-lint cache |
13 | | - default: 'false' |
14 | 8 |
|
15 | 9 | runs: |
16 | 10 | using: composite |
@@ -54,117 +48,3 @@ runs: |
54 | 48 | GOBIN="$(go env GOPATH)/bin" |
55 | 49 | fi |
56 | 50 | echo "$GOBIN" >> $GITHUB_PATH |
57 | | -
|
58 | | - # Avoid hardcoding the cache keys more than once. |
59 | | - - name: Get cache info |
60 | | - shell: bash |
61 | | - id: cache-info |
62 | | - env: |
63 | | - MODULES_KEY: go-modules-${{ runner.os }}-msft-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }} |
64 | | - LINT_KEY: golangci-lint-${{ runner.os }}-msft-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }} |
65 | | - BUILD_KEY: go-build-cache-${{ runner.os }}-msft-${{ steps.install-go.outputs.go-version }} |
66 | | - run: | |
67 | | - echo "modules-key=$MODULES_KEY" >> $GITHUB_OUTPUT |
68 | | - echo "lint-key=$LINT_KEY" >> $GITHUB_OUTPUT |
69 | | - echo "build-key=$BUILD_KEY" >> $GITHUB_OUTPUT |
70 | | - echo "GOLANGCI_LINT_CACHE=$RUNNER_TEMP/golangci-lint-cache" >> $GITHUB_ENV |
71 | | -
|
72 | | - - if: ${{ inputs.create != 'true' }} |
73 | | - name: Restore Go modules |
74 | | - uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 |
75 | | - with: |
76 | | - key: ${{ steps.cache-info.outputs.modules-key }} |
77 | | - path: | |
78 | | - ~/go/pkg/mod |
79 | | -
|
80 | | - - if: ${{ inputs.create != 'true' }} |
81 | | - name: Restore Go build cache |
82 | | - uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 |
83 | | - with: |
84 | | - key: unused-key-${{ github.run_id }} |
85 | | - restore-keys: ${{ steps.cache-info.outputs.build-key }}- |
86 | | - path: | |
87 | | - ~/.cache/go-build |
88 | | - ~/Library/Caches/go-build |
89 | | - ~/AppData/Local/go-build |
90 | | -
|
91 | | - - if: ${{ inputs.create != 'true' && inputs.lint-cache == 'true' }} |
92 | | - name: Restore golangci-lint cache |
93 | | - uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 |
94 | | - with: |
95 | | - key: unused-key-${{ github.run_id }} |
96 | | - restore-keys: ${{ steps.cache-info.outputs.lint-key }}- |
97 | | - path: ${{ env.GOLANGCI_LINT_CACHE }} |
98 | | - |
99 | | - - name: Set mtimes |
100 | | - shell: bash |
101 | | - run: | |
102 | | - find . -type f ! -path ./.git/\*\* | go run github.com/slsyy/mtimehash/cmd/mtimehash@v1.0.0 || true |
103 | | - find . -type d ! -path ./.git/\*\* -exec touch -d '1970-01-01T00:00:01Z' {} + || true |
104 | | -
|
105 | | - # All steps below are only run if the cache is being created. |
106 | | - |
107 | | - - if: ${{ inputs.create == 'true' }} |
108 | | - shell: bash |
109 | | - run: npm ci |
110 | | - |
111 | | - - if: ${{ inputs.create == 'true' }} |
112 | | - shell: bash |
113 | | - run: | |
114 | | - go mod download |
115 | | - cd _tools |
116 | | - go mod download |
117 | | -
|
118 | | - - if: ${{ inputs.create == 'true' }} |
119 | | - shell: bash |
120 | | - run: npx hereby build |
121 | | - |
122 | | - - if: ${{ inputs.create == 'true' }} |
123 | | - shell: bash |
124 | | - id: setup-go-test |
125 | | - run: npx hereby test |
126 | | - |
127 | | - - if: ${{ failure() && inputs.create == 'true' && steps.setup-go-test.conclusion == 'failure' }} |
128 | | - shell: bash |
129 | | - run: git diff --diff-filter=AM --no-index ./testdata/baselines/reference ./testdata/baselines/local |
130 | | - |
131 | | - - if: ${{ inputs.create == 'true' }} |
132 | | - shell: bash |
133 | | - run: npx hereby test --coverage |
134 | | - |
135 | | - - if: ${{ inputs.create == 'true' }} |
136 | | - shell: bash |
137 | | - run: npx hereby lint |
138 | | - |
139 | | - - if: ${{ inputs.create == 'true' }} |
140 | | - shell: bash |
141 | | - run: npx hereby lint --noembed |
142 | | - |
143 | | - - if: ${{ inputs.create == 'true' }} |
144 | | - shell: bash |
145 | | - run: npx dprint check |
146 | | - |
147 | | - - if: ${{ inputs.create == 'true' }} |
148 | | - name: Save Go modules |
149 | | - uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 |
150 | | - with: |
151 | | - key: ${{ steps.cache-info.outputs.modules-key }} |
152 | | - path: | |
153 | | - ~/go/pkg/mod |
154 | | -
|
155 | | - - if: ${{ inputs.create == 'true' }} |
156 | | - name: Save Go build cache |
157 | | - uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 |
158 | | - with: |
159 | | - key: ${{ steps.cache-info.outputs.build-key }}-${{ github.run_id }} |
160 | | - path: | |
161 | | - ~/.cache/go-build |
162 | | - ~/Library/Caches/go-build |
163 | | - ~/AppData/Local/go-build |
164 | | -
|
165 | | - - if: ${{ inputs.create == 'true' }} |
166 | | - name: Save golangci-lint cache |
167 | | - uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 |
168 | | - with: |
169 | | - key: ${{ steps.cache-info.outputs.lint-key }}-${{ github.run_id }} |
170 | | - path: ${{ env.GOLANGCI_LINT_CACHE }} |
0 commit comments