-
Notifications
You must be signed in to change notification settings - Fork 7
120 lines (97 loc) · 3.3 KB
/
build.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
name: Python CI
# Push tests pushes; PR tests merges
on: [ push, pull_request ]
defaults:
run:
shell: bash
jobs:
# Test the build
test:
# Setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ 3.7, 3.8, 3.9, '3.10' ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
# Go
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Env
run: |
echo "Event name: ${{ github.event_name }}"
echo "Git ref: ${{ github.ref }}"
echo "GH actor: ${{ github.actor }}"
echo "SHA: ${{ github.sha }}"
VER=`python --version`; echo "Python ver: $VER"
echo "OS ver: ${{ runner.os }}"
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v3
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ matrix.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('**/Pipfile') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.python-version }}-pip-
- name: Install dependencies
run: |
pip install pipenv
pipenv install --dev
- name: Run black --check .
run: |
pipenv run black --check .
- name: Test with pytest
run: |
pipenv run python -m pytest --cov=arc --cov-report=term
# --cov-fail-under=51 --cov-report=html:output/coverage
- name: Notify
uses: sarisia/actions-status-discord@v1
# Only fire alert once
if: github.ref == 'refs/heads/main' && failure() && matrix.python-version == '3.7' && matrix.os == 'ubuntu-latest'
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "build and test"
color: 0x222222
username: GitHub Actions
# ----- Only git tag testing + package publishing beyond this point ----- #
# Publish to PyPi
publish:
needs: test
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
# Mandatory for trusted publishing to PyPi
permissions:
contents: read
id-token: write
# Go
steps:
- name: Check out repo
uses: actions/checkout@v3
with:
# Without this git tags won't be pulled, and setuptools_scm will forever try to publish version 0.1.dev1
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Generate PyPI readme
run: python ./scripts/generate-pypi-readme.py
- name: Install pypa/build
run: python -m pip install -U build
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: Publish package distributions to Test PyPI
if: github.ref == 'refs/heads/main'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish package distributions to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1