mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
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:
25
.github/workflows/integration-tests.yml
vendored
25
.github/workflows/integration-tests.yml
vendored
@@ -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
14
tests/parse_tests.awk
Normal 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 "]"
|
||||
}
|
||||
Reference in New Issue
Block a user