-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (116 loc) · 4.97 KB
/
go.yaml
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
133
134
135
136
137
138
name: Go package
on: [push]
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Install golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2
# go.work makes it necessary to find go.mod files to run linter in the corresponding dirs
- name: Run golangci-lint
run: >
find . -name "go.mod" -execdir $(go env GOPATH)/bin/golangci-lint run
--timeout=2m0s
--out-format=checkstyle:golangci-lint-report.xml
--skip-dirs="internal/group/" \;
- name: Check golangci-lint report for errors
run: find . -name "golangci-lint-report.xml" -exec grep "error" {} + && exit 1 || true
- name: Upload golangci-lint report
if: always()
uses: actions/upload-artifact@v3
with:
name: golangci-lint-report
path: |
./go/ocr2/decryptionplugin/golangci-lint-report.xml
./go/tdh2/golangci-lint-report.xml
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Ensure dependencies synced & tidy
working-directory: ./go
run: |
go work sync
pushd tdh2
go mod tidy
popd
pushd ocr2/decryptionplugin
go mod tidy
popd
git diff --minimal --exit-code
- name: Build and test OCR2 plugin
working-directory: ./go/ocr2/decryptionplugin
run: |
go build -v ./...
go test -v ./... -coverpkg=./... -coverprofile=ocr2_decryptionplugin_coverage.txt
- name: Race test OCR2 plugin
working-directory: ./go/ocr2/decryptionplugin
run: |
go test -race -v ./... -coverpkg=./... -coverprofile=ocr2_decryptionplugin_race_coverage.txt
- name: Download npm deps
working-directory: ./js/tdh2
run: npm install
- name: Build and test TDH2
working-directory: ./go/tdh2
run: |
go build -v ./...
go test -v ./... -coverpkg=./... -coverprofile=tdh_coverage.txt
- name: Race test TDH2
working-directory: ./go/tdh2
run: |
go test -race -v ./... -coverpkg=./... -coverprofile=tdh_race_coverage.txt
- name: Upload Go test reports
if: always()
uses: actions/upload-artifact@v3
with:
name: go-test-results
path: |
./go/ocr2/decryptionplugin/ocr2_decryptionplugin_coverage.txt
./go/ocr2/decryptionplugin/ocr2_decryptionplugin_race_coverage.txt
./go/tdh2/tdh_coverage.txt
./go/tdh2/tdh_race_coverage.txt
sonar-scan:
name: SonarQube
needs: [golangci-lint, build-and-test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout the repo
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all history for all tags and branches to provide more metadata for sonar reports
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Update golangci-lint report symlinks
# When golangci-lint is run in a multimodule project, it creates a report with relative paths to the files which should be updated
# The command returns true to avoid failing the workflow if the report is not found
continue-on-error: true
run: |
sed -i 's@file\ name="@file\ name="/github/workspace/go/ocr2/decryptionplugin/@' ./golangci-lint-report/ocr2/decryptionplugin/golangci-lint-report.xml && echo "OCR2 golangci-lint report symlinks updated"
sed -i 's@file\ name="@file\ name="/github/workspace/go/tdh2/@' ./golangci-lint-report/tdh2/golangci-lint-report.xml && echo "TDH2 golangci-lint report symlinks updated"
- name: Set SonarQube Report Paths
id: sonarqube_report_paths
shell: bash
run: |
echo "sonarqube_coverage_report_paths=$(find -type f -name '*coverage.txt' -printf "%p,")" >> $GITHUB_OUTPUT
echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")" >> $GITHUB_OUTPUT
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@69c1a75940dec6249b86dace6b630d3a2ae9d2a7 # v2.0.1
with:
args: >
-Dsonar.go.coverage.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_coverage_report_paths }}
-Dsonar.go.golangci-lint.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_golangci_report_paths }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}