Skip to content

Merge pull request #92 from COMP1010UNSW/dependabot/pip/coverage-7.6.4 #251

Merge pull request #92 from COMP1010UNSW/dependabot/pip/coverage-7.6.4

Merge pull request #92 from COMP1010UNSW/dependabot/pip/coverage-7.6.4 #251

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Test and Lint
on:
pull_request:
branches:
- main
push:
branches:
- main
# Yoinked from https://github.com/MTES-MCT/apilos/pull/854/files
# Explicitely set permissions to allow Dependabot workflow runs to write in the PR
# for coverage's reporting.
# By default, these are read-only when the actions are ran by Dependabot
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#changing-github_token-permissions
permissions:
pull-requests: write
jobs:
Pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- uses: Gr1N/setup-poetry@v9
- uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- run: poetry --version
- run: poetry install
- name: Test with pytest
run: |
poetry run coverage run -m pytest
- name: Print coverage output
run: |
poetry run coverage report
- name: Generate code coverage report
if: ${{ github.event_name == 'pull_request' }}
run: |
poetry run coverage xml
- name: Create code coverage comment
if: ${{ github.event_name == 'pull_request' }}
uses: orgoro/coverage@v3
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
Flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- uses: Gr1N/setup-poetry@v9
- uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- run: poetry --version
- run: poetry install
- name: Lint with flake8
run: |
poetry run flake8
Mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- uses: Gr1N/setup-poetry@v9
- uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- run: poetry --version
- run: poetry install
- name: Lint with mypy
run: |
poetry run mypy .