|
1 | | -name: Testing package |
| 1 | +name: Test |
2 | 2 |
|
3 | | -on: push |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + types: [opened, synchronize] |
4 | 9 |
|
5 | 10 | jobs: |
6 | | - lint: |
7 | | - strategy: |
8 | | - matrix: |
9 | | - cmd: |
10 | | - - black |
11 | | - - mypy |
12 | | - - ruff |
| 11 | + static_analysis: |
| 12 | + if: github.event.pull_request.draft == false |
13 | 13 | runs-on: ubuntu-latest |
14 | 14 | steps: |
15 | 15 | - uses: actions/checkout@v4 |
16 | | - - name: Install poetry |
17 | | - run: pipx install poetry |
18 | | - - name: Set up Python |
19 | | - uses: actions/setup-python@v4 |
| 16 | + - uses: actions/setup-python@v4 |
20 | 17 | with: |
21 | | - python-version: "3.9" |
22 | | - cache: "poetry" |
23 | | - - name: Install deps |
24 | | - run: poetry install |
25 | | - - name: Run lint check |
26 | | - run: poetry run pre-commit run -a ${{ matrix.cmd }} |
27 | | - pytest: |
28 | | - permissions: |
29 | | - checks: write |
30 | | - pull-requests: write |
31 | | - contents: write |
| 18 | + python-version: 3.8 |
| 19 | + - name: Install Dependencies and library |
| 20 | + shell: bash |
| 21 | + run: | |
| 22 | + set -ux |
| 23 | + python -m pip install --upgrade pip |
| 24 | + pip install -e ".[dev]" |
| 25 | +
|
| 26 | + - name: Run black |
| 27 | + shell: bash |
| 28 | + run: black taskiq_faststream |
| 29 | + |
| 30 | + - name: Run mypy |
| 31 | + shell: bash |
| 32 | + run: mypy taskiq_faststream |
| 33 | + |
| 34 | + - name: Run ruff |
| 35 | + shell: bash |
| 36 | + run: ruff taskiq_faststream |
| 37 | + |
| 38 | + test: |
| 39 | + if: github.event.pull_request.draft == false |
| 40 | + runs-on: ubuntu-latest |
32 | 41 | strategy: |
33 | 42 | matrix: |
34 | | - py_version: ["3.8", "3.9", "3.10", "3.11"] |
35 | | - os: [ubuntu-latest, windows-latest] |
36 | | - runs-on: "${{ matrix.os }}" |
| 43 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
| 44 | + pydantic-version: ["pydantic-v1", "pydantic-v2"] |
| 45 | + fail-fast: false |
| 46 | + |
37 | 47 | steps: |
38 | 48 | - uses: actions/checkout@v4 |
39 | | - - name: Install poetry |
40 | | - run: pipx install poetry |
41 | 49 | - name: Set up Python |
42 | 50 | uses: actions/setup-python@v4 |
43 | 51 | with: |
44 | | - python-version: "${{ matrix.py_version }}" |
45 | | - cache: "poetry" |
46 | | - - name: Install deps |
47 | | - run: poetry install |
48 | | - - name: Run pytest check |
49 | | - run: poetry run pytest -vv -n auto --cov="taskiq_faststream" . |
50 | | - - name: Generate report |
51 | | - run: poetry run coverage xml |
52 | | - - name: Upload coverage reports to Codecov with GitHub Action |
53 | | - uses: codecov/codecov-action@v3 |
54 | | - if: matrix.os == 'ubuntu-latest' && matrix.py_version == '3.9' |
55 | | - with: |
56 | | - token: ${{ secrets.CODECOV_TOKEN }} |
57 | | - fail_ci_if_error: false |
58 | | - verbose: true |
| 52 | + python-version: ${{ matrix.python-version }} |
| 53 | + - uses: actions/cache@v3 |
| 54 | + id: cache |
| 55 | + with: |
| 56 | + path: ${{ env.pythonLocation }} |
| 57 | + key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03 |
| 58 | + - name: Install Dependencies |
| 59 | + if: steps.cache.outputs.cache-hit != 'true' |
| 60 | + run: pip install -e .[test] |
| 61 | + - name: Install Pydantic v1 |
| 62 | + if: matrix.pydantic-version == 'pydantic-v1' |
| 63 | + run: pip install "pydantic>=1.10,<2" |
| 64 | + - name: Install Pydantic v2 |
| 65 | + if: matrix.pydantic-version == 'pydantic-v2' |
| 66 | + run: pip install --pre "pydantic>=2,<3" |
| 67 | + - run: mkdir coverage |
| 68 | + - name: Test |
| 69 | + run: bash scripts/test.sh |
| 70 | + env: |
| 71 | + COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} |
| 72 | + CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} |
| 73 | + - name: Store coverage files |
| 74 | + uses: actions/upload-artifact@v3 |
| 75 | + with: |
| 76 | + name: coverage |
| 77 | + path: coverage |
| 78 | + |
| 79 | + coverage-combine: |
| 80 | + needs: [test] |
| 81 | + runs-on: ubuntu-latest |
| 82 | + |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + |
| 86 | + - uses: actions/setup-python@v4 |
| 87 | + with: |
| 88 | + python-version: '3.8' |
| 89 | + |
| 90 | + - name: Get coverage files |
| 91 | + uses: actions/download-artifact@v3 |
| 92 | + with: |
| 93 | + name: coverage |
| 94 | + path: coverage |
| 95 | + |
| 96 | + - run: pip install coverage[toml] |
| 97 | + |
| 98 | + - run: ls -la coverage |
| 99 | + - run: coverage combine coverage |
| 100 | + - run: coverage report |
| 101 | + - run: coverage html --show-contexts --title "taskiq-faststream coverage for ${{ github.sha }}" |
| 102 | + |
| 103 | + - name: Store coverage html |
| 104 | + uses: actions/upload-artifact@v3 |
| 105 | + with: |
| 106 | + name: coverage-html |
| 107 | + path: htmlcov |
| 108 | + |
| 109 | + # https://github.com/marketplace/actions/alls-green#why |
| 110 | + check: # This job does nothing and is only used for the branch protection |
| 111 | + if: github.event.pull_request.draft == false |
| 112 | + |
| 113 | + needs: |
| 114 | + - coverage-combine |
| 115 | + |
| 116 | + runs-on: ubuntu-latest |
| 117 | + |
| 118 | + steps: |
| 119 | + - name: Decide whether the needed jobs succeeded or failed |
| 120 | + uses: re-actors/alls-green@release/v1 |
| 121 | + with: |
| 122 | + jobs: ${{ toJSON(needs) }} |
0 commit comments