summaryrefslogtreecommitdiffstats
path: root/.github/workflows/test-release.yml
blob: caf00dd8806b45870ff77469e8e4d95b2f650556 (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
name: Test Release
run-name: "Test Release (${{ inputs.gitlint_version }}, pypi_source=${{ inputs.pypi_source }}, repo_test_ref=${{ inputs.repo_test_ref }})"
on:
  workflow_call:
    inputs:
      gitlint_version:
        description: "Gitlint version to test"
        required: true
        default: "0.18.0"
        type: string
      pypi_source:
        description: "PyPI repository to use"
        required: true
        type: string
      repo_test_ref:
        description: "Git reference to checkout for integration tests"
        default: "main"
        type: string
  workflow_dispatch:
    inputs:
      gitlint_version:
        description: "Gitlint version to test"
        required: true
        default: "0.18.0"
      pypi_source:
        description: "PyPI repository to use"
        required: true
        type: choice
        options:
          - "pypi.org"
          - "test.pypi.org"
        default: "pypi.org"
      repo_test_ref:
        description: "Git reference to checkout for integration tests"
        default: "main"

jobs:
  test-release:
    timeout-minutes: 10
    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:
      - 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: Install gitlint
        run: |
          python -m pip install gitlint==${{ inputs.gitlint_version }}
        if: inputs.pypi_source == 'pypi.org'

      - name: Install gitlint (test.pypi.org)
        run: |
          pip install --no-cache-dir -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple gitlint==${{ inputs.gitlint_version }}
        if: inputs.pypi_source == 'test.pypi.org'

      - name: gitlint --version
        run: |
          gitlint --version
          [ "$(gitlint --version)" == "gitlint, version ${{ inputs.gitlint_version }}" ]

      - uses: actions/checkout@v3.3.0
        with:
          ref: ${{ inputs.repo_test_ref }}

      - 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'