Skip to content

Commit eabd6c0

Browse files
committed
chore: use common workflows
Signed-off-by: gatici <[email protected]>
1 parent 0f39f11 commit eabd6c0

File tree

4 files changed

+78
-273
lines changed

4 files changed

+78
-273
lines changed

.github/workflows/main.yml

+32-248
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
# Copyright 2024 Canonical Ltd.
2+
# Copyright 2023 Canonical Ltd.
33
# Copyright 2024 Intel Corporation
4+
45
name: Main workflow
56

67
on:
@@ -10,262 +11,45 @@ on:
1011
push:
1112
branches:
1213
- main
13-
tags:
14-
- v*
1514

1615
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 }}
2931

3032
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-
uses: golangci/[email protected]
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 }}
4336

4437
hadolint:
45-
name: Dockerfile linter
46-
runs-on: ubuntu-latest
47-
48-
steps:
49-
- uses: actions/checkout@v4
50-
- name: Dockerfile linter
51-
uses: hadolint/[email protected]
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 }}
5841

5942
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 }}
6546

6647
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 }}
7451

7552
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-
- uses: docker/[email protected]
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 }}

.github/workflows/push.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright 2024 Intel Corporation
3+
# Copyright 2025 Canonical Ltd.
4+
name: GitHub release and Docker images
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- v*
12+
13+
jobs:
14+
push-images:
15+
uses: gatici/.github/.github/workflows/push-images.yml@add-workflows
16+
with:
17+
branch_name: ${{ github.ref }}
18+
registry: "registry.aetherproject.org"
19+
docker-registry: "registry.aetherproject.org/"
20+
docker-repository: "sdcore/"
21+
secrets: inherit
22+
23+
tag-github:
24+
uses: gatici/.github/.github/workflows/tag-github.yml@add-workflows
25+
26+
release-image:
27+
needs: tag-github
28+
uses: gatici/.github/.github/workflows/release-image.yml@add-workflows
29+
secrets: inherit
30+
31+
update-version:
32+
needs: tag-github
33+
uses: gatici/.github/.github/workflows/update-version.yml@add-workflows
34+
secrets: inherit
35+
36+
branch-release:
37+
needs: tag-github
38+
uses: gatici/.github/.github/workflows/update-version.yml@add-workflows
39+
secrets: inherit

.github/workflows/stale.yml

+7-15
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,12 @@ on:
66
schedule:
77
- cron: "0 0 * * *"
88

9-
env:
10-
DAYS_BEFORE_STALE: 120
11-
DAYS_BEFORE_CLOSE: 15
12-
139
jobs:
1410
stale:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- uses: actions/stale@v9
18-
with:
19-
repo-token: ${{ secrets.GITHUB_TOKEN }}
20-
stale-issue-message: 'This issue has been stale for ${{ env.DAYS_BEFORE_STALE }} days and will be closed in ${{ env.DAYS_BEFORE_CLOSE }} days. Comment to keep it open.'
21-
stale-pr-message: 'This pull request has been stale for ${{ env.DAYS_BEFORE_STALE }} days and will be closed in ${{ env.DAYS_BEFORE_CLOSE }} days. Comment to keep it open.'
22-
stale-issue-label: 'stale/issue'
23-
stale-pr-label: 'stale/pr'
24-
days-before-stale: ${{ env.DAYS_BEFORE_STALE }}
25-
days-before-close: ${{ env.DAYS_BEFORE_CLOSE }}
11+
uses: gatici/.github/.github/workflows/stale-issue.yml@add-workflows
12+
with:
13+
days_before_stale: 120
14+
days_before_close: 15
15+
cron_schedule: "0 0 * * *"
16+
secrets: inherit
17+

Makefile

-10
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,3 @@ golint:
110110
check-reuse:
111111
@docker run --rm -v $(CURDIR):/amf -w /amf omecproject/reuse-verify:latest reuse lint
112112

113-
run-aiab:
114-
$(eval VERSION := $(shell cat VERSION))
115-
@echo "version is $(VERSION)"
116-
alias kubectl=`sudo microk8s.kubectl`
117-
rm -rf $(HOME)/aether-in-a-box
118-
cd $(HOME) && \
119-
git clone https://github.com/gab-arrobo/aether-in-a-box && \
120-
cd aether-in-a-box && \
121-
yq -i '.5g-control-plane.images |= {"amf": "localhost:32000/5gc-amf:amf-testing"}' sd-core-5g-values.yaml && \
122-
CHARTS=latest make 5g-test

0 commit comments

Comments
 (0)