|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 16 | + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: Set up Python ${{ matrix.python-version }} |
| 23 | + uses: actions/setup-python@v4 |
| 24 | + with: |
| 25 | + python-version: ${{ matrix.python-version }} |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: | |
| 29 | + python -m pip install --upgrade pip |
| 30 | + pip install pytest pytest-cov |
| 31 | +
|
| 32 | + - name: Run tests |
| 33 | + run: | |
| 34 | + python3 -m pytest tests/ -v --cov=src/ljpw --cov-report=xml --cov-report=term |
| 35 | +
|
| 36 | + - name: Upload coverage to Codecov |
| 37 | + uses: codecov/codecov-action@v3 |
| 38 | + if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest' |
| 39 | + with: |
| 40 | + file: ./coverage.xml |
| 41 | + fail_ci_if_error: false |
| 42 | + verbose: true |
| 43 | + |
| 44 | + lint: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - name: Checkout code |
| 48 | + uses: actions/checkout@v3 |
| 49 | + |
| 50 | + - name: Set up Python |
| 51 | + uses: actions/setup-python@v4 |
| 52 | + with: |
| 53 | + python-version: '3.11' |
| 54 | + |
| 55 | + - name: Install linting tools |
| 56 | + run: | |
| 57 | + python -m pip install --upgrade pip |
| 58 | + pip install flake8 black isort mypy |
| 59 | +
|
| 60 | + - name: Check code formatting with black |
| 61 | + run: | |
| 62 | + black --check src/ tests/ tools/ examples/ || true |
| 63 | +
|
| 64 | + - name: Check import sorting with isort |
| 65 | + run: | |
| 66 | + isort --check-only src/ tests/ tools/ examples/ || true |
| 67 | +
|
| 68 | + - name: Lint with flake8 |
| 69 | + run: | |
| 70 | + flake8 src/ tests/ tools/ examples/ --count --select=E9,F63,F7,F82 --show-source --statistics || true |
| 71 | + flake8 src/ tests/ tools/ examples/ --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics || true |
| 72 | +
|
| 73 | + test-install: |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - name: Checkout code |
| 77 | + uses: actions/checkout@v3 |
| 78 | + |
| 79 | + - name: Set up Python |
| 80 | + uses: actions/setup-python@v4 |
| 81 | + with: |
| 82 | + python-version: '3.11' |
| 83 | + |
| 84 | + - name: Test installation |
| 85 | + run: | |
| 86 | + python -m pip install --upgrade pip |
| 87 | + pip install -e . |
| 88 | +
|
| 89 | + - name: Test CLI |
| 90 | + run: | |
| 91 | + ljpw help || python -m src.ljpw.ljpw_standalone help |
| 92 | +
|
| 93 | + - name: Test basic analysis |
| 94 | + run: | |
| 95 | + echo 'def hello(): print("world")' > test.py |
| 96 | + ljpw analyze test.py || python -m src.ljpw.ljpw_standalone analyze test.py |
0 commit comments