Repository navigation
131 lines (114 loc) · 3.97 KB
/
Copy pathtest.yml
File metadata and controls
131 lines (114 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
name: Test
on: [push, pull_request]
jobs:
test:
strategy:
matrix: &test-ubuntu-matrix
go-version:
- 1.26.x
- 1.27.x
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps: &test-steps
- name: Checkout
uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: ${{ matrix.go-version }}
- name: Download dependencies
run: go mod download
- name: Run tests
run: go test -v -race ./...
test-others:
needs: [ test ]
strategy:
matrix:
go-version:
- 1.26.x
- 1.27.x
os:
- ubuntu-latest
- macos-latest
- windows-latest
exclude:
- *test-ubuntu-matrix
runs-on: ${{ matrix.os }}
steps: *test-steps
quality:
needs: [ test ]
strategy:
matrix: *test-ubuntu-matrix
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: ${{ matrix.go-version }}
- name: Download dependencies
run: go mod download
- name: Test with JSON output, for SonarQube
run: go test -json ./... > .gotest.out
- name: Run tests with coverage
run: go test -coverprofile .coverage.out -covermode atomic ./...
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v7
env:
# https://sonarcloud.io/project/configuration/GitHubActions?id=dolmen-go_openapi-preprocessor
# https://github.com/dolmen-go/openapi-preprocessor/settings/secrets/actions
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
# See also sonar-project.properties
args: >
-Dsonar.go.tests.reportPaths=.gotest.out
-Dsonar.go.coverage.reportPaths=.coverage.out
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7
with:
disable_search: true
files: ./.coverage.out
disable_telem: true
fail_ci_if_error: true
report_type: coverage
# https://app.codecov.io/gh/dolmen-go/openapi-preprocessor/config/general
# https://github.com/dolmen-go/openapi-preprocessor/settings/secrets/actions
token: ${{ secrets.CODECOV_TOKEN }}
# Build the release as release.yml does, without publishing it. One build:
# two builds in the same job would share Go's build cache, so they would
# prove little. Reproducibility is checked by .goreleaser/reproduce.sh
# against a published release, images included.
release-dry-run:
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-go@v7
with:
go-version: stable
# For the SBOMs of the archives
- uses: anchore/sbom-action/download-syft@v0
- name: Check GoReleaser config
uses: goreleaser/goreleaser-action@v7
with:
version: '~> v2'
args: check
# ko loads the linux/amd64 image into the runner's Docker daemon
- name: Build release (snapshot)
uses: goreleaser/goreleaser-action@v7
with:
version: '~> v2'
args: release --snapshot --clean
- name: Check the archives
run: |
# shellcheck disable=SC2046 # one path per archive, without spaces
.goreleaser/check-archives.sh "$(git log -1 --format=%ct)" $(jq -r '.[] | select(.type == "Archive" and .extra.Format == "tar.gz") | .path' dist/artifacts.json)
- name: Smoke test the image
run: |
image=$(jq -r 'first(.[] | select(.type == "Docker Manifest")) | .name' dist/artifacts.json)
[ -n "$image" ] || { echo "FAIL: no Docker Manifest in dist/artifacts.json" >&2; exit 1; }
echo "# $image"
SOURCE_DATE_EPOCH="$(git log -1 --format=%ct)" .goreleaser/smoke-test.sh "$image"