-
Notifications
You must be signed in to change notification settings - Fork 23
132 lines (126 loc) · 3.77 KB
/
ci-cd.yml
File metadata and controls
132 lines (126 loc) · 3.77 KB
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
name: Python CI/CD
on: [push, pull_request]
permissions: {}
jobs:
Unit_tests:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: [
"3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14",
"pypy-2.7", "pypy-3.10"
]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r test-requirements.txt -r requirements.txt
- name: Run tests
run: |
pytest
Mypy:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: [
"3.12"
]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r test-requirements.txt -r requirements.txt
- name: Run tests
run: |
mypy --check tinify
Integration_tests:
if: github.event_name == 'push'
runs-on: ${{ matrix.os }}
timeout-minutes: 10
needs: [Unit_tests, Mypy]
strategy:
fail-fast: false
matrix:
python-version: [
"3.13",
]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r test-requirements.txt -r requirements.txt
- name: Run tests
env:
TINIFY_KEY: ${{ secrets.TINIFY_KEY }}
run: |
pytest test/integration.py
Publish:
if: |
github.repository == 'tinify/tinify-python' &&
startsWith(github.ref, 'refs/tags') &&
github.event_name == 'push'
timeout-minutes: 10
needs: [Unit_tests, Integration_tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.13"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install build wheel
- name: Check if properly tagged
run: |
PACKAGE_VERSION="$(python -c 'from tinify import __version__;print(__version__)')";
CURRENT_TAG="${GITHUB_REF#refs/*/}";
if [[ "${PACKAGE_VERSION}" != "${CURRENT_TAG}" ]]; then
>&2 echo "Tag mismatch"
>&2 echo "Version in tinify/version.py (${PACKAGE_VERSION}) does not match the current tag=${CURRENT_TAG}"
>&2 echo "Skipping deploy"
exit 1;
fi
- name: Build package (sdist & wheel)
run: |
python -m build --sdist --wheel --outdir dist/
- name: Test sdist install
run: |
python -m venv sdist_env
./sdist_env/bin/pip install dist/tinify*.tar.gz
- name: Test wheel install
run: |
python -m venv wheel_env
./wheel_env/bin/pip install dist/tinify*.whl
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_ACCESS_TOKEN }}
# Use the test repository for testing the publish feature
# repository_url: https://test.pypi.org/legacy/
packages_dir: dist/
print_hash: true