summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: af13c1896bddc7483669c29602808fec283f78e6 (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
213
214
215
216
217
218
219
220
name: CI

on:
  push:
    branches: [main]
    tags:
      # Tags for all potential release numbers till 2030.
      - "2[0-9].[0-3]" # 20.0 -> 29.3
      - "2[0-9].[0-3].[0-9]+" # 20.0.0 -> 29.3.[0-9]+
  pull_request:
  schedule:
    - cron: 0 0 * * MON # Run every Monday at 00:00 UTC

env:
  # The "FORCE_COLOR" variable, when set to 1,
  # tells Nox to colorize itself.
  FORCE_COLOR: "1"

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true

jobs:
  docs:
    name: docs
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
      - run: pip install nox
      - run: nox -s docs

  determine-changes:
    runs-on: ubuntu-latest
    outputs:
      tests: ${{ steps.filter.outputs.tests }}
      vendoring: ${{ steps.filter.outputs.vendoring }}
    steps:
      # For pull requests it's not necessary to checkout the code
      - uses: dorny/paths-filter@v2
        id: filter
        with:
          filters: |
            vendoring:
              # Anything that's touching "vendored code"
              - "src/pip/_vendor/**"
              - "pyproject.toml"
            tests:
              # Anything that's touching code-related stuff
              - ".github/workflows/ci.yml"
              - "src/**"
              - "tests/**"
        if: github.event_name == 'pull_request'

  pre-commit:
    name: pre-commit
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
      - uses: pre-commit/action@v2.0.0
        with:
          extra_args: --all-files --hook-stage=manual

  packaging:
    name: packaging
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
      - name: Set up git credentials
        run: |
          git config --global user.email "pypa-dev@googlegroups.com"
          git config --global user.name "pip"

      - run: pip install nox
      - run: nox -s prepare-release -- 99.9
      - run: nox -s build-release -- 99.9

  vendoring:
    name: vendoring
    runs-on: ubuntu-latest

    needs: [determine-changes]
    if: >-
      needs.determine-changes.outputs.vendoring == 'true' ||
      github.event_name != 'pull_request'

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2

      - run: pip install nox
      - run: nox -s vendoring
      - run: git diff --exit-code

  tests-unix:
    name: tests / ${{ matrix.python }} / ${{ matrix.os }}
    runs-on: ${{ matrix.os }}-latest

    needs: [pre-commit, packaging, determine-changes]
    if: >-
      needs.determine-changes.outputs.tests == 'true' ||
      github.event_name != 'pull_request'

    strategy:
      fail-fast: true
      matrix:
        os: [Ubuntu, MacOS]
        python:
          - 3.7
          - 3.8
          - 3.9
          - "3.10"

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

      - name: Install Ubuntu dependencies
        if: matrix.os == 'Ubuntu'
        run: sudo apt-get install bzr

      - name: Install MacOS dependencies
        if: matrix.os == 'MacOS'
        run: brew install bzr

      - run: pip install nox 'virtualenv<20'

      # Main check
      - name: Run unit tests
        run: >-
          nox -s test-${{ matrix.python }} --
          -m unit
          --verbose --numprocesses auto --showlocals
      - name: Run integration tests
        run: >-
          nox -s test-${{ matrix.python }} --
          -m integration
          --verbose --numprocesses auto --showlocals
          --durations=5

  tests-windows:
    name: tests / ${{ matrix.python }} / ${{ matrix.os }} / ${{ matrix.group }}
    runs-on: ${{ matrix.os }}-latest

    needs: [pre-commit, packaging, determine-changes]
    if: >-
      needs.determine-changes.outputs.tests == 'true' ||
      github.event_name != 'pull_request'

    strategy:
      fail-fast: true
      matrix:
        os: [Windows]
        python:
          - 3.7
          # Commented out, since Windows tests are expensively slow.
          # - 3.8
          # - 3.9
          - "3.10"
        group: [1, 2]

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

      # We use a RAMDisk on Windows, since filesystem IO is a big slowdown
      # for our tests.
      - name: Create a RAMDisk
        run: ./tools/ci/New-RAMDisk.ps1 -Drive R -Size 1GB

      - name: Setup RAMDisk permissions
        run: |
          mkdir R:\Temp
          $acl = Get-Acl "R:\Temp"
          $rule = New-Object System.Security.AccessControl.FileSystemAccessRule(
              "Everyone", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow"
          )
          $acl.AddAccessRule($rule)
          Set-Acl "R:\Temp" $acl

      - run: pip install nox 'virtualenv<20'
        env:
          TEMP: "R:\\Temp"

      # Main check
      - name: Run unit tests
        if: matrix.group == 1
        run: >-
          nox -s test-${{ matrix.python }} --
          -m unit
          --verbose --numprocesses auto --showlocals
        env:
          TEMP: "R:\\Temp"

      - name: Run integration tests (group 1)
        if: matrix.group == 1
        run: >-
          nox -s test-${{ matrix.python }} --
          -m integration -k "not test_install"
          --verbose --numprocesses auto --showlocals
        env:
          TEMP: "R:\\Temp"

      - name: Run integration tests (group 2)
        if: matrix.group == 2
        run: >-
          nox -s test-${{ matrix.python }} --
          -m integration -k "test_install"
          --verbose --numprocesses auto --showlocals
        env:
          TEMP: "R:\\Temp"