Skip to content

Commit

Permalink
chore: Add a test workflow (#679)
Browse files Browse the repository at this point in the history
* chore: Add a test workflow

* chore: Add pip constraints

* chore: Add dependabot

* chore: Add workflow trigger

* chore: Fix matrix yaml indentation

* chore: Fix file name

* chore: Add poetry cache

* chore: Remove duplicate step

* chore: Move poetry installation step before setup-python

* chore: Use explicit Python version for Poetry venv

* chore: Add lint job

* chore: Use tox environments in matrix

* test: Mark all tests under tests/external*/ as 'external'

* test: Combine coverage

* test: Continue to coverage if external tests fail

* test: Add --parallel flag for coverage

* Make sure tox is installed

* Fix tox env name

* Upload coverage

* Coverage fail under 85%

* Add doctest to matrix

* Add dependabot for GitHub Actions

* skip external tests temporarily

Co-authored-by: Aaron ("AJ") Steers <aj@meltano.com>
  • Loading branch information
edgarrmondragon and aaronsteers committed Jun 1, 2022
1 parent bdd08b6 commit 40b3b16
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 72 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/.github/workflows"
schedule:
interval: daily
time: "12:00"
timezone: "UTC"
reviewers: [meltano-engineering]
labels: [deps]
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
reviewers: [meltano-engineering]
labels: [deps]
3 changes: 3 additions & 0 deletions .github/workflows/constraints.txt
@@ -0,0 +1,3 @@
pip==22.1.1
poetry==1.1.13
virtualenv==20.14.1
112 changes: 112 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,112 @@
name: Test

on:
pull_request: {}
push:
branches: [main]
workflow_dispatch:
inputs: {}

jobs:
tests:
name: Test on ${{ matrix.python-version }} (${{ matrix.tox-env }}${{ matrix.external && ', external' || '' }}) / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.external || false }}
strategy:
fail-fast: false
matrix:
include:
- { tox-env: py, python-version: "3.7", os: "ubuntu-latest" }
- { tox-env: py, python-version: "3.8", os: "ubuntu-latest" }
- { tox-env: py, python-version: "3.9", os: "ubuntu-latest" }
- { tox-env: py, python-version: "3.10", os: "ubuntu-latest" }
#TODO: resolve by mapping CI vars to creds:
# https://github.com/meltano/sdk/issues/683
# - { tox-env: py, python-version: "3.10", os: "ubuntu-latest", external: true }
- { tox-env: doctest, python-version: "3.10", os: "ubuntu-latest" }
- { tox-env: lint, python-version: "3.8", os: "ubuntu-latest" }

steps:
- name: Check out the repository
uses: actions/checkout@v3.0.2

- name: Install Poetry
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install poetry
poetry --version
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v3.1.2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'poetry'

- name: Upgrade pip
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pip install pip
pip --version
- name: Install Dependencies
run: |
poetry env use "${{ matrix.python-version }}"
poetry install
- name: Run tox
run: |
poetry run tox -e ${{ matrix.tox-env }} --${{ matrix.external && ' -m "external"' || '' }}${{ matrix.doctest && ' --doctest-modules singer_sdk' }}
- name: Upload coverage data
if: always() && (matrix.tox-env == 'py')
uses: actions/upload-artifact@v3.1.0
with:
name: coverage-data
path: ".coverage.*"

coverage:
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out the repository
uses: actions/checkout@v3.0.2

- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Set up Python
uses: actions/setup-python@v3.1.2
with:
python-version: '3.10'
cache: 'poetry'

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Download coverage data
uses: actions/download-artifact@v3.0.0
with:
name: coverage-data

- name: Install Dependencies
run: |
poetry env use "3.10"
poetry install
- name: Combine coverage data and display human readable report
run: |
poetry run tox -e combine_coverage
- name: Create coverage report
run: |
poetry run tox -e coverage_xml
- name: Upload coverage report
uses: codecov/codecov-action@v3.1.0
114 changes: 47 additions & 67 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40b3b16

Please sign in to comment.