Skip to content

update pre-commit scrippt #69

update pre-commit scrippt

update pre-commit scrippt #69

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://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: GitHub Actions CI/CD
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
# can install packages from a requirements file
if [ -f ci-cd-requirements.txt ]; then pip install -r ci-cd-requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 --max-complexity=10 --max-line-length=100 --count --show-source --statistics demo-assignments/A0/hello
flake8 --max-complexity=10 --max-line-length=100 --count --show-source --statistics demo-assignments/A0-OOP/hello
flake8 --max-complexity=10 --max-line-length=100 --count --show-source --statistics demo-assignments/A1/cold
flake8 --max-complexity=10 --max-line-length=100 --count --show-source --statistics demo-assignments/A1-OOP/cold
flake8 --max-complexity=10 --max-line-length=100 --count --show-source --statistics demo-assignments/A2-ABC/egypt
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Check types with mypy
run: |
mypy --strict --allow-untyped-decorators --ignore-missing-imports demo-assignments/A0/hello
mypy --strict --allow-untyped-decorators --ignore-missing-imports demo-assignments/A0-OOP/hello
mypy --strict --allow-untyped-decorators --ignore-missing-imports demo-assignments/A1/cold
mypy --strict --allow-untyped-decorators --ignore-missing-imports demo-assignments/A1-OOP/cold
mypy --strict --allow-untyped-decorators --ignore-missing-imports demo-assignments/A2-ABC/egypt
- name: Test with pytest
run: |
pytest --verbose demo-assignments/A0/hello/tests
pytest --verbose demo-assignments/A0-OOP/hello/tests
pytest --verbose demo-assignments/A1/cold/tests
pytest --verbose demo-assignments/A1-OOP/cold/tests
pytest --verbose demo-assignments/A2-ABC/egypt/tests
- name: Generate coverage report
run: |
pytest --cov-report=xml:demo-assignments/A0/hello/coverage.xml --cov=demo-assignments/A0/hello demo-assignments/A0/hello/tests
pytest --cov-report=xml:demo-assignments/A0-OOP/hello/coverage.xml --cov=demo-assignments/A0-OOP/hello demo-assignments/A0-OOP/hello/tests
pytest --cov-report=xml:demo-assignments/A1/cold/coverage.xml --cov=demo-assignments/A1/cold demo-assignments/A1/cold/tests
pytest --cov-report=xml:demo-assignments/A1-OOP/cold/coverage.xml --cov=demo-assignments/A1-OOP/cold demo-assignments/A1-OOP/cold/tests
pytest --cov-report=xml:demo-assignments/A2-ABC/egypt/coverage.xml --cov=demo-assignments/A2-ABC/egypt demo-assignments/A2-ABC/egypt/tests
codecov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
fail_ci_if_error: false # optional (default = false)
files: demo-assignments/A0/hello/coverage.xml \
demo-assignments/A0-OOP/hello/coverage.xml \
demo-assignments/A1/cold/coverage.xml \
demo-assignments/A1-OOP/cold/coverage.xml
demo-assignments/A2-ABC/egypt/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
slug: rambasnet/course-container