summaryrefslogtreecommitdiffstats
path: root/.github/workflows/checks.yml
blob: 710245c0eeb586048f389f726a265a9128b767ea (plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Tests and Checks

on: [push, pull_request]

jobs:
  checks:
    runs-on: "ubuntu-latest"
    strategy:
      matrix:
        python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, pypy2, pypy3]
        os: ["macos-latest", "ubuntu-latest"]
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.sha }} # Checkout pull request HEAD commit instead of merge commit

      # Because gitlint is a tool that uses git itself under the hood, we remove git tracking from the checked out
      # code by temporarily renaming the .git directory. 
      # This is to ensure that the tests don't have a dependency on the version control of gitlint itself.
      - name: Temporarily remove git version control from code
        run: mv .git ._git

      - name: Setup python
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install requirements
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install -r test-requirements.txt

      - name: Unit Tests
        run: ./run_tests.sh

      # Coveralls integration doesn't properly work at this point, also see below
      # - name: Coveralls
      #   env:
      #     COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
      #   run: coveralls

      - name: Integration Tests
        run: ./run_tests.sh -i

      - name: Integration Tests (GITLINT_USE_SH_LIB=0)
        env:
          GITLINT_USE_SH_LIB: 0
        run: ./run_tests.sh -i

      - name: PEP8
        run: ./run_tests.sh -p

      - name: PyLint
        run: ./run_tests.sh -l

      - name: Build tests
        run: ./run_tests.sh --build

      # 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 }}

      # Re-add git version control so we can run gitlint on itself.
      - name: Re-add git version control to code
        run: mv ._git .git

      - name: Gitlint check
        run: ./run_tests.sh -g --debug

  windows-checks:
    runs-on: windows-latest
    strategy:
      matrix:
        python-version: [2.7, 3.6]
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.sha }} # Checkout pull request HEAD commit instead of merge commit

      # Because gitlint is a tool that uses git itself under the hood, we remove git tracking from the checked out
      # code by temporarily renaming the .git directory. 
      # This is to ensure that the tests don't have a dependency on the version control of gitlint itself.
      - name: Temporarily remove git version control from code
        run: Rename-Item .git ._git
    
      - name: Setup python
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      - name: "Upgrade pip on Python 3"
        if: matrix.python-version == '3.6'
        run: python -m pip install --upgrade pip

      - name: Install requirements
        run: |
          pip install -r requirements.txt
          pip install -r test-requirements.txt

      - name: gitlint --version
        run: gitlint --version

      - name: Tests (sanity)
        run: tools\windows\run_tests.bat "gitlint\tests\cli\test_cli.py::CLITests::test_lint"

      - name: Tests (ignore cli\*)
        run: pytest --ignore gitlint\tests\cli -rw -s gitlint

      - name: Tests (test_cli.py only - continue-on-error:true)
        run: tools\windows\run_tests.bat "gitlint\tests\cli\test_cli.py"
        continue-on-error: true # Known to fail at this point

      - name: Tests (all - continue-on-error:true)
        run: tools\windows\run_tests.bat
        continue-on-error: true # Known to fail at this point

      - name: Integration tests (continue-on-error:true)
        run: pytest -rw -s qa
        continue-on-error: true # Known to fail at this point

      - name: PEP8
        run: flake8 gitlint qa examples

      - name: PyLint
        run: pylint gitlint qa --rcfile=".pylintrc" -r n

      # Re-add git version control so we can run gitlint on itself.
      - name: Re-add git version control to code
        run: Rename-Item ._git .git

      - name: Gitlint check
        run: gitlint --debug