Merge branch 'main' of github.com:AriMirsky/Q-Learning #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
# We only need to test on one OS as we are using Docker | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_BASE_CMD: docker run --user root --rm | |
COVERAGE_VOLUME: ${{ github.workspace }}/coverage:/usr/app/coverage | |
steps: | |
# Checkout code | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Build Docker image | |
- name: Build Docker image | |
run: docker build -t autobike . | |
# Run Black formatting check | |
- name: Black formatting check | |
# always() runs even if the job is canceled, while success() || failure() does not | |
if: success() || failure() | |
run: ${{ env.DOCKER_BASE_CMD }} autobike black --check --config pyproject.toml . | |
# Run Pylint linting | |
- name: Pylint linting | |
if: success() || failure() | |
run: ${{ env.DOCKER_BASE_CMD }} autobike pylint --rcfile=pyproject.toml src/ | |
# Run Pytest with code coverage | |
- name: Pytest with code coverage | |
if: success() || failure() | |
# Specify coverage volume | |
run: ${{ env.DOCKER_BASE_CMD }} -v ${{ env.COVERAGE_VOLUME }} autobike pytest --cov=./ --cov-report=xml:./coverage/coverage.xml --cov-report=term | |
# Run mypy type checking | |
- name: Mypy type check | |
if: success() || failure() | |
run: ${{ env.DOCKER_BASE_CMD }} autobike mypy --config-file=pyproject.toml src/ | |
# Upload to codecov | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
if: success() | |
with: | |
# Coverage is saved here via the volume | |
files: ./coverage/coverage.xml | |
fail_ci_if_error: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |