Generate test matrix dynamically from bats (#1303)

Extract the tests to be run and generate the matrix dynamically to avoid
needing to update the list within the workflow for each test added.
This commit is contained in:
Darragh Bailey
2021-06-01 17:21:15 +01:00
committed by GitHub
parent 0c35a1e275
commit dbbfad2503
2 changed files with 29 additions and 10 deletions

View File

@@ -7,21 +7,26 @@ on:
pull_request:
jobs:
test:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- name: Generate matrix
id: generate-matrix
run: |
tests="$(awk -f tests/parse_tests.awk < tests/runtests.bats)"
echo "::set-output name=matrix::${tests}"
run-tests:
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_name:
- destroy simple vm
- simple vm provision via shell
- bring up with custom default prefix
- bring up with second disk
- bring up with two disks
- bring up with adjusted memory settings
- bring up with adjusted cpu settings
- ip is reachable with private network
test_name: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
env:
NOKOGIRI_USE_SYSTEM_LIBRARIES: true

14
tests/parse_tests.awk Normal file
View File

@@ -0,0 +1,14 @@
BEGIN {
printf "["
previous=""
}
match($0, /@test "(.*)" \{/, arr) {
if ( previous != "" ) {
printf "%s, ",previous
}
previous = sprintf("\"%s\"", arr[1])
}
END {
printf "%s",previous
print "]"
}