1
1
# SPDX-License-Identifier: Apache-2.0
2
- # Copyright 2024 Canonical Ltd.
2
+ # Copyright 2023 Canonical Ltd.
3
3
# Copyright 2024 Intel Corporation
4
+
4
5
name : Main workflow
5
6
6
7
on :
10
11
push :
11
12
branches :
12
13
- main
13
- tags :
14
- - v*
15
14
16
15
jobs :
17
- staticcheck :
18
- runs-on : ubuntu-latest
19
- steps :
20
- - uses : actions/checkout@v4
21
- -
uses :
WillAbides/[email protected]
22
- with :
23
- go-version-file : ' go.mod'
24
-
25
- -
uses :
dominikh/[email protected]
26
- with :
27
- version : latest
28
- install-go : false
16
+ build :
17
+ uses : gatici/.github/.github/workflows/build.yml@add-workflows
18
+ with :
19
+ branch_name : ${{ github.ref }}
20
+
21
+ docker-build :
22
+ needs : build
23
+ uses : gatici/.github/.github/workflows/docker-build.yml@add-workflows
24
+ with :
25
+ branch_name : ${{ github.ref }}
26
+
27
+ static-analysis :
28
+ uses : gatici/.github/.github/workflows/static-analysis.yml@add-workflows
29
+ with :
30
+ branch_name : ${{ github.ref }}
29
31
30
32
lint :
31
- runs-on : ubuntu-latest
32
- steps :
33
- - uses : actions/checkout@v4
34
- - uses : actions/setup-go@v5
35
- with :
36
- go-version-file : ' go.mod'
37
-
38
- - name : golangci-lint
39
-
40
- with :
41
- version : latest
42
- args : -v --config ./.golangci.yml
33
+ uses : gatici/.github/.github/workflows/lint.yml@add-workflows
34
+ with :
35
+ branch_name : ${{ github.ref }}
43
36
44
37
hadolint :
45
- name : Dockerfile linter
46
- runs-on : ubuntu-latest
47
-
48
- steps :
49
- - uses : actions/checkout@v4
50
- - name : Dockerfile linter
51
-
52
- # Ignoring:
53
- # DL3008 warning: Pin versions in apt get install (e.g., apt-get install <package>=<version>)
54
- # DL3018 warning: Pin versions in apk add (e.g., apk add <package>=<version>)
55
- with :
56
- dockerfile : Dockerfile
57
- ignore : DL3008,DL3018
38
+ uses : gatici/.github/.github/workflows/hadolint.yml@add-workflows
39
+ with :
40
+ branch_name : ${{ github.ref }}
58
41
59
42
license-check :
60
- runs-on : ubuntu-latest
61
- steps :
62
- - uses : actions/checkout@v4
63
- - name : reuse lint
64
- uses : fsfe/reuse-action@v5
43
+ uses : gatici/.github/.github/workflows/license-check.yml@add-workflows
44
+ with :
45
+ branch_name : ${{ github.ref }}
65
46
66
47
fossa-scan :
67
- runs-on : ubuntu-latest
68
- steps :
69
- - uses : actions/checkout@v4
70
- - name : FOSSA scan
71
- uses : fossa-contrib/fossa-action@v3
72
- with :
73
- fossa-api-key : 0c3bbcdf20e157bbd487dae173751b28
48
+ uses : gatici/.github/.github/workflows/fossa-scan.yml@add-workflows
49
+ with :
50
+ branch_name : ${{ github.ref }}
74
51
75
52
unit-tests :
76
- runs-on : ubuntu-latest
77
- steps :
78
- - uses : actions/checkout@v4
79
- - uses : actions/setup-go@v5
80
- with :
81
- go-version-file : ' go.mod'
82
- cache : true
83
-
84
- - name : Unit tests
85
- run : go test ./...
86
-
87
- e2e-tests :
88
- needs :
89
- - unit-tests
90
- - lint
91
- - staticcheck
92
- runs-on : ubuntu-latest
93
- env :
94
- DOCKER_REGISTRY : localhost:32000
95
- DOCKER_REPOSITORY : /
96
- APP_NAME : amf
97
- steps :
98
- - name : Check out code into the Go module directory
99
- uses : actions/checkout@v4
100
-
101
- - name : Setup operator environment
102
- uses : charmed-kubernetes/actions-operator@main
103
- with :
104
- juju-channel : 3.6/stable
105
- provider : microk8s
106
- channel : 1.31-strict/stable
107
- lxd-channel : 5.21/stable
108
- microk8s-addons : " hostpath-storage dns registry helm"
109
-
110
- - name : Enable Multus addon
111
- continue-on-error : true
112
- run : |
113
- sudo microk8s addons repo add community https://github.com/canonical/microk8s-community-addons --reference feat/strict-fix-multus
114
- sudo microk8s enable multus
115
- sudo microk8s kubectl -n kube-system rollout status daemonset/kube-multus-ds
116
- sudo microk8s kubectl auth can-i create network-attachment-definitions
117
-
118
- - name : Export kubeconfig file
119
- run : |
120
- sudo microk8s kubectl config view --raw > $HOME/.kube/config
121
-
122
- - name : Build and push Docker image for testing
123
- env :
124
- DOCKER_TAG : ${{ env.APP_NAME }}-testing
125
- run : |
126
- make docker-build
127
- make docker-push
128
-
129
- - name : Run E2E test
130
- run : |
131
- make run-aiab
132
-
133
- create-github-release :
134
- needs : e2e-tests
135
- runs-on : ubuntu-latest
136
- if : ${{ github.repository_owner == 'omec-project'}}
137
- outputs :
138
- changed : ${{ steps.version-change.outputs.changed }}
139
- version : ${{ steps.version-change.outputs.version }}
140
- release_branch : ${{ steps.version-change.outputs.release_branch }}
141
- version_branch : ${{ steps.version-change.outputs.version_branch }}
142
- steps :
143
- - uses : actions/checkout@v4
144
- - name : Get changes
145
- id : version-file
146
- run : |
147
- if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep VERSION; then
148
- echo "changed=true" >> $GITHUB_OUTPUT
149
- version_before=$(git show ${{ github.event.before }}:VERSION)
150
- echo "version_before=$version_before" >> $GITHUB_OUTPUT
151
- else
152
- echo "VERSION file was not changed"
153
- fi
154
-
155
- - name : Validate change in version file
156
- id : version-change
157
- if : ${{ steps.version-file.outputs.changed == 'true' }}
158
- run : |
159
- version=$(cat VERSION)
160
- version_before_full=${{ steps.version-file.outputs.version_before }}
161
- version_before=${version_before_full::-4}
162
- echo "version=$version"
163
- echo "version_before=$version_before"
164
- validate="^[0-9]+\.[0-9]+\.[0-9]+$"
165
- if [[ $version =~ $validate ]]; then
166
- echo "changed=true" >> $GITHUB_OUTPUT
167
- echo "version=$version" >> $GITHUB_OUTPUT
168
- else
169
- echo "Version change not for release"
170
- fi
171
- if [[ $version_before =~ $validate ]]; then
172
- IFS='.' read -r major minor patch <<< "$version"
173
- IFS='.' read -r major_b minor_b patch_b <<< "$version_before"
174
- if [[ "$major" -ne "$major_b" ]] || [[ "$minor" -ne "$minor_b" ]]; then
175
- version_branch="$major_b.$minor_b"
176
- echo "release_branch=true" >> $GITHUB_OUTPUT
177
- echo "version_branch=$version_branch" >> $GITHUB_OUTPUT
178
- fi
179
- else
180
- echo "Version change not for branch release"
181
- fi
182
-
183
- - name : Create Release
184
- if : steps.version-change.outputs.changed == 'true'
185
- uses : comnoco/create-release@v2
186
- env :
187
- GITHUB_TOKEN : ${{ secrets.GH_OMEC_PAT }}
188
- with :
189
- tag_name : " v${{ steps.version-change.outputs.version }}"
190
- release_name : " v${{ steps.version-change.outputs.version }}"
191
- draft : false
192
- prerelease : false
193
- generate_release_notes : true
194
-
195
- release-image :
196
- needs : create-github-release
197
- if : needs.create-github-release.outputs.changed == 'true'
198
- runs-on : ubuntu-latest
199
- env :
200
- REGISTRY : docker.io
201
- DOCKER_REGISTRY : docker.io/
202
- DOCKER_REPOSITORY : omecproject/
203
- steps :
204
- - uses : actions/checkout@v4
205
- with :
206
- fetch-depth : 0
207
- - uses : actions/setup-go@v5
208
- with :
209
- go-version-file : ' go.mod'
210
-
211
- with :
212
- registry : ${{ env.REGISTRY }}
213
- username : ${{ secrets.DOCKERHUB_USERNAME }}
214
- password : ${{ secrets.DOCKERHUB_PASSWORD }}
215
-
216
- - name : Push release Docker image
217
- env :
218
- DOCKER_TAG : rel-${{ needs.create-github-release.outputs.version }}
219
- run : |
220
- make docker-build
221
- make docker-push
222
-
223
- update-version :
224
- runs-on : ubuntu-latest
225
- needs : create-github-release
226
- if : needs.create-github-release.outputs.changed == 'true'
227
- steps :
228
- - uses : actions/checkout@v4
229
- with :
230
- fetch-depth : 0
231
-
232
- - name : Increment version
233
- run : |
234
- version=${{ needs.create-github-release.outputs.version }}
235
- IFS='.' read -r major minor patch <<< "$version"
236
- patch_update=$((patch+1))
237
- NEW_VERSION="$major.$minor.$patch_update-dev"
238
- echo $NEW_VERSION > VERSION
239
- echo "Updated version: $NEW_VERSION"
240
-
241
- - name : Create Pull Request
242
- uses : peter-evans/create-pull-request@v7
243
- with :
244
- base : ${{ github.ref_name }}
245
- token : ${{ secrets.GH_OMEC_PAT }}
246
- commit-message : Update version
247
- committer : github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
248
- author : ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
249
- signoff : true
250
- branch : " chore/version-update"
251
- delete-branch : true
252
- title : Update version
253
- body : |
254
- Update VERSION file
255
- add-paths : |
256
- VERSION
257
-
258
- branch-release :
259
- runs-on : ubuntu-latest
260
- needs : create-github-release
261
- if : (needs.create-github-release.outputs.changed == 'true') && (needs.create-github-release.outputs.release_branch == 'true')
262
- env :
263
- GITHUB_TOKEN : ${{ secrets.GH_OMEC_PAT }}
264
- steps :
265
- - uses : actions/checkout@v4
266
- with :
267
- fetch-depth : 0
268
- -
uses :
peterjgrainger/[email protected]
269
- with :
270
- branch : " rel-${{ needs.create-github-release.outputs.version_branch }}"
271
- sha : ' ${{ github.event.pull_request.head.sha }}'
53
+ uses : gatici/.github/.github/workflows/unit-test.yml@add-workflows
54
+ with :
55
+ branch_name : ${{ github.ref }}
0 commit comments