Cross-Version Tests and Upload #2938
This file contains hidden or 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
| name: Cross-Version Tests and Upload | |
| on: | |
| schedule: | |
| - cron: "0 0,19 * * *" # 12PM, 5PM Pacific; daily | |
| - cron: "0 15 * * *" # 8AM Pacific; daily (separate trigger for uploading release candidate) | |
| workflow_dispatch: | |
| inputs: | |
| batfish_repo: | |
| description: "GitHub repo containing Batfish" | |
| type: string | |
| required: false | |
| default: "batfish/batfish" | |
| batfish_ref: | |
| description: "Batfish ref to build a container from" | |
| type: string | |
| required: false | |
| default: "master" | |
| pybatfish_repo: | |
| description: "GitHub repo containing Pybatfish" | |
| type: string | |
| required: false | |
| default: "batfish/pybatfish" | |
| pybatfish_ref: | |
| description: "Pybatfish ref to build a wheel from" | |
| type: string | |
| required: false | |
| default: "master" | |
| jobs: | |
| # Initial checks and build artifacts | |
| precommit: | |
| uses: ./.github/workflows/reusable-precommit.yml | |
| with: | |
| BATFISH_GITHUB_BATFISH_REPO: "${{ github.event.inputs.batfish_repo || 'batfish/batfish' }}" | |
| BATFISH_GITHUB_BATFISH_REF: "${{ github.event.inputs.batfish_ref || 'master' }}" | |
| BATFISH_GITHUB_PYBATFISH_REPO: "${{ github.event.inputs.pybatfish_repo || 'batfish/pybatfish' }}" | |
| BATFISH_GITHUB_PYBATFISH_REF: "${{ github.event.inputs.pybatfish_ref || 'master' }}" | |
| # Integration tests | |
| test: | |
| needs: precommit | |
| uses: ./.github/workflows/reusable-integration-tests.yml | |
| with: | |
| bf_version: ${{ needs.precommit.outputs.bf_version }} | |
| bf_test_artifact_age: "90" | |
| bf_min_release_test_count: "2" | |
| pybf_min_release_test_count: "2" # todo: bump to 3 once we have 3 releases with new API support | |
| run_cross_version_tests: true | |
| # Push test/dev artifacts | |
| upload_dev: | |
| needs: | |
| - precommit | |
| - test | |
| uses: ./.github/workflows/reusable-upload.yml | |
| with: | |
| bf_version: ${{ needs.precommit.outputs.bf_version }} | |
| # Only upload dev/test artifacts, not production | |
| queue_prod_release: false | |
| test_tag: "test-${{ needs.precommit.outputs.bf_version }}" | |
| release_tag: "${{ needs.precommit.outputs.bf_version }}" | |
| BATFISH_GITHUB_BATFISH_REPO: "${{ needs.precommit.outputs.batfish_repo }}" | |
| BATFISH_GITHUB_PYBATFISH_REPO: "${{ needs.precommit.outputs.pybatfish_repo }}" | |
| BATFISH_GITHUB_PYBATFISH_REF: "${{ needs.precommit.outputs.pybatfish_resolved_sha }}" | |
| secrets: | |
| PYBATFISH_TEST_PYPI_TOKEN: ${{ secrets.PYBATFISH_TEST_PYPI_TOKEN }} | |
| PYBATFISH_PYPI_TOKEN: ${{ secrets.PYBATFISH_PYPI_TOKEN }} | |
| BATFISH_DOCKER_LOGIN_TOKEN: ${{ secrets.BATFISH_DOCKER_LOGIN_TOKEN }} | |
| OPEN_SOURCE_BUILDKITEBOT_PUBLIC_REPO_TOKEN: ${{ secrets.OPEN_SOURCE_BUILDKITEBOT_PUBLIC_REPO_TOKEN }} | |
| # Validate the uploaded test artifacts with lab-validation | |
| lab_validation: | |
| needs: | |
| - precommit | |
| - upload_dev | |
| uses: batfish/lab-validation/.github/workflows/reusable-lab-validation.yml@main | |
| with: | |
| batfish_docker: "batfish/batfish:test-${{ needs.precommit.outputs.bf_version }}" | |
| pybatfish_version: "${{ needs.precommit.outputs.bf_version }}" | |
| pybatfish_pypi_repo: "test" | |
| # Push production artifacts only if lab validation passes | |
| upload_prod: | |
| needs: | |
| - precommit | |
| - test | |
| - lab_validation | |
| # Only run production uploads if this is a release candidate AND lab validation passed | |
| if: github.event_name == 'workflow_dispatch' || github.event.schedule == '0 15 * * *' | |
| uses: ./.github/workflows/reusable-upload.yml | |
| with: | |
| bf_version: ${{ needs.precommit.outputs.bf_version }} | |
| # Only upload production artifacts | |
| queue_prod_release: true | |
| test_tag: "test-${{ needs.precommit.outputs.bf_version }}" | |
| release_tag: "${{ needs.precommit.outputs.bf_version }}" | |
| BATFISH_GITHUB_BATFISH_REPO: "${{ needs.precommit.outputs.batfish_repo }}" | |
| BATFISH_GITHUB_PYBATFISH_REPO: "${{ needs.precommit.outputs.pybatfish_repo }}" | |
| BATFISH_GITHUB_PYBATFISH_REF: "${{ needs.precommit.outputs.pybatfish_resolved_sha }}" | |
| secrets: | |
| PYBATFISH_TEST_PYPI_TOKEN: ${{ secrets.PYBATFISH_TEST_PYPI_TOKEN }} | |
| PYBATFISH_PYPI_TOKEN: ${{ secrets.PYBATFISH_PYPI_TOKEN }} | |
| BATFISH_DOCKER_LOGIN_TOKEN: ${{ secrets.BATFISH_DOCKER_LOGIN_TOKEN }} | |
| OPEN_SOURCE_BUILDKITEBOT_PUBLIC_REPO_TOKEN: ${{ secrets.OPEN_SOURCE_BUILDKITEBOT_PUBLIC_REPO_TOKEN }} | |
| # Send Slack notification on failure for scheduled or post-merge jobs on master branch | |
| notify_slack_on_failure: | |
| needs: | |
| - precommit | |
| - test | |
| - upload_dev | |
| - lab_validation | |
| - upload_prod | |
| if: | | |
| failure() && | |
| github.ref == 'refs/heads/master' && | |
| (github.event_name == 'schedule' || github.event_name == 'push') && | |
| !(github.event_name == 'workflow_dispatch' || github.event.schedule == '0 15 * * *') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send Slack notification | |
| uses: slackapi/slack-github-action@v2.1.1 | |
| with: | |
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| webhook-type: incoming-webhook | |
| payload: | | |
| { | |
| "text": "*Docker cross-version tests and upload workflow failed*", | |
| "blocks": [ | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "*Docker cross-version tests and upload workflow failed*" | |
| } | |
| }, | |
| { | |
| "type": "section", | |
| "fields": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Workflow:*\n${{ github.workflow }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Status:*\nFailed" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Trigger:*\n${{ github.event_name }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Branch:*\nmaster" | |
| } | |
| ] | |
| }, | |
| { | |
| "type": "actions", | |
| "elements": [ | |
| { | |
| "type": "button", | |
| "text": { | |
| "type": "plain_text", | |
| "text": "View in GitHub Actions" | |
| }, | |
| "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| } | |
| ] | |
| } | |
| ] | |
| } |