|
| 1 | +# This workflow will install Python dependencies, run tests and lint with a single version of Python |
| 2 | +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python |
| 3 | + |
| 4 | +name: PyTemplate CI |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [ main, dev ] |
| 9 | + pull_request: |
| 10 | + branches: [ main, dev ] |
| 11 | + |
| 12 | +jobs: |
| 13 | + style: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout PyTemplate Project |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Python ${{ matrix.python-version }} |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version-file: .python-version-default |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: | |
| 29 | + python -m pip install -U pip |
| 30 | + pip install wheel setuptools |
| 31 | + pip install tox |
| 32 | +
|
| 33 | + - name: Code Linting & Formatting |
| 34 | + if: always() |
| 35 | + run: tox -e lint |
| 36 | + |
| 37 | + - name: Static Type Safety Check |
| 38 | + if: always() |
| 39 | + run: tox -e type |
| 40 | + |
| 41 | + tests: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + strategy: |
| 44 | + matrix: |
| 45 | + python-version: [ "3.11", "3.12" ] |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout PyTemplate Project |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Set up Python ${{ matrix.python-version }} |
| 52 | + uses: actions/setup-python@v5 |
| 53 | + with: |
| 54 | + python-version: ${{ matrix.python-version }} |
| 55 | + |
| 56 | + - name: Install dependencies |
| 57 | + run: | |
| 58 | + python -m pip install -U pip |
| 59 | + pip install wheel setuptools |
| 60 | + pip install tox |
| 61 | + echo "TOX_VERSION=py$(echo ${{ matrix.python-version }} | tr -d .)-tests" >> $GITHUB_ENV |
| 62 | +
|
| 63 | + - name: Unit Testing |
| 64 | + run: | |
| 65 | + tox -e ${{ env.TOX_VERSION }} |
| 66 | +
|
| 67 | + - name: Save Coverage Data Temporarily |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: coverage-data-${{ matrix.python-version }} |
| 71 | + path: .coverage.* |
| 72 | + retention-days: 1 |
| 73 | + if-no-files-found: ignore |
| 74 | + include-hidden-files: true |
| 75 | + |
| 76 | + coverage: |
| 77 | + runs-on: "ubuntu-latest" |
| 78 | + needs: [ tests ] |
| 79 | + strategy: |
| 80 | + fail-fast: false |
| 81 | + |
| 82 | + steps: |
| 83 | + - name: Checkout |
| 84 | + uses: actions/checkout@v4 |
| 85 | + |
| 86 | + - name: Download coverage data |
| 87 | + uses: actions/download-artifact@v4 |
| 88 | + with: |
| 89 | + pattern: coverage-data-* |
| 90 | + merge-multiple: true |
| 91 | + |
| 92 | + - name: Set up Python |
| 93 | + uses: actions/setup-python@v5 |
| 94 | + with: |
| 95 | + python-version-file: .python-version-default |
| 96 | + |
| 97 | + - name: Install Dependencies |
| 98 | + run: | |
| 99 | + pip install coverage |
| 100 | +
|
| 101 | + - name: Report Testing Coverage |
| 102 | + run: | |
| 103 | + coverage combine |
| 104 | + coverage report --format markdown | tee $GITHUB_STEP_SUMMARY |
| 105 | + coverage report |
| 106 | +
|
| 107 | + license: |
| 108 | + runs-on: ubuntu-latest |
| 109 | + steps: |
| 110 | + - name: Checkout |
| 111 | + uses: actions/checkout@v4 |
| 112 | + |
| 113 | + - name: Setup Golang |
| 114 | + uses: actions/setup-go@v5 |
| 115 | + with: |
| 116 | + go-version: '1.22.4' |
| 117 | + |
| 118 | + - name: Install addlicense |
| 119 | + run: | |
| 120 | + go install github.com/google/addlicense@v1.1.1 |
| 121 | +
|
| 122 | + - name: Check for License Headers |
| 123 | + run: | |
| 124 | + addlicense -check -f LICENSE src |
| 125 | + addlicense -check -f LICENSE tests |
0 commit comments