Skip to content

Commit 94c5bc4

Browse files
authored
github action version check fix (#751)
* github action version check fix Signed-off-by: Woojoong Kim <woojoong.kim@intel.com> * github action version check fix Signed-off-by: Woojoong Kim <woojoong.kim@intel.com> * github action version check fix Signed-off-by: Woojoong Kim <woojoong.kim@intel.com> --------- Signed-off-by: Woojoong Kim <woojoong.kim@intel.com>
1 parent e5c1682 commit 94c5bc4

File tree

12 files changed

+309
-91
lines changed

12 files changed

+309
-91
lines changed

.github/workflows/build-test.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright 2024 Intel Corporation
3+
4+
name: Build and test workflow
5+
on:
6+
pull_request:
7+
branches:
8+
- master
9+
push:
10+
branches:
11+
- master
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Set up Helm
21+
uses: azure/setup-helm@v4
22+
with:
23+
version: latest
24+
token: ${{ secrets.GH_ONOS_PAT }}
25+
- name: build
26+
run: make deps
27+
test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
- name: Unit tests
34+
run: make test

.github/workflows/code-scan.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright 2024 Intel Corporation
3+
4+
name: Code scan workflow
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- master
10+
push:
11+
branches:
12+
- master
13+
14+
jobs:
15+
version-check:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
- name: check version
22+
run: |
23+
sudo snap install yq
24+
export COMPARISON_BRANCH=origin/master
25+
git branch -a
26+
make check-version
27+
lint:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
- name: helm-lint
34+
run: make lint
35+
license:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: check license
40+
run: make license
41+
fossa-check:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: FOSSA scan
46+
uses: fossa-contrib/fossa-action@v3
47+
with:
48+
fossa-api-key: 6d304c09a3ec097ba4517724e4a4d17d

.github/workflows/release.yml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright 2024 Intel Corporation
3+
# Copyright 2024 Kyunghee University
4+
name: Publish image and tag/release code
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
version-check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: check version
19+
run: |
20+
sudo snap install yq
21+
export COMPARISON_BRANCH=origin/master
22+
git branch -a
23+
make check-version
24+
25+
tag_versions:
26+
runs-on: ubuntu-latest
27+
needs: version-check
28+
if: github.repository_owner == 'onosproject'
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
- name: create release using REST API
34+
run: |
35+
export COMPARISON_BRANCH=${{ github.event.before }}
36+
sudo snap install yq
37+
target_charts=$(./build/bin/version_check.sh get_changed_charts)
38+
while IFS= read -r tc
39+
do
40+
tc_ver=$(yq e '.version' $tc/Chart.yaml)
41+
tag_name=$tc-$tc_ver
42+
curl -L \
43+
-X POST \
44+
-H "Accept: application/vnd.github+json" \
45+
-H "Authorization: Bearer ${{ secrets.GH_ONOS_PAT }}" \
46+
-H "X-GitHub-Api-Version: 2022-11-28" \
47+
https://api.github.com/repos/${{ github.repository }}/releases \
48+
-d '{
49+
"tag_name": "'"$tag_name"'",
50+
"target_commitish": "${{ github.event.repository.default_branch }}",
51+
"name": "'"$tag_name"'",
52+
"draft": false,
53+
"prerelease": false,
54+
"generate_release_notes": true
55+
}'
56+
done <<< $target_charts
57+
58+
publish-charts:
59+
runs-on: ubuntu-latest
60+
needs: version-check
61+
if: (github.repository_owner == 'onosproject')
62+
steps:
63+
- uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
- name: Set up Helm
67+
uses: azure/setup-helm@v4
68+
with:
69+
version: latest
70+
token: ${{ secrets.GH_ONOS_PAT }}
71+
- name: build
72+
run: make deps
73+
- name: publish charts
74+
run: |
75+
export COMPARISON_BRANCH=${{ github.event.before }}
76+
sudo snap install yq rsync
77+
target_charts=$(./build/bin/version_check.sh get_changed_charts)
78+
rm -rf staging && mkdir -p staging/onos-helm-charts
79+
while IFS= read -r tc
80+
do
81+
mkdir -p staging/onos-helm-charts/$tc
82+
tc_ver=$(yq e '.version' $tc/Chart.yaml)
83+
helm package $tc --destination staging/onos-helm-charts/$tc
84+
done <<< $target_charts
85+
cd staging
86+
curl -o current-index.yaml https://charts.onosproject.org/index.yaml
87+
helm repo index onos-helm-charts --url https://charts.onosproject.org/onos-helm-charts --merge current-index.yaml
88+
rm -rf current-index.yaml
89+
mv onos-helm-charts/index.yaml .
90+
cd ..
91+
chmod -R g+r staging/
92+
- name: rsync deployments
93+
uses: burnett01/rsync-deployments@7.0.1
94+
with:
95+
switches: -rvzh
96+
path: staging/
97+
remote_path: /srv/sites/charts.onosproject.org
98+
remote_host: static.opennetworking.org
99+
remote_user: ${{ secrets.JENKINS_USERNAME }}
100+
remote_key: ${{ secrets.JENKINS_SSHKEY }}
101+
remote_key_pass: ${{ secrets.JENKINS_PASSPHRASE }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ staging/
1010
requirements.lock
1111
**/charts/*
1212
build/build-tools
13+
venv

Makefile

+16-23
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,20 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
.PHONY: all test clean
5+
.PHONY: all test clean version-check
66

7-
all: test
7+
COMPARISON_BRANCH ?= master
88

9-
build-tools:=$(shell if [ ! -d "./build/build-tools" ]; then cd build && git clone https://github.com/onosproject/build-tools.git; fi)
10-
include ./build/build-tools/make/onf-common.mk
9+
all: deps
1110

12-
jenkins-test: jenkins_version_check deps # @HELP run the jenkins verification tests
13-
docker pull quay.io/helmpack/chart-testing:v3.7.0
14-
docker run --rm --name ct --volume `pwd`:/charts quay.io/helmpack/chart-testing:v3.7.0 sh -c "ct lint \
15-
--charts charts/onos-config,charts/onos-topo,charts/onos-cli,charts/onos-umbrella,charts/device-simulator \
16-
--debug --validate-maintainers=false"
11+
lint: # @HELP run helm lint
12+
./build/bin/helm_lint.sh
1713

18-
test: # @HELP run the integration tests
19-
test: version_check deps
20-
(kubectl delete ns onos-topo || exit 0) && kubectl create ns onos-topo && helmit test -n onos-topo ./test -c . --suite onos-topo
21-
(kubectl delete ns onos-config || exit 0) && kubectl create ns onos-config && helmit test -n onos-config ./test -c . --suite onos-config
22-
(kubectl delete ns onos-umbrella || exit 0) && kubectl create ns onos-umbrella && helmit test -n onos-umbrella ./test -c . --suite onos-umbrella
23-
24-
version_check: # @HELP run the version checker on the charts
25-
COMPARISON_BRANCH=master ./build/build-tools/chart_version_check
14+
check-version: # @HELP run the version checker on the charts
15+
COMPARISON_BRANCH=${COMPARISON_BRANCH} ./build/bin/version_check.sh all
2616

27-
jenkins_version_check: # @HELP run the version checker on the charts
28-
export COMPARISON_BRANCH=origin/master && export WORKSPACE=`pwd` && ./build/build-tools/chart_version_check
29-
30-
jenkins-publish: # @HELP publish version on github
31-
cd .. && GO111MODULE=on go install github.com/mikefarah/yq/v4@v4.16.2
32-
./build/build-tools/release-chart-merge-commit https://charts.onosproject.org ${WEBSITE_USER} ${WEBSITE_PASSWORD}
17+
test: # @HELP run the integration tests
18+
test: deps license lint
3319

3420
clean:: # @HELP clean up temporary files.
3521
rm -rf onos-umbrella/charts onos-umbrella/Chart.lock
@@ -39,3 +25,10 @@ deps: clean license
3925
helm dep build onos-umbrella
4026
helm dep build scale-sim
4127

28+
license: # @HELP run license checks
29+
rm -rf venv
30+
python3 -m venv venv
31+
. ./venv/bin/activate;\
32+
python3 -m pip install --upgrade pip;\
33+
python3 -m pip install reuse;\
34+
reuse lint

build/bin/helm_lint.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
# Copyright 2024 Intel Corporation
4+
5+
exit_code=0
6+
7+
for dir in $(find . -maxdepth 1 -mindepth 1 -type d); do
8+
if [[ -f "$dir/Chart.yaml" ]]; then
9+
helm lint "$dir"
10+
if [ $? == 1 ]
11+
then
12+
exit_code=2
13+
fi
14+
fi
15+
done
16+
exit $exit_code

build/bin/release

-61
This file was deleted.

0 commit comments

Comments
 (0)