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
|
# Prior to releases, this will run additional stress tests, plus tests for all supported versions of
# the requests library. Expected runtime is upwards of 20mins depending on runner availability,
# which is why these are only run for releases.
name: Deploy
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
pre-release-suffix:
description: 'Version suffix for pre-releases ("a", "b", "rc", etc.)'
required: false
default: 'dev'
pre-release-version:
description: 'Version number for pre-releases; defaults to build number'
required: false
default: ''
env:
LATEST_PY_VERSION: '3.10'
PYTEST_VERBOSE: 'true'
STRESS_TEST_MULTIPLIER: 5
jobs:
# Run tests for all supported requests versions
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
requests-version: [2.22, 2.23, 2.24, 2.25, 2.26, latest]
fail-fast: false
services:
nginx:
image: kennethreitz/httpbin
ports:
- 80:80
steps:
# Set up python + poetry
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1.3
with:
version: 1.2.0b1
virtualenvs-in-project: true
# Start integration test databases
- uses: supercharge/mongodb-github-action@1.7.0
with:
mongodb-version: 4.4
- uses: supercharge/redis-github-action@1.4.0
with:
redis-version: 6
- uses: rrainn/dynamodb-action@v2.0.1
# Cache packages per python version, and reuse until lockfile changes
- name: Cache python packages
id: cache
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ matrix.requests-version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
poetry add requests@${{ matrix.requests-version }} --lock
poetry install -v -E all
# Run unit + integration tests, with additional stress tests
- name: Run tests
run: |
source $VENV
nox -e test-current
nox -e stress -- ${{ env.STRESS_TEST_MULTIPLIER }}
# Run unit tests without any optional dependencies installed
test-minimum-deps:
runs-on: ubuntu-latest
steps:
# Set up python + poetry
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ env.LATEST_PY_VERSION }}
- uses: snok/install-poetry@v1.3
with:
version: 1.2.0b1
virtualenvs-in-project: true
# Cache packages per python version, and reuse until lockfile changes
- name: Cache python packages
id: cache
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ matrix.python-version }}-latest-minimum-deps-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install -v
- name: Run unit tests with no optional dependencies
run: |
source $VENV
pytest -n auto tests/unit
# Deploy stable builds on tags only, and pre-release builds from manual trigger ("workflow_dispatch")
release:
needs: [test, test-minimum-deps]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ env.LATEST_PY_VERSION }}
- uses: snok/install-poetry@v1.3
with:
version: 1.2.0b1
virtualenvs-in-project: true
- name: Set pre-release version
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
env:
pre-release-suffix: ${{ github.event.inputs.pre-release-suffix || 'dev' }}
pre-release-version: ${{ github.event.inputs.pre-release-version || github.run_number }}
run: |
poetry version $(poetry version -s).${{ env.pre-release-suffix }}${{ env.pre-release-version }}
poetry version
- name: Build and publish to pypi
run: |
poetry build
poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }}
|