Skip to content

Commit

Permalink
feat: add workflows for property-based testing (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 authored Sep 8, 2023
1 parent 6b6b701 commit 82f8482
Show file tree
Hide file tree
Showing 17 changed files with 859 additions and 179 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/prop.yml
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')
}}
68 changes: 68 additions & 0 deletions .github/workflows/smoke.yml
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')
}}
Loading

0 comments on commit 82f8482

Please sign in to comment.