-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add workflows for property-based testing (#11)
- Loading branch information
Showing
17 changed files
with
859 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Run property-based tests | ||
|
||
on: | ||
pull_request: | ||
merge_group: | ||
types: [checks_requested] | ||
schedule: | ||
# Run every midnight UTC | ||
- cron: "0 0 * * *" | ||
workflow_dispatch: # manually triggered | ||
|
||
jobs: | ||
generate-matrix: | ||
name: Generate Matrix | ||
runs-on: ubuntu-latest | ||
outputs: | ||
networks: ${{ steps.generate-matrix.outputs.networks }} | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Generate network matrix | ||
id: generate-matrix | ||
run: | | ||
NETWORKS=$(ls k8s/networks | jq -R -s -c '. | gsub(".yaml"; "") | split("\n")[:-1]') | ||
echo ${NETWORKS} | ||
echo ::set-output name=networks::${NETWORKS} | ||
run-tests: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
needs: generate-matrix | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
networks: ${{ fromJSON(needs.generate-matrix.outputs.networks) }} | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Setup GKE auth | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
credentials_json: ${{ secrets.GKE_SA_KEY }} | ||
- | ||
name: Get GKE credentials | ||
uses: 'google-github-actions/get-gke-credentials@v1' | ||
with: | ||
cluster_name: ${{ secrets.GKE_CLUSTER }} | ||
location: ${{ secrets.GKE_ZONE }} | ||
- | ||
# Add a "_sha_runId" suffix to differentiate PR test runs | ||
name: Setup test env | ||
if: ${{ github.event_name == 'pull_request' }} | ||
run: | | ||
TEST_SUFFIX="-$(echo ${{ github.sha }} | head -c 8)-${{ github.run_id }}" | ||
echo "TEST_SUFFIX=$TEST_SUFFIX" >> $GITHUB_ENV | ||
- | ||
name: Test ${{ matrix.networks }} | ||
working-directory: k8s/tests/scripts | ||
run: ./run-tests.sh ${{ matrix.networks }} | ||
- | ||
# Always cleanup resources at the end of PR test runs, whether the tests pass or fail. | ||
name: Delete ${{ matrix.networks }} | ||
if: always() | ||
working-directory: k8s/tests/scripts | ||
run: | | ||
if [[ ${{ github.event_name }} == "pull_request" ]]; then | ||
./delete-tests.sh ${{ matrix.networks }} | ||
fi | ||
collect-results: | ||
name: Results | ||
if: ${{ always() }} | ||
runs-on: ubuntu-latest | ||
needs: [run-tests] | ||
steps: | ||
- run: exit 1 | ||
# see https://stackoverflow.com/a/67532120/4907315 | ||
if: >- | ||
${{ | ||
contains(needs.*.result, 'failure') | ||
|| contains(needs.*.result, 'cancelled') | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Run smoke tests | ||
|
||
on: | ||
schedule: | ||
# Run every midnight UTC | ||
- cron: "0 0 * * *" | ||
workflow_dispatch: # manually triggered | ||
|
||
jobs: | ||
generate-matrix: | ||
name: Generate Matrix | ||
runs-on: ubuntu-latest | ||
outputs: | ||
networks: ${{ steps.generate-matrix.outputs.networks }} | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Generate network matrix | ||
id: generate-matrix | ||
run: | | ||
NETWORKS=$(ls k8s/networks | jq -R -s -c '. | gsub(".yaml"; "") | split("\n")[:-1]') | ||
echo ${NETWORKS} | ||
echo ::set-output name=networks::${NETWORKS} | ||
run-tests: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
needs: generate-matrix | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
networks: ${{ fromJSON(needs.generate-matrix.outputs.networks) }} | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Setup GKE auth | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
credentials_json: ${{ secrets.GKE_SA_KEY }} | ||
- | ||
name: Get GKE credentials | ||
uses: 'google-github-actions/get-gke-credentials@v1' | ||
with: | ||
cluster_name: ${{ secrets.GKE_CLUSTER }} | ||
location: ${{ secrets.GKE_ZONE }} | ||
- | ||
# Don't clean up networks afterward so that these tests can run longer term | ||
name: Test ${{ matrix.networks }} | ||
working-directory: k8s/tests/scripts | ||
run: ./run-tests.sh ${{ matrix.networks }} smoke | ||
|
||
collect-results: | ||
name: Results | ||
if: ${{ always() }} | ||
runs-on: ubuntu-latest | ||
needs: [run-tests] | ||
steps: | ||
- run: exit 1 | ||
# see https://stackoverflow.com/a/67532120/4907315 | ||
if: >- | ||
${{ | ||
contains(needs.*.result, 'failure') | ||
|| contains(needs.*.result, 'cancelled') | ||
}} |
Oops, something went wrong.