Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Refactor CI checks to run as a single job #92

Merged
merged 3 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
85 changes: 28 additions & 57 deletions .github/workflows/safe_pr_checks.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,40 @@
name: CI Checks - Safe
on: [
pull_request
]
on:
push:
branches:
- main
pull_request:

jobs:
Autoformat:
Check-All:
runs-on: ubuntu-latest
steps:
- run: echo "Running CI for branch ${{ github.ref }}."
- name: Check out repository code
- name: Checkout
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: make black-ci

Check-Migrations:
runs-on: ubuntu-latest
steps:
- run: echo "Running CI for branch ${{ github.ref }}."
- name: Check out repository code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: make init-db
- run: make check-migrations
- name: Docker Compose Build
run: make compose-build

Lint:
runs-on: ubuntu-latest
steps:
- run: echo "Running CI for branch ${{ github.ref }}."
- name: Check out repository code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: make pylint
- name: Format
run: make black-ci

Check-Types:
runs-on: ubuntu-latest
steps:
- run: echo "Running CI for branch ${{ github.ref }}."
- name: Check out repository code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: make mypy
- name: Lint
run: make pylint

Unit-Tests:
runs-on: ubuntu-latest
steps:
- run: echo "Running CI for branch ${{ github.ref }}."
- name: Check out repository code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: make pytest
- name: Check Types
run: make mypy

Integration-Tests-Access:
runs-on: ubuntu-latest
steps:
- run: echo "Running CI for branch ${{ github.ref }}."
- name: Check out repository code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: make pytest-integration-access
- name: Init DB
run: make init-db

Integration-Tests-Erasure:
runs-on: ubuntu-latest
steps:
- run: echo "Running CI for branch ${{ github.ref }}."
- name: Check out repository code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: make pytest-integration-erasure
- name: Check Migrations
run: make check-migrations

- name: Unit Tests
run: make pytest

- name: Integration Tests (Access)
run: make pytest-integration-access

- name: Integration Tests (Erasure)
run: make pytest-integration-erasure
11 changes: 6 additions & 5 deletions .github/workflows/unsafe_pr_checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI Checks - Unsafe
on:
push:
branches:
- main
pull_request:
types: [labeled]

Expand All @@ -9,12 +11,11 @@ jobs:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'run unsafe ci checks')
steps:
- run: echo "Running CI for branch ${{ github.ref }}."
- name: Check out repository code
- name: Checkout
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: Run unit tests that connect to an external db

- name: Integration Tests (External)
env:
REDSHIFT_TEST_URI: ${{ secrets.REDSHIFT_TEST_URI }}
SNOWFLAKE_TEST_URI: ${{ secrets.SNOWFLAKE_TEST_URI }}
run: make pytest-external-integration
run: make pytest-integration-external
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ docker-push:
# CI
####################

check-all: black-ci pylint mypy pytest pytest-integration check-migrations
check-all: black-ci pylint mypy check-migrations pytest pytest-integration-access pytest-integration-erasure

black-ci: compose-build
@echo "Running black checks..."
Expand Down Expand Up @@ -99,7 +99,7 @@ mypy: compose-build
pytest: compose-build
@echo "Running pytest unit tests..."
@docker-compose run $(IMAGE_NAME) \
pytest $(pytestpath) -m "not integration and not integration_erasure and not external_integration"
pytest $(pytestpath) -m "not integration and not integration_erasure and not integration_external"

# Run the pytest integration tests.
pytest-integration-access: compose-build
Expand All @@ -124,10 +124,10 @@ pytest-integration-erasure: compose-build
pytest $(pytestpath) -m "integration_erasure"

# These tests connect to external third-party test databases
pytest-external-integration: compose-build
pytest-integration-external: compose-build
@echo "Running tests that connect to external third party test databases"
@docker-compose run -e REDSHIFT_TEST_URI -e SNOWFLAKE_TEST_URI $(IMAGE_NAME) \
pytest $(pytestpath) -m "external_integration"
pytest $(pytestpath) -m "integration_external"


####################
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/test_external_database_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def snowflake_test_engine() -> Generator:
engine.dispose()


@pytest.mark.external_integration
@pytest.mark.integration_external
def test_redshift_example_data(redshift_test_engine):
"""Confirm that we can connect to the redshift test db and get table names"""
inspector = inspect(redshift_test_engine)
Expand All @@ -78,7 +78,7 @@ def test_redshift_example_data(redshift_test_engine):
]


@pytest.mark.external_integration
@pytest.mark.integration_external
def test_snowflake_example_data(snowflake_test_engine):
"""Confirm that we can connect to the snowflake test db and get table names"""
inspector = inspect(snowflake_test_engine)
Expand Down