| 1 |
name: Tests and Checks |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
on: |
| 6 |
push: |
| 7 |
branches: |
| 8 |
- main |
| 9 |
pull_request: |
| 10 |
branches: |
| 11 |
- main |
| 12 |
|
| 13 |
concurrency: |
| 14 |
group: ci-${{ github.ref }}-1 |
| 15 |
cancel-in-progress: true |
| 16 |
|
| 17 |
jobs: |
| 18 |
checks: |
| 19 |
runs-on: "ubuntu-latest" |
| 20 |
strategy: |
| 21 |
matrix: |
| 22 |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", pypy-3.9] |
| 23 |
os: ["macos-latest", "ubuntu-latest", "windows-latest"] |
| 24 |
steps: |
| 25 |
- uses: actions/[email protected] |
| 26 |
with: |
| 27 |
ref: ${{ github.event.pull_request.head.sha }} |
| 28 |
fetch-depth: 0 |
| 29 |
|
| 30 |
- name: Setup python |
| 31 |
uses: actions/[email protected] |
| 32 |
with: |
| 33 |
python-version: ${{ matrix.python-version }} |
| 34 |
|
| 35 |
- name: Install pypa/build |
| 36 |
run: python -m pip install build==0.10.0 |
| 37 |
|
| 38 |
- name: Install Hatch |
| 39 |
run: python -m pip install hatch==1.6.3 |
| 40 |
|
| 41 |
- name: Unit Tests |
| 42 |
run: hatch run test:unit-tests |
| 43 |
|
| 44 |
- name: Code formatting (black) |
| 45 |
run: hatch run test:format |
| 46 |
|
| 47 |
- name: Code linting (ruff) |
| 48 |
run: hatch run test:lint |
| 49 |
|
| 50 |
- name: Install local gitlint for integration tests |
| 51 |
run: | |
| 52 |
hatch run qa:install-local |
| 53 |
|
| 54 |
- name: Integration tests (default -> GITLINT_USE_SH_LIB=1) |
| 55 |
run: | |
| 56 |
hatch run qa:integration-tests |
| 57 |
if: matrix.os != 'windows-latest' |
| 58 |
|
| 59 |
- name: Integration tests (GITLINT_USE_SH_LIB=1) |
| 60 |
run: | |
| 61 |
hatch run qa:integration-tests |
| 62 |
env: |
| 63 |
GITLINT_USE_SH_LIB: 1 |
| 64 |
if: matrix.os != 'windows-latest' |
| 65 |
|
| 66 |
- name: Integration tests (GITLINT_QA_USE_SH_LIB=0) |
| 67 |
run: | |
| 68 |
hatch run qa:integration-tests -k "not(test_commit_hook_continue or test_commit_hook_abort or test_commit_hook_edit)" qa |
| 69 |
env: |
| 70 |
GITLINT_QA_USE_SH_LIB: 0 |
| 71 |
if: matrix.os != 'windows-latest' |
| 72 |
|
| 73 |
- name: Integration tests (Windows) |
| 74 |
run: | |
| 75 |
hatch run qa:integration-tests -k "not (test_commit_hook_continue or test_commit_hook_abort or test_commit_hook_edit or test_lint_staged_stdin or test_stdin_file or test_stdin_pipe_empty)" qa |
| 76 |
if: matrix.os == 'windows-latest' |
| 77 |
|
| 78 |
- name: Build test (gitlint) |
| 79 |
run: | |
| 80 |
python -m build |
| 81 |
hatch clean |
| 82 |
|
| 83 |
- name: Build test (gitlint-core) |
| 84 |
run: | |
| 85 |
python -m build |
| 86 |
hatch clean |
| 87 |
working-directory: ./gitlint-core |
| 88 |
|
| 89 |
- name: Docs build (mkdocs) |
| 90 |
run: hatch run docs:build |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
- name: gitlint --debug |
| 95 |
run: hatch run dev:gitlint --debug |
| 96 |
continue-on-error: ${{ github.event_name == 'pull_request' }} |
| 97 |
|
| 98 |
- name: Code Coverage (coveralls) |
| 99 |
uses: coverallsapp/github-action@master |
| 100 |
with: |
| 101 |
path-to-lcov: ".coverage.lcov" |
| 102 |
github-token: ${{ secrets.GITHUB_TOKEN }} |
| 103 |
git-commit: ${{ github.event.pull_request.head.sha }} |
| 104 |
flag-name: gitlint-${{ matrix.os }}-${{ matrix.python-version }} |
| 105 |
parallel: true |
| 106 |
|
| 107 |
upload_coveralls: |
| 108 |
needs: checks |
| 109 |
runs-on: ubuntu-latest |
| 110 |
steps: |
| 111 |
- name: Upload coverage to coveralls |
| 112 |
uses: coverallsapp/github-action@master |
| 113 |
with: |
| 114 |
path-to-lcov: ".coverage.lcov" |
| 115 |
github-token: ${{ secrets.GITHUB_TOKEN }} |
| 116 |
parallel-finished: true |
| 117 |
|
| 118 |
check: |
| 119 |
if: always() |
| 120 |
|
| 121 |
needs: |
| 122 |
- upload_coveralls |
| 123 |
- checks |
| 124 |
|
| 125 |
runs-on: ubuntu-latest |
| 126 |
|
| 127 |
steps: |
| 128 |
- name: Decide whether the needed jobs succeeded or failed |
| 129 |
uses: re-actors/alls-green@release/v1 |
| 130 |
with: |
| 131 |
jobs: ${{ toJSON(needs) }} |
| 132 |
|
| 133 |
|
| 134 |
auto-publish-dev: |
| 135 |
needs: |
| 136 |
- check |
| 137 |
if: github.ref == 'refs/heads/main' |
| 138 |
uses: ./.github/workflows/publish-release.yml |
| 139 |
secrets: inherit |
| 140 |
with: |
| 141 |
pypi_target: "pypi.org" |
| 142 |
repo_release_ref: "main" |