1- # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
1+ # .github/workflows/python-package.yml
32
4- name : Python package
3+ name : CI
54
65on :
76 push :
8- branches : [ "master" ]
7+ branches : [ "master", "main" ] # Also works on 'main' branch
98 pull_request :
10- branches : [ "master" ]
9+ branches : [ "master", "main" ]
1110
1211jobs :
1312 build :
14-
1513 runs-on : ubuntu-latest
1614 strategy :
1715 fail-fast : false
1816 matrix :
19- python-version : ["3.7", "3. 8", "3.9", "3.10", "3.11", "3.12"]
17+ python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"] # Adjusted for modern versions
2018
2119 steps :
22- - uses : actions/checkout@v3
20+ - name : Checkout code
21+ uses : actions/checkout@v4 # Use the latest version
22+
2323 - name : Set up Python ${{ matrix.python-version }}
24- uses : actions/setup-python@v3
24+ uses : actions/setup-python@v5 # Use the latest version
2525 with :
2626 python-version : ${{ matrix.python-version }}
27+
2728 - name : Install dependencies
2829 run : |
2930 python -m pip install --upgrade pip
30- python -m pip install flake8 goroutine-py
31- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32- - name : Lint with flake8
31+ # This command installs the project from local files in editable mode (-e)
32+ # and includes the [test] dependencies from pyproject.toml
33+ python -m pip install -e ".[test]"
34+
35+ - name : Lint with flake8, black, and isort
3336 run : |
3437 # stop the build if there are Python syntax errors or undefined names
3538 flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
36- # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38- - name : Test demo
39+ # Check formatting with black
40+ black --check .
41+ # Check import sorting with isort
42+ isort --check .
43+
44+ - name : Run tests with pytest
3945 run : |
40- python demo.py
46+ pytest
0 commit comments