aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/main.yml
blob: 2e739fa0a918d932a9af1dc2e75347af38e3cb3a (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
name: CI

on: [push, pull_request]

jobs:
  lint-pr:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: TrueBrain/actions-flake8@v1.2
  lint-local:
    if: github.event_name == 'push'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
      - run: pip install tox
      - run: tox -e flake8
  filename-matching:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
      - run: pip install tox
      - run: tox -e filename_matching
  mypy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
      - run: pip install tox
      - run: tox -e mypy
  individual-coverage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
      - run: pip install tox
      - run: tox -e individual_coverage
  test:
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - run: printenv
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
        with:
          python-version: '3.8'
      - run: pip install tox
      - run: tox -e py38
      - uses: codecov/codecov-action@v1
        with:
          file: ./coverage.xml
          name: ${{ matrix.os }}
          fail_ci_if_error: true
  test-py35:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
        with:
          python-version: '3.5'
      - run: pip install tox
      - run: tox -e py35
  build-wheel:
    runs-on: ubuntu-latest
    env:
      CI_BUILD_WHEEL: 1
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
        with:
          python-version: '3.8'
      - run: pip install tox
      - run: tox -e cibuild -- build
      - uses: actions/upload-artifact@master
        with:
          name: wheel
          path: release/dist
  build-binaries:
    strategy:
      fail-fast: false
      matrix:
        # Old Ubuntu version for old glibc
        os: [macos-latest, windows-latest, ubuntu-16.04]
    runs-on: ${{ matrix.os }}
    env:
      CI_BUILD_PYINSTALLER: 1
      CI_BUILD_WININSTALLER: ${{ matrix.os == 'windows-latest' }}
      CI_BUILD_KEY: ${{ secrets.CI_BUILD_KEY }}
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
        with:
          python-version: '3.7'
      - if: matrix.os == 'windows-latest'
        uses: actions/cache@v1
        with:
          path: release/installbuilder/setup
          key: installbuilder
      - run: pip install tox
      - run: tox -e cibuild -- build
      # artifacts must have different names, see https://github.com/actions/upload-artifact/issues/24
      - uses: actions/upload-artifact@master
        with:
          name: binaries.${{ matrix.os }}
          path: release/dist

  test-web-ui:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - run: git rev-parse --abbrev-ref HEAD
      - uses: actions/setup-node@v1
      - id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - uses: actions/cache@v1
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - working-directory: ./web
        run: yarn
      - working-directory: ./web
        run: npm test
      - uses: codecov/codecov-action@v1
        with:
          file: ./web/coverage/coverage-final.json
          name: web
          fail_ci_if_error: true

  docs:
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
        with:
          python-version: '3.8'
      - run: pip install tox
      - run: |
          wget https://github.com/gohugoio/hugo/releases/download/v0.70.0/hugo_extended_0.70.0_Linux-64bit.deb
          sudo dpkg -i hugo*.deb
      - run: tox -e docs

  # Separate from everything else because slow.
  build-and-deploy-docker:
    if: github.repository == 'mitmproxy/mitmproxy' && github.event_name == 'push'
    needs: [test, test-web-ui, build-wheel]
    runs-on: ubuntu-latest
    env:
      CI_BUILD_DOCKER: 1
      DOCKER_USERNAME: mitmbot
      DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
        with:
          python-version: '3.7'
      - run: pip install tox
      - uses: actions/download-artifact@master
        with:
          name: wheel
          path: release/dist
      - run: tox -e cibuild -- build
      - run: tox -e cibuild -- upload

  deploy:
    if: github.repository == 'mitmproxy/mitmproxy' && github.event_name == 'push'
    runs-on: ubuntu-latest
    needs: [test, test-web-ui, build-wheel, build-binaries]
    env:
      CI_BUILD_WHEEL: 1
      CI_BUILD_PYINSTALLER: 1
      CI_BUILD_WININSTALLER: 1
      TWINE_USERNAME: mitmproxy
      TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
        with:
          python-version: '3.8'
      # artifacts must be downloaded individually, see https://github.com/actions/download-artifact/issues/6
      - uses: actions/download-artifact@master
        with:
          name: wheel
          path: release/dist
      - uses: actions/download-artifact@master
        with:
          name: binaries.windows-latest
          path: release/dist
      - uses: actions/download-artifact@master
        with:
          name: binaries.macos-latest
          path: release/dist
      - uses: actions/download-artifact@master
        with:
          name: binaries.ubuntu-16.04
          path: release/dist
      - run: ls release/dist
      - run: pip install tox
      - run: tox -e cibuild -- upload