-
Notifications
You must be signed in to change notification settings - Fork 279
80 lines (68 loc) · 2.55 KB
/
Copy pathtest.yml
File metadata and controls
80 lines (68 loc) · 2.55 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
name: Tests
on:
workflow_call:
permissions:
contents: read
jobs:
test-go-code:
name: Test Go Code (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-8cores-32gb]
fail-fast: false
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version: 'stable'
cache: true # This caches go modules based on go.sum
cache-dependency-path: go.sum
# Download all dependencies upfront (will be cached)
- name: Download Go dependencies
run: |
go mod download
go mod verify
# Cache Go build cache for faster compilation
# Note: ~/go/pkg/mod is already cached by actions/setup-go with cache: true
- name: Cache Go build cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-
# Cache Go tools (gotestfmt only for tests)
- name: Cache Go tools
id: cache-go-tools
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/go/bin
key: ${{ runner.os }}-go-tools-${{ hashFiles('go.mod') }}-gotestfmt-v2
restore-keys: |
${{ runner.os }}-go-tools-
# Only install gotestfmt if not cached
- name: Install gotestfmt (if not cached)
if: steps.cache-go-tools.outputs.cache-hit != 'true'
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.44.1
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Run tests with all dependencies already cached
- name: Run tests with coverage
run: task test-coverage
- name: Upload coverage reports to Codecov with GitHub Action
if: startsWith(matrix.os, 'ubuntu')
uses: codecov/codecov-action@cddd853df119a48c5be31a973f8cd97e12e35e16 # v6.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: stacklok/toolhive
- name: Upload coverage to Coveralls
if: startsWith(matrix.os, 'ubuntu')
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2
with:
file: coverage/coverage.out
fail-on-error: false