-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (186 loc) · 5.8 KB
/
ci.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Continuous Integration
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BIFROEST_VENDOR: "Engity GmbH"
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
jobs:
evaluate:
name: Evaluate
runs-on: ubuntu-latest
outputs:
commit: "${{ steps.refs.outputs.commit }}"
version: "${{ steps.refs.outputs.version }}"
ref: "${{ steps.refs.outputs.ref }}"
pr: "${{ steps.refs.outputs.pr }}"
stage-binary: "${{ steps.refs.outputs.stage-binary }}"
stage-archive: "${{ steps.refs.outputs.stage-archive }}"
stage-image: "${{ steps.refs.outputs.stage-image }}"
stage-digest: "${{ steps.refs.outputs.stage-digest }}"
stage-publish: "${{ steps.refs.outputs.stage-publish }}"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
check-latest: true
- name: Cache Go
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Execute
id: refs
run: |
go run ./cmd/build evaluate-environment --log.colorMode=always
test:
name: Tests
needs: [ evaluate ]
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Ubuntu dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt install libpam0g-dev
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
check-latest: true
- name: Cache Go
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Install dependencies
run: |
go mod download
- name: Test
run: |
mkdir -p var
go test -v -covermode atomic "-coverprofile=var/profile.cov" ./...
- name: Send coverage
if: false
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
goveralls "-coverprofile=profile.cov" "-service=github" "-parallel" "-flagname=go-${{ matrix.os }}"
package:
name: Package
needs: [ evaluate ]
runs-on: "ubuntu-latest"
container:
image: ghcr.io/engity-com/build-images/go
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache Go
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache images dependencies
uses: actions/cache@v4
with:
path: .cache/dependencies/images
key: images-dependencies
restore-keys: images-dependencies
- name: Git configure
run: |
git config --global --add safe.directory $(pwd)
- name: Install dependencies
run: |
go mod download
- name: Build
run: |
go run ./cmd/build build --log.colorMode=always
- name: Archive package results
if: needs.evaluate.outputs.stage-publish == 'true'
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: dist
path: |
var/dist/**/*
documentation:
name: Documentation
needs: [ evaluate ]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: Create temp repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
path: var/doc
- name: Setup Git
working-directory: var/doc
run: |
git config user.email "[email protected]"
git config user.name "Engity Bot"
- name: Prepare temp repository
working-directory: var/doc
run: |
git branch -d temp-deploy || true
git switch --orphan temp-deploy
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ hashFiles('docs/requirements.txt') }}
- name: Install dependencies
run: |
pip install -r docs/requirements.txt
- name: Build
run: |
mkdocs --color build -c
rm -f var/doc/requirements.txt
- name: Deploy
if: needs.evaluate.outputs.stage-publish == 'true' && needs.evaluate.outputs.pr
working-directory: var/doc
run: |
git add -A
git commit -m "Release PR-${{ needs.evaluate.outputs.pr }}"
git push --delete origin "docs/pr-${{ needs.evaluate.outputs.pr }}" || true
git tag -d "docs/pr-${{ needs.evaluate.outputs.pr }}" || true
git tag -a "docs/pr-${{ needs.evaluate.outputs.pr }}" -m "Release PR-${{ needs.evaluate.outputs.pr }}"
git push origin "docs/pr-${{ needs.evaluate.outputs.pr }}"
echo "Documentation is available at https://bifroest.engity.org/pr-${{ needs.evaluate.outputs.pr }}/" >> "$GITHUB_STEP_SUMMARY"