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

feat: make ginkgo tests as matrix #979

Merged
merged 12 commits into from
Feb 25, 2024
Next Next commit
feat: make ginkgo tests as matrix
brokenpip3 committed Feb 25, 2024
commit da49032bf8243c566845dbc0728e845a274c040a
25 changes: 21 additions & 4 deletions .github/workflows/auto-tests-helm.yaml
Original file line number Diff line number Diff line change
@@ -20,10 +20,25 @@ on:
- '*.md'

jobs:
run-tests:
if: github.event.pull_request.draft == false
name: Run automated tests
create-tests-list:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: matrix
run: |
script=$(./test/make_matrix_ginkgo.sh)
echo "matrix=${script}" >> $GITHUB_OUTPUT

run-helm-tests:
runs-on: ubuntu-latest
needs: [create-tests-list]
if: github.event.pull_request.draft == false
name: Run automated helm tests
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.create-tests-list.outputs.matrix) }}
steps:
- name: Check out code
uses: actions/checkout@v4
@@ -61,7 +76,9 @@ jobs:
sudo chown -R $USER $HOME/.kube

- name: Jenkins Operator - Helm Chart tests
env:
TEST: ${{ matrix.test }}
run: |
git reset --hard
make helm-lint
make helm-e2e E2E_TEST_ARGS='-ginkgo.v'
make helm-e2e E2E_TEST_ARGS='-ginkgo.v -ginkgo.focus="${PKG}"'
5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -33,6 +33,11 @@
pkgs.gnumake
pkgs.wget
pkgs.helm-docs
(pkgs.writeShellApplication {
name = "make_matrix";
runtimeInputs = with pkgs; [ bash gnugrep gawk ];
text = builtins.readFile ./test/make_matrix_ginkgo.sh;
})
go_15_pkgs.go
golangci_pkgs.golangci-lint
];
35 changes: 35 additions & 0 deletions test/make_matrix_ginkgo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

TESTDIR="${TESTDIR:-test}"

json_output(){
# Make shellcheck happy,
# declare local before assign
local lastl
local line
local grep_info
local f
local l
local t

lastl=$(echo "${1}" | wc -l)
line=0
printf '{\"include\":['
while read -r test; do
line=$((line + 1))
grep_info=$(echo "${test}"|awk -F '"' '{print $1}')
f=$(echo "${grep_info}"|cut -d ':' -f 1)
l=$(echo "${grep_info}"|cut -d ':' -f 2)
t=$(echo "${test}"|awk -F '"' '{print $2}')
printf '{\"file\":\"%s\",\"line\":\"%s\",\"test\":\"%s\"}' "$f" "$l" "$t"
[[ $line -ne $lastl ]] && printf ","
done <<< "${1}"
printf "]}"
}

parse(){
grep -nrE 'It\([^)]+\)' "$1"
}

tests_list=$(parse "${TESTDIR}"/"${1}")
json_output "${tests_list}"