RT-Migration #137
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: Python application | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
# This job runs all steps except unittest in parallel | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 | |
pip install black | |
pip install isort | |
python -m pip install poetry | |
poetry install --no-root # Install project dependencies | |
- name: Lint with flake8 | |
run: | | |
# Stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# Exit-zero treats all errors as warnings. | |
flake8 . --count --exit-zero --max-complexity=10 --statistics | |
- name: Format code with Black | |
run: | | |
black . --exclude="" --check --verbose | |
- name: Sort imports with isort | |
run: | | |
isort . --profile=black --check-only --verbose | |
# This job only runs the unittest tests sequentially, after the 'build' job | |
test: | |
runs-on: ubuntu-latest | |
needs: build # Ensure this job waits for the 'build' job to complete | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
max-parallel: 1 # This ensures the unittest runs sequentially across Python versions | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install poetry | |
poetry install --no-root # Install project dependencies | |
- name: Test with unittest | |
env: | |
API_KEY: ${{ secrets.API_KEY }} | |
run: | | |
poetry run python -m unittest discover tests |