-
Notifications
You must be signed in to change notification settings - Fork 79
104 lines (87 loc) · 3.3 KB
/
code.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
name: Code CI
on:
push:
pull_request:
schedule:
- cron: "00 4 * * *" # daily at 4AM
jobs:
lint:
# pull requests are a duplicate of a branch push if they are from within the
# same repo. Skip these
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- name: Lint
run: pip install --user .[dev] && tox -e pre-commit,mypy
build:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # So we get history for version numbers
- name: Create Sdist and Wheel
# Set SOURCE_DATE_EPOCH from git commit for reproducible build
# https://reproducible-builds.org/
run: SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) pipx run build --sdist --wheel
- name: Upload Wheel and Sdist as artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
- name: Install wheel and check cli works
run: pip install dist/*.whl && python -m ophyd --version
test:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9"]
runs-on: ubuntu-latest
env:
TEST_CL: pyepics
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # So we get history for version number
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install -e .[dev] && pipdeptree
- name: Start IOCs in containers.
run: |
source ${GITHUB_WORKSPACE}/scripts/epics_exports.sh
source ${GITHUB_WORKSPACE}/scripts/epics_docker.sh
- name: Test with pytest
run: pytest -k "${TEST_CL} or /v2/"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
name: ${{ matrix.python }}
files: cov.xml
release:
needs: [build]
runs-on: ubuntu-latest
# upload to PyPI and make a release on every tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/download-artifact@v3
- name: Github Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
with:
files: dist/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
# The PYPI_PASSWORD must be a pypi token with the "pypi-" prefix with sufficient permissions to upload this package
# https://pypi.org/help/#apitoken
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: pipx run twine upload dist/*