Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate git actions into commit-check script #10

Merged
merged 35 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1faaa89
cosolidated git actions
ebeaty-cisco May 10, 2024
7757744
moved version increment check to commit-check
ebeaty-cisco May 10, 2024
f626cf6
moved version increment check to commit-check
ebeaty-cisco May 10, 2024
89d239a
moved version increment check to commit-check
ebeaty-cisco May 10, 2024
530f4b5
moved version increment check to commit-check
ebeaty-cisco May 10, 2024
112e0ac
helm linting
ebeaty-cisco May 10, 2024
c8e4727
helm UT
ebeaty-cisco May 10, 2024
a3b3ef1
shell check
ebeaty-cisco May 10, 2024
0904a01
test UT
ebeaty-cisco May 10, 2024
b70e14a
test UT
ebeaty-cisco May 10, 2024
131d047
test UT
ebeaty-cisco May 10, 2024
16d88ae
test UT
ebeaty-cisco May 10, 2024
ca5210d
test UT
ebeaty-cisco May 10, 2024
45e57d9
test UT
ebeaty-cisco May 10, 2024
1a46042
test UT
ebeaty-cisco May 10, 2024
aa6a229
test UT
ebeaty-cisco May 10, 2024
242b996
tidying up
ebeaty-cisco May 10, 2024
596eb3a
venv for python
ebeaty-cisco May 10, 2024
0124520
venv for python
ebeaty-cisco May 10, 2024
dd1ee2c
fix shellcheck
ebeaty-cisco May 10, 2024
4d76a86
fix shellcheck
ebeaty-cisco May 10, 2024
32efd5d
.
ebeaty-cisco May 13, 2024
e989625
script done
ebeaty-cisco May 14, 2024
ebce6d1
rm unused config
ebeaty-cisco May 14, 2024
d3e8f03
testing
ebeaty-cisco May 14, 2024
7ce3ae9
test
ebeaty-cisco May 14, 2024
300bf09
testing
ebeaty-cisco May 14, 2024
100a29b
testing
ebeaty-cisco May 14, 2024
d6d6809
test
ebeaty-cisco May 14, 2024
826c0b1
test reverted
ebeaty-cisco May 14, 2024
1116446
rm docker option
ebeaty-cisco May 16, 2024
d002d4f
markups
ebeaty-cisco May 16, 2024
3c4920e
markups done
ebeaty-cisco May 16, 2024
6df15e7
markups done
ebeaty-cisco May 16, 2024
917966f
re-add .github/workflows/release.yml
ebeaty-cisco May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/config/ct.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/config/yamllint.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/commit-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: commit-checks

on:
pull_request:
branches:
- 'main'
- 'preview-[0-9]+\.[0-9]+\.[0-9]+'
paths-ignore:
- '.gitignore'
- '*.md'
push:
branches:
- 'main'
- 'gh-actions*'

jobs:
all_tests:
runs-on: ubuntu-latest
name: 'commit-checks'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Run all tests
run: scripts/commit-check
36 changes: 0 additions & 36 deletions .github/workflows/release.yml

This file was deleted.

63 changes: 0 additions & 63 deletions .github/workflows/sa.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/tests.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/version-increment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: version-increment

on:
pull_request:
branches:
- 'main'
paths-ignore:
- '.gitignore'
- '*.md'
push:
branches:
- 'gh-actions*'

jobs:
helm:
runs-on: ubuntu-latest
name: 'version-increment-check'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: helm/chart-testing-action@v2.3.1

- name: Run chart-testing (check-version-increment)
run: ct lint --config .github/config/ct-version-increment.yml --target-branch ${{ github.event.repository.default_branch }}
tjohnes marked this conversation as resolved.
Show resolved Hide resolved
71 changes: 64 additions & 7 deletions scripts/commit-check
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
#!/usr/bin/env bash
# commit-check - Pre-commit checks

set -e -o pipefail
# This script runs all commit checks EXCEPT for checking that the version is
# correctly incermented, which is done via a seperate github action.

set -e

function cleanup()
{
echo
echo "Cleaning up..."
if [[ -d $TMP_VENV ]]; then
rm -r "$TMP_VENV"
fi
}

trap cleanup EXIT

#=====================================================
# Run checks
#=====================================================

FAILURES=0

echo "Setting up python venv..."
TMP_VENV=$(mktemp -d -t venv.XXXXXX)
python3 -m venv "$TMP_VENV"
"$TMP_VENV"/bin/pip install --upgrade pip
"$TMP_VENV"/bin/pip install PyYAML

echo
echo "Running version-increment dependency check"
if ! ./scripts/check-dependency-version-increment; then
echo "Version-increment dependency check failed, check output and fix issues." >&2
FAILURES=$((FAILURES+1))
else
echo "Version-increment dependency check passed."
fi

echo
echo "Running helm lint..."
args=("--set" "image.repository=repository" "--set" "image.tag=latest")
error=false
for chart in charts/*; do
for chart in charts/{xrd-vrouter,xrd-control-plane}; do
pushd "$chart"
if ! (helm dependency update && helm lint "${args[@]}"); then
error=true
Expand All @@ -19,17 +50,43 @@ for chart in charts/*; do
done
if [ $error = true ]; then
FAILURES=$((FAILURES+1))
echo "helm lint failed, check output and fix errors" >&2
echo "Helm lint failed, check output and fix errors" >&2
else
echo "Helm lint passed."
fi


echo
echo "Running shellcheck..."
if ! shellcheck scripts/{chart-releaser,commit-check}; then
echo "shellcheck failed, check output and fix issues." >&2
echo "Shellcheck failed, check output and fix issues." >&2
FAILURES=$((FAILURES+1))
else
echo "Shellcheck passed."
fi

podman build tests/ -t helm-tests --network host

echo
echo "Running Control Plane unit tests..."
if ! podman run -v "$PWD/:/charts" helm-tests bats tests/ut/xrd-control-plane; then
echo "Control Plane unit tests failed, check output and fix issues." >&2
FAILURES=$((FAILURES+1))
else
echo "Control Plane unit tests passed."
fi

echo
echo "Running vRouter unit tests..."
if ! podman run -v "$PWD/:/charts" helm-tests bats tests/ut/xrd-vrouter; then
echo "vRouter unit tests failed, check output and fix issues." >&2
FAILURES=$((FAILURES+1))
else
echo "vRouter unit tests passed."
fi

#=====================================================
# Final steps
#=====================================================

echo
if ((FAILURES > 0)); then
Expand All @@ -38,4 +95,4 @@ if ((FAILURES > 0)); then
else
echo "SUCCESS: All passed!"
exit 0
fi
fi
Loading