-
-
Notifications
You must be signed in to change notification settings - Fork 29
846 lines (814 loc) · 28.1 KB
/
build-test-n-publish.yml
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
name: 🏗 📦 & test & publish
on:
create: # is used for publishing to PyPI and TestPyPI
tags: # any tag regardless of its name, no branches
- >-
**
branches-ignore:
- >-
**
push: # publishes to TestPyPI pushes to the main branch
branches: # any branch but not tag
- >-
**
- >- # NOTE: "branches-ignore" cannot be used with "branches"
!dependabot/**
tags-ignore:
- >-
**
pull_request:
paths-ignore: # NOTE: cannot be combined with "paths"
- docs/**
jobs:
pre-setup:
name: Pre-set global build settings
runs-on: ubuntu-latest
defaults:
run:
shell: python
outputs:
dist_version: ${{ steps.scm_version.outputs.dist_version }}
is_untagged_devel: >-
${{ steps.not_tagged_check.outputs.is_untagged_devel || false }}
is_tagged: ${{ steps.tagged_check.outputs.is_tagged || false }}
profiling_enabled: >-
${{ steps.profiling_check.outputs.profiling_enabled || false }}
cache_key_files: >-
${{ steps.calc_cache_key_files.outputs.files_hash_key }}
steps:
- name: Switch to using Python 3.8 by default
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: >-
Mark the build as non-tagged
${{ github.event.repository.default_branch }} build
id: not_tagged_check
if: >-
github.event_name == 'push' &&
github.ref == format(
'refs/heads/{0}', github.event.repository.default_branch
)
run: >-
print('::set-output name=is_untagged_devel::true')
- name: Mark the build as tagged
id: tagged_check
if: >- # "create" workflows run separately from "push" & "pull_request"
github.event_name == 'create' &&
github.event.ref_type == 'tag'
run: >-
print('::set-output name=is_tagged::true')
- name: Enable profiling of the build
id: profiling_check
if: >-
steps.tagged_check.outputs.is_tagged != 'true'
run: >-
print('::set-output name=profiling_enabled::true')
- name: Check out src from Git
uses: actions/checkout@v2
with:
fetch-depth: >-
${{ steps.tagged_check.outputs.is_tagged == 'true' && 1 || 0 }}
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc_cache_key_py
run: |
from hashlib import sha512
from sys import version
hash = sha512(version.encode()).hexdigest()
print(f'::set-output name=py_hash_key::{hash}')
- name: >-
Calculate dependency files' combined hash value
for use in the cache key
id: calc_cache_key_files
run: |
from hashlib import sha512
hashes_combo = sha512('-'.join((
"${{ hashFiles('setup.cfg') }}",
"${{ hashFiles('tox.ini')}}",
"${{ hashFiles('pyproject.toml') }}",
"${{ hashFiles('.pre-commit-config.yaml') }}",
"${{ hashFiles('pytest.ini') }}",
"${{ hashFiles('requirements-build.*') }}",
"${{ hashFiles('docs/requirements.*') }}",
)).encode()).hexdigest()
print(f'::set-output name=files_hash_key::{hashes_combo}')
- name: Set up pip cache
uses: actions/cache@v2
with:
path: >-
${{
runner.os == 'Linux'
&& '~/.cache/pip'
|| '~/Library/Caches/pip'
}}
key: >-
${{ runner.os }}-pip-${{
steps.calc_cache_key_py.outputs.py_hash_key }}-${{
steps.calc_cache_key_files.outputs.files_hash_key }}
restore-keys: |
${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Drop Git tags from HEAD for non-tag-create events
if: >-
steps.tagged_check.outputs.is_tagged != 'true'
run: >-
git tag --points-at HEAD
|
xargs git tag --delete
shell: bash
- name: Set up versioning prerequisites
run: >-
python -m
pip install
--user
setuptools-scm
shell: bash
- name: Set the current dist version
id: scm_version
run: |
import setuptools_scm
ver = setuptools_scm.get_version(
${{ steps.not_tagged_check.outputs.is_untagged_devel == 'true' && 'local_scheme="no-local-version"' || '' }}
)
print('::set-output name=dist_version::{ver}'.format(ver=ver))
build-bin-macos:
name: 🏗 macOS 📦 for 🐍 ${{ matrix.python-version }}
needs:
- pre-setup
# NOTE: I tried also making wheels for 32-bit runtime but it's
# NOTE: proven to be useless and hard to maintain. Also macOS
# NOTE: Catalina ditched support for 32-bit executables so it
# NOTE: doesn't really make sense to try shimming it.
runs-on: macos-latest
strategy:
matrix:
python-version:
# NOTE: Research on the wheel names / platform tags and how they
# NOTE: are matched under various macOS versions:
# NOTE: https://github.com/MacPython/wiki/wiki/Spinning-wheels
- 3.8
- 2.7
- 3.7
- 3.6
- 3.5
env:
ANSIBLE_PYLIBSSH_TRACING: >-
${{ fromJSON(needs.pre-setup.outputs.profiling_enabled) && 1 || 0 }}
PEP517_ARGS: --binary
PY_COLORS: 1
TOXENV: build-wheels-pip,delocate-macos-wheels,metadata-validation
TOX_PARALLEL_NO_SPINNER: 1
steps:
- name: Patch env context to match docs expectations
run: |
echo "::set-env name=HOME::${HOME}"
- name: >-
Find the download URL for official
CPython distribution from python.org
id: probe-python
run: |
function probe_url() {
local py_ver="$1"
local macos_ver="$2"
[ $(curl -I --write-out '%{http_code}' --silent --output /dev/null "https://www.python.org/ftp/python/${py_ver}/python-${py_ver}-macosx10.${macos_ver}.pkg") == '200' ] && return 0
return 1
}
function find_last_macos_py() {
for macos_ver in 6 9
do
for py_ver in $*
do
>&2 echo Probing py${py_ver} and macosx10.${macos_ver}
# FIXME: Can we set outputs right here?
if probe_url $py_ver $macos_ver
then
>&2 echo "Found pkg: py${py_ver} w/ macosx10.${macos_ver}"
echo "::set-output name=py_ver_long::${py_ver}"
echo "::set-output name=download_url::https://www.python.org/ftp/python/${py_ver}/python-${py_ver}-macosx10.${macos_ver}.pkg"
return 0
fi
done
done
>&2 echo Failed looking up macOS pkg for $*
return 1
}
LONG_VER_SUGGESTIONS=$(git ls-remote --sort -v:refname --tags git://github.com/python/cpython.git "${{ matrix.python-version }}*" "v${{ matrix.python-version }}*" | grep -v '\^{}$' | awk '{print$2}' | sed 's#^refs/tags/##;s#^v##' | grep -v '[abcepr]')
find_last_macos_py ${LONG_VER_SUGGESTIONS}
- name: Install Python from python.org
run: |
INSTALLERS_CACHE="${{env.HOME}}/.github/workflows/.tmp/python-installers"
INSTALLER_PATH="${INSTALLERS_CACHE}/python-${LONG_VER}.pkg"
SHORT_VER=$(echo ${LONG_VER} | awk -F. '{print$1"."$2}')
INSTALL_PATH="/Library/Frameworks/Python.framework/Versions/${SHORT_VER}/bin"
PYTHON_BIN="${INSTALL_PATH}/python${SHORT_VER}"
mkdir -pv "${INSTALLERS_CACHE}"
>&2 echo Downloading "${DOWNLOAD_URL}" into "${INSTALLER_PATH}"...
wget -O "${INSTALLER_PATH}" "${DOWNLOAD_URL}"
sudo installer -verboseR -dumplog -pkg "${INSTALLER_PATH}" -target /
>&2 echo Setting up '$PATH' and a binary output var for Python ${LONG_VER}
echo "::add-path::${INSTALL_PATH}"
echo "::set-output name=binary::${PYTHON_BIN}"
env:
DOWNLOAD_URL: ${{ steps.probe-python.outputs.download_url }}
LONG_VER: ${{ steps.probe-python.outputs.py_ver_long }}
id: install-python
- name: >-
Install certificates for Python ${{ matrix.python-version }}
from python.org, if necessary, by running
'Install Certificates.command'
if: matrix.python-version != 3.5
run: >-
/Applications/Python\ ${{ matrix.python-version }}/Install\ Certificates.command
- name: >-
Install certificates for Python ${{ matrix.python-version }}
from python.org, if necessary, by installing certifi
if: matrix.python-version == 3.5
run: >-
curl https://bootstrap.pypa.io/get-pip.py
|
${{ steps.install-python.outputs.binary }} - 'certifi'
- name: Log official Python dist version from python.org
run: ${{ steps.install-python.outputs.binary }} --version
- name: Install libssh from brew
run: brew install libssh # @0.9.4 # pinning the version does not work
# FIXME: can we pre-build libssh once in a pre-requisite job?
# NOTE: Currently we use a brew-installed libssh build that also
# NOTE: pulls-in openssl@1.1 as well. In the future we may want to
# NOTE: be in control of what and how we build. This is what the
# NOTE: commented out code below is for. Doing own builds may help
# NOTE: us produce a smaller footprint by not building the server-
# NOTE: side APIs. Controlling the supply chain is also safer from
# NOTE: the security perspective. Also, it breaks when brew replaces
# NOTE: the versions.
#- name: Fetch libssh src
# env:
# LIBSSH_VERSION: 0.9.3
# run: >-
# git clone --depth=1
# -b "libssh-${{ env.LIBSSH_VERSION }}"
# https://git.libssh.org/projects/libssh.git
#- name: Make libssh build dir
# run: mkdir -pv build
# working_directory: libssh
#- name: Build libssh
# env:
# CFLAGS: -I/usr/local/opt/openssl/include
# LDFLAGS: -L/usr/local/opt/openssl/lib
# run: |
# cmake ..
# make
# make install/strip
# working_directory: libssh/build
- name: Install tox
run: >-
${{ steps.install-python.outputs.binary }} -m
pip install
--user
tox
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc_cache_key_py
run: |
from __future__ import print_function
from hashlib import sha512
from sys import version, version_info
b_version = version if version_info[0] == 2 else version.encode()
hash = sha512(b_version).hexdigest()
print('::set-output name=py_hash_key::{hash}'.format(hash=hash))
shell: python
- name: Set up pip cache
uses: actions/cache@v2
with:
path: >-
${{
runner.os == 'Linux'
&& '~/.cache/pip'
|| '~/Library/Caches/pip'
}}
key: >-
${{ runner.os }}-pip-${{
steps.calc_cache_key_py.outputs.py_hash_key }}-${{
needs.pre-setup.outputs.cache_key_files }}
restore-keys: |
${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Check out src from Git
uses: actions/checkout@v2
with:
fetch-depth: >-
${{ fromJSON(needs.pre-setup.outputs.is_tagged) && 1 || 0 }}
- name: Drop Git tags from HEAD for non-tag-create events
if: >-
!fromJSON(needs.pre-setup.outputs.is_tagged)
run: >-
git tag --points-at HEAD
|
xargs git tag --delete
shell: bash
- name: Pre-populate tox env
run: ${{ steps.install-python.outputs.binary }} -m tox -p auto --parallel-live -vvvv --notest
- name: Instruct setuptools-scm not to add a local version part
if: fromJSON(needs.pre-setup.outputs.is_untagged_devel)
run: |
echo 'local_scheme = "no-local-version"' >> pyproject.toml
git update-index --assume-unchanged pyproject.toml
- name: Build dist
run: ${{ steps.install-python.outputs.binary }} -m tox -p auto --parallel-live -vvvv -e build-wheels-pip
- name: Bundle external shared libs
run: ${{ steps.install-python.outputs.binary }} -m tox -p auto --parallel-live -vvvv -e delocate-macos-wheels -- dist/*.whl
- name: Verify wheel metadata
run: ${{ steps.install-python.outputs.binary }} -m tox -p auto --parallel-live -vvvv -e metadata-validation
- name: Install pytest and its plugins
run: >-
${{ steps.install-python.outputs.binary }} -m
pip install
--user
pytest pytest-cov pytest-xdist
- name: Install the generated Python wheel distribution
run: >-
${{ steps.install-python.outputs.binary }} -m
pip install
--user
--no-index -f dist
--only-binary ansible-pylibssh
ansible-pylibssh
- name: Run tests using pytest
run: >-
${{ steps.install-python.outputs.binary }}
-m pytest
-m smoke
--no-cov
- name: Store the binary wheel
uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: dist
build-bin-manylinux:
name: 🏗 manylinux 📦 for 🐍 ${{ matrix.manylinux-python-target }}
needs:
- pre-setup
runs-on: ubuntu-latest
strategy:
matrix:
manylinux-python-target:
# NOTE: Must be from this list:
# NOTE: $ podman run -it --rm \
# NOTE: quay.io/pypa/manylinux1_x86_64 \
# NOTE: ls -1 /opt/python
- cp38-cp38
- cp37-cp37m
- cp36-cp36m
- cp35-cp35m
- cp27-cp27mu
- cp27-cp27m
env:
ANSIBLE_PYLIBSSH_TRACING: >-
${{ fromJSON(needs.pre-setup.outputs.profiling_enabled) && 1 || 0 }}
PY_COLORS: 1
TOXENV: build-dists-manylinux,metadata-validation
TOX_PARALLEL_NO_SPINNER: 1
steps:
- name: Switch to using Python 3.8 by default
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc_cache_key_py
run: |
from __future__ import print_function
from hashlib import sha512
from sys import version, version_info
b_version = version if version_info[0] == 2 else version.encode()
hash = sha512(b_version).hexdigest()
print('::set-output name=py_hash_key::{hash}'.format(hash=hash))
shell: python
- name: Set up pip cache
uses: actions/cache@v2
with:
path: >-
${{
runner.os == 'Linux'
&& '~/.cache/pip'
|| '~/Library/Caches/pip'
}}
key: >-
${{ runner.os }}-pip-${{
steps.calc_cache_key_py.outputs.py_hash_key }}-${{
needs.pre-setup.outputs.cache_key_files }}
restore-keys: |
${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: >-
python -m
pip install
--user
tox
- name: Check out src from Git
uses: actions/checkout@v2
with:
fetch-depth: >-
${{ fromJSON(needs.pre-setup.outputs.is_tagged) && 1 || 0 }}
- name: Drop Git tags from HEAD for non-tag-create events
if: >-
!fromJSON(needs.pre-setup.outputs.is_tagged)
run: >-
git tag --points-at HEAD
|
xargs git tag --delete
shell: bash
- name: Pre-populate tox env
run: python -m tox -p auto --parallel-live -vvvv --notest
- name: Instruct setuptools-scm not to add a local version part
if: fromJSON(needs.pre-setup.outputs.is_untagged_devel)
run: |
echo 'local_scheme = "no-local-version"' >> pyproject.toml
git update-index --assume-unchanged pyproject.toml
- name: >-
Build ${{ matrix.manylinux-python-target }} dist
and verify wheel metadata
run: >-
python -m
tox -p auto --parallel-live -vvvv
--
${{ matrix.manylinux-python-target }}
- name: Store ${{ matrix.manylinux-python-target }} binary wheel
uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: dist
build-src:
name: 🏗 an sdist 📦
needs:
- pre-setup
runs-on: ubuntu-latest
env:
ANSIBLE_PYLIBSSH_TRACING: >-
${{ fromJSON(needs.pre-setup.outputs.profiling_enabled) && 1 || 0 }}
PEP517_ARGS: --source
PY_COLORS: 1
TOXENV: build-dists,metadata-validation
TOX_PARALLEL_NO_SPINNER: 1
steps:
- name: Switch to using Python 3.8 by default
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc_cache_key_py
run: |
from __future__ import print_function
from hashlib import sha512
from sys import version, version_info
b_version = version if version_info[0] == 2 else version.encode()
hash = sha512(b_version).hexdigest()
print('::set-output name=py_hash_key::{hash}'.format(hash=hash))
shell: python
- name: Set up pip cache
uses: actions/cache@v2
with:
path: >-
${{
runner.os == 'Linux'
&& '~/.cache/pip'
|| '~/Library/Caches/pip'
}}
key: >-
${{ runner.os }}-pip-${{
steps.calc_cache_key_py.outputs.py_hash_key }}-${{
needs.pre-setup.outputs.cache_key_files }}
restore-keys: |
${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: >-
python -m
pip install
--user
tox
- name: Check out src from Git
uses: actions/checkout@v2
with:
fetch-depth: >-
${{ fromJSON(needs.pre-setup.outputs.is_tagged) && 1 || 0 }}
- name: Drop Git tags from HEAD for non-tag-create events
if: >-
!fromJSON(needs.pre-setup.outputs.is_tagged)
run: >-
git tag --points-at HEAD
|
xargs git tag --delete
shell: bash
- name: Pre-populate tox env
run: python -m tox -p auto --parallel-live -vvvv --notest
- name: Instruct setuptools-scm not to add a local version part
if: fromJSON(needs.pre-setup.outputs.is_untagged_devel)
run: |
echo 'local_scheme = "no-local-version"' >> pyproject.toml
git update-index --assume-unchanged pyproject.toml
- name: Build sdist and verify metadata
run: python -m tox -p auto --parallel-live -vvvv
- name: Store the source distribution
uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: dist
test-matrix:
name: >-
Test 🐍
${{ matrix.python-version }}
${{ matrix.runner-vm-os }}
${{ matrix.dist-type }} dists
needs:
- build-bin-macos
- build-bin-manylinux
- build-src
- pre-setup # transitive, for accessing settings
runs-on: ${{ matrix.runner-vm-os }}
strategy:
matrix:
python-version:
- 3.8
- 2.7
- 3.7
- 3.6
- 3.5
runner-vm-os:
- ubuntu-20.04
- macos-latest
- ubuntu-18.04
- ubuntu-16.04
dist-type:
- binary
- source
exclude:
- dist-type: source
runner-vm-os: ubuntu-16.04 # has too old libssh in the repos
- dist-type: source
runner-vm-os: ubuntu-18.04
- dist-type: source
runner-vm-os: ubuntu-20.04 # undefined symbol: ssh_disconnect
env:
ANSIBLE_PYLIBSSH_TRACING: >-
${{ fromJSON(needs.pre-setup.outputs.profiling_enabled) && 1 || 0 }}
PY_COLORS: 1
TOXENV: test-${{ matrix.dist-type }}-dists
TOX_PARALLEL_NO_SPINNER: 1
steps:
- name: Install libssh and openssl headers on Linux
if: >-
matrix.dist-type == 'source' &&
runner.os == 'Linux'
run: sudo apt update && sudo apt install libssh-dev libssl-dev build-essential
- name: Install libssh and openssl headers on macOS
if: >-
runner.os == 'macOS'
run: brew install libssh
- name: Install libssh headers on Linux for cythonize+coverage
if: >-
runner.os == 'Linux'
run: sudo add-apt-repository ppa:kedazo/libssh-0.7.x && sudo apt update && sudo apt install libssh-dev
- name: Switch 🐍 to v${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc_cache_key_py
run: |
from __future__ import print_function
from hashlib import sha512
from sys import version, version_info
b_version = version if version_info[0] == 2 else version.encode()
hash = sha512(b_version).hexdigest()
print('::set-output name=py_hash_key::{hash}'.format(hash=hash))
shell: python
- name: Set up pip cache
uses: actions/cache@v2
with:
path: >-
${{
runner.os == 'Linux'
&& '~/.cache/pip'
|| '~/Library/Caches/pip'
}}
key: >-
${{ runner.os }}-pip-${{
steps.calc_cache_key_py.outputs.py_hash_key }}-${{
needs.pre-setup.outputs.cache_key_files }}
restore-keys: |
${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: >-
python -m
pip install
--user
tox
- name: Check out src from Git
uses: actions/checkout@v2
- name: Download all the dists
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: dist/
- name: Pre-populate tox env
run: python -m tox -p auto --parallel-live -vvvv --notest
- name: Configure tox to run pytest under catchsegv
if: runner.os == 'Linux'
run: >-
print("::set-env name=CATCHSEGV_BINARY::catchsegv")
shell: python
- name: Run tests
run: python -m tox -p auto --parallel-live -vvvv
- name: Send coverage data to Codecov
uses: codecov/codecov-action@v1
with:
file: .test-results/pytest/cov.xml
dist-meta:
name: Verify 🐍📦 metadata
needs:
- build-bin-macos
- build-bin-manylinux
- build-src
- pre-setup # transitive, for accessing settings
runs-on: ubuntu-latest
env:
PY_COLORS: 1
TOXENV: metadata-validation
TOX_PARALLEL_NO_SPINNER: 1
steps:
- name: Switch to using Python 3.8 by default
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc_cache_key_py
run: |
from __future__ import print_function
from hashlib import sha512
from sys import version, version_info
b_version = version if version_info[0] == 2 else version.encode()
hash = sha512(b_version).hexdigest()
print('::set-output name=py_hash_key::{hash}'.format(hash=hash))
shell: python
- name: Set up pip cache
uses: actions/cache@v2
with:
path: >-
${{
runner.os == 'Linux'
&& '~/.cache/pip'
|| '~/Library/Caches/pip'
}}
key: >-
${{ runner.os }}-pip-${{
steps.calc_cache_key_py.outputs.py_hash_key }}-${{
needs.pre-setup.outputs.cache_key_files }}
restore-keys: |
${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: >-
python -m
pip install
--user
tox
- name: Check out src from Git
uses: actions/checkout@v2
- name: Pre-populate tox env
run: python -m tox -p auto --parallel-live -vvvv --notest
- name: Download all the dists
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: dist/
- name: Verify metadata
run: python -m tox -p auto --parallel-live -vvvv
deploy:
name: Publish 🐍📦 to (Test)PyPI
needs:
- dist-meta
- pre-setup # transitive, for accessing settings
- test-matrix
if: >-
fromJSON(needs.pre-setup.outputs.is_untagged_devel) ||
fromJSON(needs.pre-setup.outputs.is_tagged)
runs-on: ubuntu-latest
steps:
- name: Download all the dists
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: dist/
- name: Publish 🐍📦 to TestPyPI
if: >-
fromJSON(needs.pre-setup.outputs.is_untagged_devel) ||
fromJSON(needs.pre-setup.outputs.is_tagged)
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.testpypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish 🐍📦 to PyPI
if: fromJSON(needs.pre-setup.outputs.is_tagged)
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
dumb-pypi:
name: Publish nightlies to Dumb PyPI # https://ansible.github.io/pylibssh/
needs:
- dist-meta
- pre-setup # transitive, for accessing settings
- test-matrix
if: >-
fromJSON(needs.pre-setup.outputs.is_untagged_devel) ||
fromJSON(needs.pre-setup.outputs.is_tagged)
runs-on: ubuntu-latest
steps:
- name: Download the recent published versions from TestPyPI
run: >-
python -m
pip download
--index-url https://test.pypi.org/simple/
--dest dist/
--no-deps
--pre
ansible-pylibssh
- name: Download all the dists
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: dist/
- name: Switch to Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc_cache_key_py
run: |
from __future__ import print_function
from hashlib import sha512
from sys import version, version_info
b_version = version if version_info[0] == 2 else version.encode()
hash = sha512(b_version).hexdigest()
print('::set-output name=py_hash_key::{hash}'.format(hash=hash))
shell: python
- name: Set up pip cache
uses: actions/cache@v2
with:
path: >-
${{
runner.os == 'Linux'
&& '~/.cache/pip'
|| '~/Library/Caches/pip'
}}
key: >-
${{ runner.os }}-pip-${{
steps.calc_cache_key_py.outputs.py_hash_key }}-${{
needs.pre-setup.outputs.cache_key_files }}
restore-keys: |
${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dumb-pypi dist from PyPI
run: python -m pip install dumb-pypi --user
- name: Generate a dumb PyPI website
run: |
python -m dumb_pypi.main \
--package-list <(ls dist/) \
--packages-url https://raw.githubusercontent.com/${{ github.repository }}/gh-pages/dist \
--output-dir gh-pages-dumb-pypi
shell: bash
- name: >-
Copy dists from this build and TestPyPI
to the generated dumb PyPI website dir
run: cp -av dist gh-pages-dumb-pypi/
- name: Publish the dumb PyPI website to GH Pages
uses: peaceiris/actions-gh-pages@v3
with:
force_orphan: true
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: gh-pages-dumb-pypi
# TODO: Test install from sdist
#
# TODO: Figure out if we can use Py_LIMITED_API / PEP 384:
# TODO: * https://docs.python.org/3/c-api/stable.html
# TODO: https://github.com/cython/cython/issues/2542