Do not run tests a second time before deploying #9
Workflow file for this run
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
# Install Python dependencies, run tests, and lint with a single version of Python. | |
# See https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: HLS GIBS Notifications | |
on: | |
workflow_dispatch: | |
release: | |
types: | |
- published | |
push: | |
branches: | |
- main | |
- develop | |
tags-ignore: | |
- '*' | |
paths: | |
- '.github/workflows/*' | |
- 'cdk.json' | |
- 'hls_gibs/**' | |
- 'Makefile' | |
- 'setup.py' | |
- 'tox.ini' | |
pull_request: | |
types: | |
- edited | |
- opened | |
- reopened | |
- synchronize | |
branches: | |
- main | |
- develop | |
paths: | |
- '.github/workflows/*' | |
- 'cdk.json' | |
- 'hls_gibs/**' | |
- 'Makefile' | |
- 'setup.py' | |
- 'tox.ini' | |
# See https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services#updating-your-github-actions-workflow | |
permissions: | |
id-token: write # required for requesting the JWT | |
contents: read # required for actions/checkout | |
defaults: | |
run: | |
shell: bash | |
# When this workflow is queued, automatically cancel any previous running or pending | |
# jobs from the same branch. | |
concurrency: | |
group: integration-tests-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
config: | |
# This is a hack to work around the lack of support for two other possiblities for | |
# avoiding duplication of configuration values: | |
# | |
# (1) YAML anchors (https://yaml.org/spec/1.1/current.html#id899912) and aliases | |
# (https://yaml.org/spec/1.1/current.html#id902561) | |
# (2) Availability of `env` context within `jobs.<job-id>.with.<with-id>` (see | |
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability) | |
# | |
# Alternative hack: https://github.com/actions/runner/issues/1182#issuecomment-1262870831 | |
runs-on: ubuntu-22.04 | |
outputs: | |
PYTHON_VERSION: "3.12" | |
TOX_MIN_VERSION: "3.18.0" # `allowlist_externals` replaces `whitelist_externals` | |
steps: | |
- name: Configure shared values | |
run: "" # Nothing to do, but at least one step is required | |
unit-tests: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-22.04 | |
needs: config | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ needs.config.outputs.PYTHON_VERSION }}" | |
cache: 'pip' | |
cache-dependency-path: setup.py | |
- name: Install dependencies | |
run: | | |
pip install "tox>=${{ needs.config.outputs.TOX_MIN_VERSION }}" | |
- name: Run unit tests | |
run: | | |
make unit-tests | |
integration-tests: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-22.04 | |
environment: dev | |
needs: config | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ needs.config.outputs.PYTHON_VERSION }}" | |
cache: 'pip' | |
cache-dependency-path: setup.py | |
- name: Install dependencies | |
run: | | |
pip install "tox>=${{ needs.config.outputs.TOX_MIN_VERSION }}" | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ vars.AWS_DEFAULT_REGION }} | |
role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME_ARN }} | |
role-session-name: ${{ github.actor }} | |
- name: Convert secrets to environment variables | |
env: | |
SECRETS_JSON: ${{ toJson(secrets) }} | |
run: | | |
while read -rd $'' line; do | |
echo "$line" >> $GITHUB_ENV | |
done < <( | |
jq -r <<<"$SECRETS_JSON" 'to_entries|map("\(.key)=\(.value)\u0000")[]' | |
) | |
- name: Convert vars to environment variables | |
env: | |
VARS_JSON: ${{ toJson(vars) }} | |
run: | | |
while read -rd $'' line; do | |
echo "$line" >> $GITHUB_ENV | |
done < <( | |
jq -r <<<"$VARS_JSON" 'to_entries|map("\(.key)=\(.value)\u0000")[]' | |
) | |
- name: Deploy notification integration test stack | |
run: | | |
make deploy-it | |
- name: Run notification integration tests | |
run: | | |
make integration-tests | |
- name: Destroy notification integration test stack | |
if: always() | |
run: | | |
make destroy-it | |
deploy-dev: | |
# Deploy to Dev only on push (including merged PR) to `develop` branch | |
if: github.event_name == 'push' && github.event.ref == 'refs/heads/develop' | |
needs: | |
- config | |
uses: ./.github/workflows/deploy.yml | |
with: | |
environment: dev | |
PYTHON_VERSION: "${{ needs.config.outputs.PYTHON_VERSION }}" | |
TOX_MIN_VERSION: "${{ needs.config.outputs.TOX_MIN_VERSION }}" | |
secrets: inherit | |
deploy-prod: | |
# Deploy to Prod only on publishing a release (tag) on `main` branch | |
if: github.event_name == 'release' && github.event.action == 'published' | |
needs: | |
- config | |
uses: ./.github/workflows/deploy.yml | |
with: | |
environment: prod | |
PYTHON_VERSION: "${{ needs.config.outputs.PYTHON_VERSION }}" | |
TOX_MIN_VERSION: "${{ needs.config.outputs.TOX_MIN_VERSION }}" | |
secrets: inherit |