From b2e195b304de536dd4a68cff47380baeca54e4ca Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 22 Jan 2022 13:40:38 +0100 Subject: [PATCH] chore(cicd): Automate release creation on tag push These CI/CD improvements also bring test coverage tracking, and better naming for test steps. --- .github/workflows/pypi_deploy.yaml | 16 +++++++----- .github/workflows/tagged_release.yml | 38 ++++++++++++++++++++++++++++ .github/workflows/test.yaml | 32 +++++++++++++++-------- README.md | 1 + 4 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/tagged_release.yml diff --git a/.github/workflows/pypi_deploy.yaml b/.github/workflows/pypi_deploy.yaml index 168c8eb..acff3da 100644 --- a/.github/workflows/pypi_deploy.yaml +++ b/.github/workflows/pypi_deploy.yaml @@ -1,20 +1,22 @@ name: PyPI deploy on: - push: - tags: '*' + release: + types: [created] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 with: python-version: 3.9 - - uses: abatilo/actions-poetry@v2.1.3 - - name: install + - name: Install Poetry + uses: abatilo/actions-poetry@v2.1.3 + - name: Install redtape with Poetry run: poetry install - - name: build + - name: Build redtape with Poetry run: poetry build - - name: publish + - name: Publish redtape to Pypi with Poetry run: poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/tagged_release.yml b/.github/workflows/tagged_release.yml new file mode 100644 index 0000000..ee3db98 --- /dev/null +++ b/.github/workflows/tagged_release.yml @@ -0,0 +1,38 @@ +name: Tagged release + +on: + push: + tags: + - "v*" + +jobs: + gh_tagged_release: + runs-on: ubuntu-latest + steps: + - name: Wait for Tests to succeed + uses: fountainhead/action-wait-for-check@v1.0.0 + id: wait-for-test + with: + token: ${{ secrets.PA_TOKEN }} + checkName: test + ref: ${{ github.sha }} + - uses: actions/checkout@v2.3.4 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: '3.9' + - name: Install Poetry + uses: abatilo/actions-poetry@v2.1.4 + with: + poetry-version: 1.1.12 + - name: Install redtape with Poetry + run: poetry install + - name: Build redtape with Poetry + run: poetry build + - name: Release new SemVer tag + uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: "${{ secrets.PA_TOKEN }}" + prerelease: false + files: | + dist/* diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 941a712..e76f3f9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,7 +1,9 @@ -name: Tests +name: Test on: push: branches: [ master ] + tags: + - "v*" pull_request: branches: - master @@ -15,21 +17,31 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: abatilo/actions-poetry@v2.1.4 + - name: Install Poetry + uses: abatilo/actions-poetry@v2.1.4 with: poetry-version: 1.1.12 - - name: install + - name: Install airflow-dbt-python with Poetry run: poetry install -E amazon -E postgres - - name: flake8 + - name: Style guide enforcement with flake8 run: poetry run flake8 . - - name: mypy + - name: Static type checking with mypy run: poetry run mypy . - - name: black + - name: Code formatting with black run: poetry run black --check . - - name: init airflow db + - name: Initialize Airflow db for testing run: poetry run airflow db init - - name: test - run: poetry run pytest -v tests/ + - name: Run tests with pytest + run: poetry run pytest -v --cov=./airflow_dbt_python --cov-report=xml:./coverage.xml --cov-report term-missing tests/ + - name: Upload code coverage + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml + name: redtape + flags: unittests + env_vars: OS,PYTHON diff --git a/README.md b/README.md index 2c5b7d9..c74d83a 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![PyPI version](https://img.shields.io/pypi/v/airflow-dbt-python?style=plastic)](https://pypi.org/project/airflow-dbt-python/) [![GitHub build status](https://github.com/tomasfarias/airflow-dbt-python/actions/workflows/test.yaml/badge.svg)](https://github.com/tomasfarias/airflow-dbt-python/actions) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![Test coverage](https://codecov.io/gh/tomasfarias/airflow-dbt-python/branch/master/graph/badge.svg?token=HBKZ78F11F)](https://codecov.io/gh/tomasfarias/airflow-dbt-python) An [Airflow](https://airflow.apache.org/) operator and hook to interface with the [`dbt-core`](https://pypi.org/project/dbt-core/) Python package.