|
| 1 | +# Built from: |
| 2 | +# https://docs.github.com/en/actions/guides/building-and-testing-python |
| 3 | +# https://github.com/snok/install-poetry#workflows-and-tips |
| 4 | + |
| 5 | +name: Build and test schemasheets |
| 6 | + |
| 7 | +on: [push, pull_request] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + |
| 16 | + #---------------------------------------------- |
| 17 | + # check-out repo and set-up python |
| 18 | + #---------------------------------------------- |
| 19 | + - name: Check out repository |
| 20 | + uses: actions/checkout@v2 |
| 21 | + |
| 22 | + - name: Set up Python 3.9 |
| 23 | + uses: actions/setup-python@v2 |
| 24 | + with: |
| 25 | + python-version: 3.9 |
| 26 | + |
| 27 | + #---------------------------------------------- |
| 28 | + # install & configure poetry |
| 29 | + #---------------------------------------------- |
| 30 | + - name: Install Poetry |
| 31 | + uses: snok/install-poetry@v1.1.6 |
| 32 | + with: |
| 33 | + virtualenvs-create: true |
| 34 | + virtualenvs-in-project: true |
| 35 | + |
| 36 | + #---------------------------------------------- |
| 37 | + # load cached venv if cache exists |
| 38 | + #---------------------------------------------- |
| 39 | + - name: Load cached venv |
| 40 | + id: cached-poetry-dependencies |
| 41 | + uses: actions/cache@v2 |
| 42 | + with: |
| 43 | + path: .venv |
| 44 | + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} |
| 45 | + |
| 46 | + #---------------------------------------------- |
| 47 | + # install dependencies if cache does not exist |
| 48 | + #---------------------------------------------- |
| 49 | + - name: Install dependencies |
| 50 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 51 | + run: poetry install --no-interaction --no-root |
| 52 | + |
| 53 | + #---------------------------------------------- |
| 54 | + # install your root project, if required |
| 55 | + #---------------------------------------------- |
| 56 | + - name: Install library |
| 57 | + run: poetry install --no-interaction |
| 58 | + |
| 59 | + #---------------------------------------------- |
| 60 | + # run test suite |
| 61 | + #---------------------------------------------- |
| 62 | + - name: Run tests |
| 63 | + run: poetry run pytest --cov-report=term --cov-report=html:htmlcov --cov=schemasheets/ |
| 64 | + |
| 65 | + #---------------------------------------------- |
| 66 | + # upload coverage results |
| 67 | + #---------------------------------------------- |
| 68 | + - name: Upload pytest test results |
| 69 | + uses: actions/upload-artifact@v2 |
| 70 | + with: |
| 71 | + name: pytest-results |
| 72 | + path: htmlcov |
| 73 | + # Use always() to always run this step to publish test results when there are test failures |
| 74 | + if: ${{ always() }} |
0 commit comments