1+ name : CI_CD
2+
3+ on : [push, pull_request]
4+
5+ permissions : {}
6+ jobs :
7+ Unit_tests :
8+ runs-on : ${{ matrix.os }}
9+ timeout-minutes : 10
10+ strategy :
11+ fail-fast : false
12+ matrix :
13+ python-version : [
14+ " 2.7" ,
15+ " 3.7" , "3.8", "3.9", "3.10", "3.11-dev",
16+ " pypy-2.7" , "pypy-3.8"
17+ ]
18+ os : [ubuntu-latest, macOS-latest, windows-latest]
19+
20+ steps :
21+ - uses : actions/checkout@v3
22+ - name : Set up Python ${{ matrix.python-version }}
23+ uses : actions/setup-python@v4
24+ with :
25+ python-version : ${{ matrix.python-version }}
26+ - name : Install dependencies
27+ run : |
28+ pip install -r test-requirements.txt -r requirements.txt
29+ - name : Run tests
30+ run : |
31+ pytest
32+
33+ Integration_tests :
34+ runs-on : ${{ matrix.os }}
35+ timeout-minutes : 10
36+ needs : Unit_tests
37+ strategy :
38+ fail-fast : false
39+ matrix :
40+ python-version : [
41+ " 3.10" ,
42+ ]
43+ os : [ubuntu-latest, macOS-latest, windows-latest]
44+ steps :
45+ - uses : actions/checkout@v3
46+ - name : Set up Python ${{ matrix.python-version }}
47+ uses : actions/setup-python@v4
48+ with :
49+ python-version : ${{ matrix.python-version }}
50+ - name : Install dependencies
51+ run : |
52+ pip install -r test-requirements.txt -r requirements.txt
53+ - name : Run tests
54+ env :
55+ TINIFY_KEY : ${{ secrets.TINIFY_KEY }}
56+ run : |
57+ pytest test/integration.py
58+
59+ Publish :
60+ if : |
61+ github.repository == 'tinify/tinify-python' &&
62+ startsWith(github.ref, 'refs/tags') &&
63+ github.event_name == 'push'
64+ timeout-minutes : 10
65+ needs : [Unit_tests, Integration_tests]
66+ runs-on : ubuntu-latest
67+ steps :
68+ - uses : actions/checkout@v3
69+ with :
70+ fetch-depth : 0
71+ persist-credentials : false
72+ - name : Set up Python
73+ uses : actions/setup-python@v4
74+ with :
75+ python-version : " 3.10"
76+ - name : Install dependencies
77+ run : |
78+ pip install -r requirements.txt
79+ pip install build wheel
80+ - name : Build package (sdist & wheel)
81+ run : |
82+ python -m build --sdist --wheel --outdir dist/
83+ - name : Test sdist install
84+ run : |
85+ python -m venv sdist_env
86+ ./sdist_env/bin/pip install dist/tinify*.tar.gz
87+ - name : Test wheel install
88+ run : |
89+ python -m venv wheel_env
90+ ./wheel_env/bin/pip install dist/tinify*.whl
91+ - name : Publish package to PyPI
92+ uses : pypa/gh-action-pypi-publish@master
93+ with :
94+ user : __token__
95+ password : ${{ secrets.PYPI_ACCESS_TOKEN }}
96+ # Use the test repository for testing the publish feature
97+ # repository_url: https://test.pypi.org/legacy/
98+ packages_dir : dist/
99+ print_hash : true
100+
0 commit comments