-
Notifications
You must be signed in to change notification settings - Fork 4
145 lines (119 loc) · 4.12 KB
/
checks.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
139
140
141
142
143
144
145
name: Code Checks
on: [push]
defaults:
run:
shell: bash
permissions:
contents: write
id-token: write
pages: write
jobs:
cleanliness:
name: Run Cleanliness Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install yamllint==1.33.0
- run: |
make manifests
( cd test/fakepolicy && make manifests )
make generate
make fmt
make vet
yamllint .
git diff --exit-code
# A separate job so that it can annotate the code
golangci:
name: Run golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
# Automatically uses ./.golangci.yml for configuration
tests:
name: Run Tests
runs-on: ubuntu-latest
# Prevent race conditions from multiple runs updating the wiki or GH pages.
# Additional runs will be queued as needed.
concurrency:
group: tests
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- run: |
make test
grep -v 'zz_generated.deepcopy.go' raw-cover.out > cover.out
# This publishes a report and a badge in the wiki, which is useful for pull-requests.
- name: Update coverage report
uses: ncruces/go-coverage-report@v0
with:
coverage-file: cover.out
output-dir: ${{ github.ref_name }}
report: true
chart: false
amend: false
continue-on-error: false
# The final steps publish the report, badge, and the (newly-generated) docs to GitHub Pages.
# They will only run when the branch is 'main'
- name: GH Pages - Setup
if: ${{ github.ref_name == 'main' }}
uses: actions/configure-pages@v5
- name: GH Pages - Generate
if: ${{ github.ref_name == 'main' }}
run: |
go install golang.org/x/pkgsite/cmd/pkgsite@latest
echo "Starting the doc server..."
pkgsite 2>/dev/null &
DOC_PID=$!
sleep 15 # Let it initialize
echo "Downloading the generated doc site"
wget -r -q -np -N -E -p -k 'http://localhost:8080/open-cluster-management.io/[email protected]' || true
kill -9 $DOC_PID
echo "Bringing all the files into a gh-pages directory"
mv 'localhost:8080' 'gh-pages'
# Adjust some localhost links
find ./gh-pages -type f -name "*.html" -print0 | \
xargs -0 sed -i 's|localhost:8080/files|broken-source-link|g'
find ./gh-pages -type f -name "*.html" -print0 | \
xargs -0 sed -i 's|http://localhost:8080|https://pkg.go.dev|g'
# Copy these from the wiki (generated by ncruces/go-coverage-report)
cp ./.github/wiki/main/coverage.html gh-pages/coverage.html
cp ./.github/wiki/main/coverage.svg gh-pages/coverage.svg
# Add a simple redirect index.html
cat << EOF > gh-pages/index.html
<!DOCTYPE html>
<html>
<head>
<title>Landing Page</title>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="0; URL=./open-cluster-management.io/governance-policy-nucleus.html" />
</head>
<body>
<p>Redirecting to the docs page...</p>
</body>
</html>
EOF
- name: GH Pages - Upload
if: ${{ github.ref_name == 'main' }}
uses: actions/upload-pages-artifact@v3
with:
path: './gh-pages'
- name: GH Pages - Deploy
if: ${{ github.ref_name == 'main' }}
id: deployment
uses: actions/deploy-pages@v4