1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
name: Tests and Checks
# Only run CI on pushes to main and pull requests
# We don't run CI on other branches, but those should be merged into main via a PR anyways which will trigger CI before the merge.
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
checks:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", pypy-3.9]
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
steps:
- uses: actions/checkout@v3.3.0
with:
ref: ${{ github.event.pull_request.head.sha }} # Checkout pull request HEAD commit instead of merge commit
- name: Setup python
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
run: python -m pip install hatch==1.6.3
- name: Unit Tests
run: hatch run test:unit-tests
- name: Code formatting (black)
run: hatch run test:format
- name: Code linting (ruff)
run: hatch run test:lint
- name: Install local gitlint for integration tests
run: |
hatch run qa:install-local
- name: Integration tests (default -> GITLINT_USE_SH_LIB=1)
run: |
hatch run qa:integration-tests
if: matrix.os != 'windows-latest'
- name: Integration tests (GITLINT_USE_SH_LIB=1)
run: |
hatch run qa:integration-tests
env:
GITLINT_USE_SH_LIB: 1
if: matrix.os != 'windows-latest'
- name: Integration tests (GITLINT_QA_USE_SH_LIB=0)
run: |
hatch run qa:integration-tests -k "not(test_commit_hook_continue or test_commit_hook_abort or test_commit_hook_edit)" qa
env:
GITLINT_QA_USE_SH_LIB: 0
if: matrix.os != 'windows-latest'
- name: Integration tests (Windows)
run: |
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
if: matrix.os == 'windows-latest'
- name: Build test (gitlint)
run: |
hatch build
hatch clean
- name: Build test (gitlint-core)
run: |
hatch build
hatch clean
working-directory: ./gitlint-core
- name: Docs build (mkdocs)
run: hatch run docs:build
# Run gitlint. Skip during PR runs, since PR commit messages are transient and usually full of gitlint violations.
# PRs get squashed and get a proper commit message during merge.
- name: gitlint --debug
run: hatch run dev:gitlint --debug
continue-on-error: ${{ github.event_name == 'pull_request' }} # Don't enforce gitlint in PRs
# Coveralls integration doesn't properly work at this point, also see below
# - name: Coveralls
# env:
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
# run: coveralls
# Patch the commit-msg hook to make it work in GH CI
# Specifically, within the commit-msg hook, wrap the invocation of gitlint with `script`
# Coveralls GH Action currently doesn't support current non-LCOV reporting format
# For now, still using Travis for unit test coverage reporting
# https://github.com/coverallsapp/github-action/issues/30
# - name: Coveralls
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
check: # This job does nothing and is only used for the branch protection
if: always() # Ref: https://github.com/marketplace/actions/alls-green#why
needs:
- checks
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
|