Skip to content

Commit

Permalink
github action version check fix
Browse files Browse the repository at this point in the history
Signed-off-by: Woojoong Kim <[email protected]>
  • Loading branch information
woojoong88 committed Jul 1, 2024
1 parent e5c1682 commit 856f0c3
Show file tree
Hide file tree
Showing 10 changed files with 300 additions and 87 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 Intel Corporation

name: Build and test workflow
on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: latest
token: ${{ secrets.GH_ONOS_PAT }}
- name: build
run: make deps
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Unit tests
run: make test
48 changes: 48 additions & 0 deletions .github/workflows/code-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 Intel Corporation

name: Code scan workflow

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
version-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: check version
run: |
sudo snap install yq
export COMPARISON_BRANCH=origin/master
git branch -a
make check-version
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: helm-lint
run: make lint
license:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: check license
run: make license
fossa-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: FOSSA scan
uses: fossa-contrib/fossa-action@v3
with:
fossa-api-key: 6d304c09a3ec097ba4517724e4a4d17d
101 changes: 101 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 Intel Corporation
# Copyright 2024 Kyunghee University
name: Publish image and tag/release code

on:
push:
branches:
- master

jobs:
version-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: check version
run: |
sudo snap install yq
export COMPARISON_BRANCH=origin/master
git branch -a
make check-version
tag_versions:
runs-on: ubuntu-latest
needs: version-check
if: github.repository_owner == 'onosproject'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: create release using REST API
run: |
export COMPARISON_BRANCH=${{ github.event.before }}
sudo snap install yq
target_charts=$(./build/bin/version_check.sh get_changed_charts)
while IFS= read -r tc
do
tc_ver=$(yq e '.version' $tc/Chart.yaml)
tag_name=$tc-$tc_ver
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_ONOS_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases \
-d '{
"tag_name": "'"$tag_name"'",
"target_commitish": "${{ github.event.repository.default_branch }}",
"name": "'"$tag_name"'",
"draft": false,
"prerelease": false,
"generate_release_notes": true
}'
done <<< $target_charts
publish-charts:
runs-on: ubuntu-latest
needs: version-check
if: (github.repository_owner == 'onosproject')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: latest
token: ${{ secrets.GH_ONOS_PAT }}
- name: build
run: make deps
- name: publish charts
run: |
export COMPARISON_BRANCH=${{ github.event.before }}
sudo snap install yq rsync
target_charts=$(./build/bin/version_check.sh get_changed_charts)
rm -rf staging && mkdir -p staging/onos-helm-charts
while IFS= read -r tc
do
mkdir -p staging/onos-helm-charts/$tc
tc_ver=$(yq e '.version' $tc/Chart.yaml)
helm package $tc --destination staging/onos-helm-charts/$tc
done <<< $target_charts
cd staging
curl -o current-index.yaml https://charts.onosproject.org/index.yaml
helm repo index onos-helm-charts --url https://charts.onosproject.org/onos-helm-charts --merge current-index.yaml
rm -rf current-index.yaml
mv onos-helm-charts/index.yaml .
cd ..
chmod -R g+r staging/
- name: rsync deployments
uses: burnett01/[email protected]
with:
switches: -rvzh
path: staging/
remote_path: /srv/sites/charts.onosproject.org
remote_host: static.opennetworking.org
remote_user: ${{ secrets.JENKINS_USERNAME }}
remote_key: ${{ secrets.JENKINS_SSHKEY }}
remote_key_pass: ${{ secrets.JENKINS_PASSPHRASE }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ staging/
requirements.lock
**/charts/*
build/build-tools
venv
39 changes: 16 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,20 @@
#
# SPDX-License-Identifier: Apache-2.0

.PHONY: all test clean
.PHONY: all test clean version-check

all: test
COMPARISON_BRANCH ?= master

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

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

test: # @HELP run the integration tests
test: version_check deps
(kubectl delete ns onos-topo || exit 0) && kubectl create ns onos-topo && helmit test -n onos-topo ./test -c . --suite onos-topo
(kubectl delete ns onos-config || exit 0) && kubectl create ns onos-config && helmit test -n onos-config ./test -c . --suite onos-config
(kubectl delete ns onos-umbrella || exit 0) && kubectl create ns onos-umbrella && helmit test -n onos-umbrella ./test -c . --suite onos-umbrella

version_check: # @HELP run the version checker on the charts
COMPARISON_BRANCH=master ./build/build-tools/chart_version_check
check-version: # @HELP run the version checker on the charts
COMPARISON_BRANCH=${COMPARISON_BRANCH} ./build/bin/version_check.sh all

jenkins_version_check: # @HELP run the version checker on the charts
export COMPARISON_BRANCH=origin/master && export WORKSPACE=`pwd` && ./build/build-tools/chart_version_check

jenkins-publish: # @HELP publish version on github
cd .. && GO111MODULE=on go install github.com/mikefarah/yq/[email protected]
./build/build-tools/release-chart-merge-commit https://charts.onosproject.org ${WEBSITE_USER} ${WEBSITE_PASSWORD}
test: # @HELP run the integration tests
test: deps license lint

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

license: # @HELP run license checks
rm -rf venv
python3 -m venv venv
. ./venv/bin/activate;\
python3 -m pip install --upgrade pip;\
python3 -m pip install reuse;\
reuse lint
16 changes: 16 additions & 0 deletions build/bin/helm_lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 Intel Corporation

exit_code=0

for dir in $(find . -maxdepth 1 -mindepth 1 -type d); do
if [[ -f "$dir/Chart.yaml" ]]; then
helm lint "$dir"
if [ $? == 1 ]
then
exit_code=2
fi
fi
done
exit $exit_code
61 changes: 0 additions & 61 deletions build/bin/release

This file was deleted.

Loading

0 comments on commit 856f0c3

Please sign in to comment.