summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 099ac0fb71e044d56c2b5dffd5472e1110528aa0 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: CI
on: [push, pull_request]

jobs:
  linters:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - testenv: pylint
          - testenv: flake8
          - testenv: mypy
          - testenv: docs
          - testenv: vulture
          - testenv: misc
          - testenv: pyroma
          - testenv: check-manifest
          - testenv: eslint
          - testenv: shellcheck
            args: "-f gcc"  # For problem matchers
    steps:
      - uses: actions/checkout@v2
      - uses: actions/cache@v2
        with:
          path: |
            .mypy_cache
            .tox
            ~/.cache/pip
          key: "${{ matrix.testenv }}-${{ hashFiles('misc/requirements/requirements-*.txt') }}-${{ hashFiles('requirements.txt') }}"
      - uses: actions/setup-python@v2
        with:
          python-version: '3.8'
      - uses: actions/setup-node@v2.1.0
        with:
          node-version: '12.x'
        if: "matrix.testenv == 'eslint'"
      - name: Set up problem matchers
        run: "python scripts/dev/ci/problemmatchers.py ${{ matrix.testenv }} ${{ runner.temp }}"
      - name: Install dependencies
        run: |
            [[ ${{ matrix.testenv }} == eslint ]] && npm install -g eslint
            [[ ${{ matrix.testenv }} == docs ]] && sudo apt-get install --no-install-recommends asciidoc
            python -m pip install -U pip
            python -m pip install -U -r misc/requirements/requirements-tox.txt
      - name: "Run ${{ matrix.testenv }}"
        run: "tox -e ${{ matrix.testenv}} -- ${{ matrix.args }}"

  tests-docker:
    runs-on: ubuntu-20.04
    strategy:
      fail-fast: false
      matrix:
        image:
          - archlinux-webkit
          - archlinux-webengine
          # - archlinux-webengine-unstable
    container:
      image: "qutebrowser/ci:${{ matrix.image }}"
      env:
        QUTE_BDD_WEBENGINE: "${{ matrix.image != 'archlinux-webkit' }}"
        DOCKER: "${{ matrix.image }}"
        CI: true
        PYTEST_ADDOPTS: "--color=yes"
      volumes:
        # Hardcoded because we can't use ${{ runner.temp }} here apparently.
        - /home/runner/work/_temp/:/home/runner/work/_temp/
      options: --privileged --tty
    steps:
      - uses: actions/checkout@v2
      - name: Set up problem matchers
        run: "python scripts/dev/ci/problemmatchers.py py38 ${{ runner.temp }}"
      - run: tox -e py38

  tests:
    continue-on-error: "${{ matrix.experimental == true }}"
    strategy:
      fail-fast: false
      matrix:
        include:
          ### PyQt 5.7.1 (Python 3.5)
          # - testenv: py35-pyqt57
          #   os: ubuntu-16.04
          #   python: 3.5
          #   experimental: true
          ### PyQt 5.9 (Python 3.6)
          - testenv: py36-pyqt59
            os: ubuntu-18.04
            python: 3.6
          ### PyQt 5.10 (Python 3.6)
          - testenv: py36-pyqt510
            os: ubuntu-20.04
            python: 3.6
          ### PyQt 5.11 (Python 3.7)
          - testenv: py37-pyqt511
            os: ubuntu-20.04
            python: 3.7
          ### PyQt 5.12 (Python 3.8)
          - testenv: py38-pyqt512
            os: ubuntu-20.04
            python: 3.8
          ### PyQt 5.13 (Python 3.8)
          - testenv: py38-pyqt513
            os: ubuntu-20.04
            python: 3.8
          ### PyQt 5.14 (Python 3.8)
          - testenv: py38-pyqt514
            os: ubuntu-20.04
            python: 3.8
          ### PyQt 5.15 (Python nightly)
          - testenv: py3-pyqt515
            os: ubuntu-20.04
            python: 3.10-dev
          ### PyQt 5.15 (Python 3.8, with coverage)
          - testenv: py38-pyqt515-cov
            os: ubuntu-20.04
            python: 3.8
          ### macOS: PyQt 5.14 (Python 3.7)
          - testenv: py37-pyqt514
            os: macos-10.15
            python: 3.7
            args: "tests/unit"  # Only run unit tests on macOS
          ### Windows: PyQt 5.14 (Python 3.7)
          - testenv: py37-pyqt514
            os: windows-2019
            python: 3.7
    runs-on: "${{ matrix.os }}"
    steps:
      - uses: actions/checkout@v2
      - uses: actions/cache@v2
        with:
          path: |
            .mypy_cache
            .tox
            ~/.cache/pip
          key: "${{ matrix.testenv }}-${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('misc/requirements/requirements-*.txt') }}-${{ hashFiles('requirements.txt') }}"
      - name: Set up Python
        uses: actions/setup-python@v2
        if: "!endsWith(matrix.python, '-dev')"
        with:
          python-version: "${{ matrix.python }}"
      - name: Set up development Python
        uses: deadsnakes/action@v1.0.0
        if: "endsWith(matrix.python, '-dev')"
        with:
          python-version: "${{ matrix.python }}"
      - name: Set up problem matchers
        run: "python scripts/dev/ci/problemmatchers.py ${{ matrix.testenv }} ${{ runner.temp }}"
      - name: Install apt dependencies
        run: sudo apt-get install --no-install-recommends libyaml-dev libegl1-mesa libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0
        if: "startsWith(matrix.os, 'ubuntu-')"
      - name: Install dependencies
        run: |
            python -m pip install -U pip
            python -m pip install -U -r misc/requirements/requirements-tox.txt
      - name: "Run ${{ matrix.testenv }}"
        env:
          PYTEST_ADDOPTS: "--color=yes"
        run: "tox -e ${{ matrix.testenv}} -- ${{ matrix.args }}"
      - name: Analyze backtraces
        run: "bash scripts/dev/ci/backtrace.sh ${{ matrix.testenv }}"
        if: "failure()"
      - name: Upload coverage
        if: "endsWith(matrix.testenv, '-cov')"
        uses: codecov/codecov-action@v1.0.10
        with:
          name: "${{ matrix.testenv }}"

  codeql:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        # We must fetch at least the immediate parents so that if this is
        # a pull request then we can checkout the head.
        fetch-depth: 2
    # If this run was triggered by a pull request event, then checkout
    # the head of the pull request instead of the merge commit.
    - run: git checkout HEAD^2
      if: ${{ github.event_name == 'pull_request' }}
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v1
      with:
        languages: javascript, python
    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v1

  irc:
    runs-on: ubuntu-latest
    needs: [linters, tests, tests-docker, codeql]
    if: always()
    steps:
    - name: Send success IRC notification
      uses: Gottox/irc-message-action@v1
      if: "needs.linters.result == 'success' && needs.tests.result == 'success' && needs.tests-docker.result == 'success' && needs.codeql.result == 'success'"
      with:
        server: chat.freenode.net
        channel: '#qutebrowser-dev'
        nickname: qutebrowser-bot
        message: |-
          [${{ github.workflow }}] Success: ${{ github.ref }} https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} triggered by ${{ github.actor }}
    - name: Send non-success IRC notification
      uses: Gottox/irc-message-action@v1
      if: "needs.linters.result != 'success' || needs.tests.result != 'success' || needs.tests-docker.result != 'success' || needs.codeql.result != 'success'"
      with:
        server: chat.freenode.net
        channel: '#qutebrowser-dev'
        nickname: qutebrowser-bot
        message: |-
          [${{ github.workflow }}] FAIL: ${{ github.ref }} https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} triggered by ${{ github.actor }}
          linters: ${{ needs.linters.result }}, tests: ${{ needs.tests.result }}, tests-docker: ${{ needs.tests-docker.result }}, codeql: ${{ needs.codeql.result }}