Skip to content

Commit 0ce1e67

Browse files
authored
Update chainlink-testing-framework/setup-go and chainlink-testing-framework/run-tests actions (#191)
* Update caching in setup-go GHA Update caching and use go.mod instead of go.sum as hashFile as discussed in actions/setup-go#478 (comment) * Remove cache_key_id and use cache_version This makes sure that the same cache key is used everywhere unless cache_version is changed. * Remove download mods step This is unnecessary step. The mods are downloaded anyway and then cached at the end of a job * Do not cache go builds by default Go builds can be fast and do not rely on network. This will reduce cache size. * Restore cache_key_id * Update related GHA * Use local actions for run-tests * Update cache keys * Fix * Revert using local actions * Bump * Fix * Bring back test_download_vendor_packages_command * Remove cache_version as cache_key_id can include this * Make test_download_vendor_packages_command optional * Bump * Bump
1 parent fdaf56b commit 0ce1e67

File tree

3 files changed

+47
-31
lines changed

3 files changed

+47
-31
lines changed

chainlink-testing-framework/run-tests/action.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,18 @@ inputs:
203203
runs:
204204
using: composite
205205
steps:
206+
- name: Checkout chainlink-testing-framework to use citool
207+
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
208+
with:
209+
repository: smartcontractkit/chainlink-testing-framework
210+
ref: main
211+
fetch-depth: 0
212+
path: ctf
213+
206214
# Setup Tools and libraries
207215
- name: Setup environment
208216
if: inputs.run_setup == 'true'
209-
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/[email protected].20
217+
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/setup-run-tests-environment@e4dd107855e2359e2d762a48872a3e9365e70f11 # v2.3.30
210218
with:
211219
test_download_vendor_packages_command: ${{ inputs.test_download_vendor_packages_command }}
212220
go_version: ${{ inputs.go_version }}
@@ -328,14 +336,6 @@ runs:
328336
shell: bash
329337
run: go run ${{ github.action_path }}/mask-testsecrets/main.go "${{ inputs.test_secrets_override_base64 }}"
330338

331-
- name: Checkout chainlink-testing-framework to use citool
332-
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
333-
with:
334-
repository: smartcontractkit/chainlink-testing-framework
335-
ref: main
336-
fetch-depth: 0
337-
path: ctf
338-
339339
- name: Create default test config override
340340
if: inputs.test_config_override_base64 == ''
341341
shell: bash
Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
name: setup-go
22
description: Common golang setup
33
inputs:
4-
test_download_vendor_packages_command:
5-
required: false
6-
description: The command to download the go modules
7-
default: make download
84
go_version:
95
required: false
106
description: Go version to install
@@ -16,9 +12,13 @@ inputs:
1612
required: false
1713
description: Only restore the cache, set to true if you want to restore and save on cache hit miss
1814
default: "false"
15+
cache_builds:
16+
required: false
17+
description: Cache go builds
18+
default: "false"
1919
cache_key_id:
2020
required: true
21-
description: Cache go vendors unique id
21+
description: Cache key id
2222
no_cache:
2323
required: false
2424
description: Do not use a go cache
@@ -27,6 +27,9 @@ inputs:
2727
required: false
2828
description: Should we check go mod tidy
2929
default: "true"
30+
test_download_vendor_packages_command:
31+
required: false
32+
description: The command to download the go modules
3033

3134
runs:
3235
using: composite
@@ -39,38 +42,51 @@ runs:
3942
check-latest: true
4043
cache: false
4144

42-
- name: Cache Vendor Packages
45+
- name: Set go cache keys
46+
shell: bash
47+
id: go-cache-dir
48+
run: |
49+
echo "gomodcache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
50+
echo "gobuildcache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
51+
52+
- name: Cache Go Modules
4353
if: inputs.cache_restore_only == 'false' && inputs.no_cache == 'false'
4454
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
4555
id: cache-packages
4656
with:
47-
path: |
48-
~/.cache/go-build
49-
~/go/pkg/mod
50-
~/go/bin
51-
key: ${{ runner.os }}-${{ inputs.cache_key_id }}-${{ hashFiles('**/go.sum') }}
57+
path: ${{ steps.go-cache-dir.outputs.gomodcache }}
58+
key: ${{ runner.os }}-${{ inputs.cache_key_id }}-gomod-${{ hashFiles(inputs.go_mod_path) }}
59+
restore-keys: |
60+
${{ runner.os }}-${{ inputs.cache_key_id }}-gomod-
61+
62+
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
63+
if: inputs.cache_restore_only == 'false' && inputs.cache_builds == 'true'
64+
name: Cache Go Builds
65+
with:
66+
path: ${{ steps.go-cache-dir.outputs.gobuildcache }}
67+
# The lifetime of go build outputs is pretty short, so we make our primary cache key be the branch name
68+
key: ${{ runner.os }}-${{ inputs.cache_key_id }}-gobuild-${{ hashFiles(inputs.go_mod_path) }}
5269
restore-keys: |
53-
${{ runner.os }}-${{ inputs.cache_key_id }}-
70+
${{ runner.os }}-${{ inputs.cache_key_id }}-gobuild-
5471
55-
- name: Restore Cache Vendor Packages
72+
- name: Restore Go Modules
5673
if: inputs.cache_restore_only != 'false' && inputs.no_cache == 'false'
5774
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
5875
id: restore-cache-packages
5976
with:
6077
path: |
61-
~/.cache/go-build
62-
~/go/pkg/mod
63-
~/go/bin
64-
key: ${{ runner.os }}-${{ inputs.cache_key_id }}-${{ hashFiles('**/go.sum') }}
78+
${{ steps.go-cache-dir.outputs.gomodcache }}
79+
key: ${{ runner.os }}-${{ inputs.cache_key_id }}-gomod-${{ hashFiles(inputs.go_mod_path) }}
6580
restore-keys: |
66-
${{ runner.os }}-${{ inputs.cache_key_id }}-
81+
${{ runner.os }}-${{ inputs.cache_key_id }}-gomod-
6782
6883
- name: Tidy and check files
6984
if: ${{ inputs.should_tidy == 'true' }}
7085
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/[email protected]
7186
with:
7287
go_mod_path: ${{ inputs.go_mod_path }}
7388

74-
- name: Download Go Vendor Packages
89+
- name: Run go mod download
90+
if: inputs.test_download_vendor_packages_command
7591
shell: bash
76-
run: ${{ inputs.test_download_vendor_packages_command }}
92+
run: ${{ inputs.test_download_vendor_packages_command }}

chainlink-testing-framework/setup-run-tests-environment/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ runs:
6161
# Go setup and caching
6262
- name: Setup Go
6363
if: inputs.go_necessary == 'true'
64-
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/[email protected].14
64+
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/setup-go@e4dd107855e2359e2d762a48872a3e9365e70f11 # v2.3.30
6565
with:
66-
test_download_vendor_packages_command: ${{ inputs.test_download_vendor_packages_command }}
6766
go_version: ${{ inputs.go_version }}
6867
go_mod_path: ${{ inputs.go_mod_path }}
6968
cache_restore_only: ${{ inputs.cache_restore_only }}
7069
cache_key_id: ${{ inputs.cache_key_id }}
7170
should_tidy: ${{ inputs.should_tidy }}
7271
no_cache: ${{ inputs.no_cache }}
72+
test_download_vendor_packages_command: ${{ inputs.test_download_vendor_packages_command }}
7373

7474
# Setup AWS cred and K8s context
7575
- name: Configure AWS Credentials

0 commit comments

Comments
 (0)