Skip to content

Commit

Permalink
Testing things
Browse files Browse the repository at this point in the history
  • Loading branch information
pgoslatara committed Sep 9, 2024
1 parent 73238ff commit 86aeef1
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 59 deletions.
39 changes: 33 additions & 6 deletions .github/workflows/ci_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: CI pipeline

on:
pull_request_target:
pull_request:
branches:
- main

Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
cat changed_files.txt | xargs poetry run pre-commit run --files
unit-tests:
needs: [pre-commit]
# needs: [pre-commit]
runs-on: ${{ matrix.operating-system }}
permissions:
contents: write
Expand Down Expand Up @@ -83,16 +83,24 @@ jobs:
poetry-version: ${{ env.POETRY_VERSION }}
python-version: ${{ matrix.python-version }}

- name: Run pytest (unit tests)
- run: |
$env:Path += ';C:\Users\runneradmin\.local\bin'
poetry --version
if: matrix.operating-system == 'windows-latest'
# - run: poetry --version


- name: Run pytest
if: matrix.operating-system == 'windows-latest'
run: make test-unit
run: make test-windows

- name: Run pytest (unit tests)
if: matrix.operating-system != 'windows-latest'
run: make test-unit | tee pytest-coverage.txt && exit ${PIPESTATUS[0]}

- name: Pytest coverage comment
if: matrix.python-version == '3.11' && matrix.operating-system == 'ubuntu-latest'
if: matrix.python-version == '3.11' && matrix.operating-system != 'windows-latest'
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
Expand All @@ -101,16 +109,35 @@ jobs:
junitxml-path: ./coverage.xml

- name: Run pytest (integration tests)
if: matrix.operating-system != 'windows-latest'
run: make test-integration

- name: Regenerate dbt artifacts
run: |
if [[ ${{ matrix.operating-system }} == "windows-latest" ]]; then
$env:Path += ';C:\Users\runneradmin\.local\bin'
fi
poetry run dbt deps
poetry run dbt build
poetry run dbt docs generate
- name: Run `dbt-bouncer` on generated artifacts
run: poetry run dbt-bouncer --config-file ./dbt-bouncer-example.yml
run: |
if [[ ${{ matrix.operating-system }} == "windows-latest" ]]; then
$env:Path += ';C:\Users\runneradmin\.local\bin'
fi
poetry run dbt-bouncer --config-file ./dbt-bouncer-example.yml
- name: Determine python version
id: python-version
run: |
if [[ ${{ matrix.operating-system }} == "windows-latest" ]]; then
echo "PYTHON_VERSION=$(cat .python-version)" >> $ENV:GITHUB_OUTPUT
else
export PYTHON_VERSION=$(cat .python-version)
echo "PYTHON_VERSION: $PYTHON_VERSION"
echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_OUTPUT
fi
e2e-tests:
needs: [pre-commit]
Expand Down
111 changes: 58 additions & 53 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
build-artifacts:
poetry run python ./scripts/generate_artifacts.py

build-pex:
poetry run pex . \
--interpreter-constraint ">=3.8.1,<3.13" \
--jobs 128 \
--max-install-jobs 0 \
--output-file ./dist/dbt-bouncer.pex \
--pip-version 23.2 \
--platform macosx_11_0_x86_64-cp-38-cp38 \
--platform macosx_11_0_x86_64-cp-39-cp39 \
--platform macosx_11_0_x86_64-cp-310-cp310 \
--platform macosx_11_0_x86_64-cp-311-cp311 \
--platform macosx_11_0_x86_64-cp-312-cp312 \
--platform manylinux2014_x86_64-cp-38-cp38 \
--platform manylinux2014_x86_64-cp-39-cp39 \
--platform manylinux2014_x86_64-cp-310-cp310 \
--platform manylinux2014_x86_64-cp-311-cp311 \
--platform manylinux2014_x86_64-cp-312-cp312 \
--python-shebang='/usr/bin/env python' \
--script dbt-bouncer

test:
$(MAKE) test-unit
$(MAKE) test-integration

test-integration:
poetry run pytest \
-c ./tests \
--junitxml=coverage.xml \
--cov-report=term-missing:skip-covered \
--cov=src/dbt_bouncer/ \
--numprocesses 5 \
./tests/integration \
$(MAKE_ARGS)

test-unit:
poetry run pytest \
-c ./tests \
--junitxml=coverage.xml \
--cov-report=term-missing:skip-covered \
--cov=src/dbt_bouncer/ \
--numprocesses 5 \
./tests/unit \
-m 'not not_in_parallel' && \
poetry run pytest \
-c ./tests \
--junitxml=coverage.xml \
--cov-report=term-missing:skip-covered \
--cov=src/dbt_bouncer/ \
--cov-append \
-m not_in_parallel
build-artifacts:
poetry run python ./scripts/generate_artifacts.py

build-pex:
poetry run pex . \
--interpreter-constraint ">=3.8.1,<3.13" \
--jobs 128 \
--max-install-jobs 0 \
--output-file ./dist/dbt-bouncer.pex \
--pip-version 23.2 \
--platform macosx_11_0_x86_64-cp-38-cp38 \
--platform macosx_11_0_x86_64-cp-39-cp39 \
--platform macosx_11_0_x86_64-cp-310-cp310 \
--platform macosx_11_0_x86_64-cp-311-cp311 \
--platform macosx_11_0_x86_64-cp-312-cp312 \
--platform manylinux2014_x86_64-cp-38-cp38 \
--platform manylinux2014_x86_64-cp-39-cp39 \
--platform manylinux2014_x86_64-cp-310-cp310 \
--platform manylinux2014_x86_64-cp-311-cp311 \
--platform manylinux2014_x86_64-cp-312-cp312 \
--python-shebang='/usr/bin/env python' \
--script dbt-bouncer

test:
$(MAKE) test-unit
$(MAKE) test-integration

test-integration:
poetry run pytest \
-c ./tests \
--junitxml=coverage.xml \
--cov-report=term-missing:skip-covered \
--cov=src/dbt_bouncer/ \
--numprocesses 5 \
./tests/integration \
$(MAKE_ARGS)

test-unit:
poetry run pytest \
-c ./tests \
--junitxml=coverage.xml \
--cov-report=term-missing:skip-covered \
--cov=src/dbt_bouncer/ \
--numprocesses 5 \
./tests/unit \
-m 'not not_in_parallel' && \
poetry run pytest \
-c ./tests \
--junitxml=coverage.xml \
--cov-report=term-missing:skip-covered \
--cov=src/dbt_bouncer/ \
--cov-append \
-m not_in_parallel

test-windows:
poetry run pytest -c ./tests --numprocesses 5 ./tests/unit -m 'not not_in_parallel' && \
poetry run pytest -c ./tests -m not_in_parallel && \
poetry run pytest -c ./tests --numprocesses 5 ./tests/integration

0 comments on commit 86aeef1

Please sign in to comment.