-
Notifications
You must be signed in to change notification settings - Fork 3
148 lines (141 loc) · 5.39 KB
/
ci.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
# GitHub Actions configuration **EXAMPLE**,
# MODIFY IT ACCORDING TO YOUR NEEDS!
# Reference: https://docs.github.com/en/actions
name: tests
on:
push:
# Avoid using all the resources/limits available by checking only
# relevant branches and tags. Other branches can be checked via PRs.
branches: [main]
tags: ["v*"] # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request: # Run in every PR
workflow_dispatch: # Allow manually triggering the workflow
schedule:
# Run roughly every 15 days at 00:00 UTC
# (useful to check if updates on dependencies break the package)
- cron: "0 0 1,16 * *"
concurrency:
group: >-
${{ github.workflow }}-${{ github.ref_type }}-
${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
wheel-distribution: ${{ steps.wheel-distribution.outputs.path }}
steps:
- uses: actions/checkout@v2
with: { fetch-depth: 0 } # deep clone for setuptools-scm
- uses: actions/setup-python@v2
with: { python-version: "3.10" }
- name: Lint code
run: pipx run pre-commit run --all-files --show-diff-on-failure
- name: Build package distribution files
run: pipx run tox -e clean,build
- name: Record the path of wheel distribution
id: wheel-distribution
run: echo "::set-output name=path::$(ls dist/*.whl)"
- name: Store the distribution files for use in other stages
# `tests` and `publish` will use the same pre-built distributions,
# so we make sure to release the exact same package that was tested
uses: actions/upload-artifact@v2
with:
name: python-distribution-files
path: dist/
retention-days: 1
test:
needs: prepare
strategy:
matrix:
python:
- 3.7 # oldest Python supported by PSF
- "3.10" # newest Python that is stable
platform:
- ubuntu-latest
# - macos-latest
# - windows-latest
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Retrieve pre-built distribution files
uses: actions/download-artifact@v2
with: { name: python-distribution-files, path: dist/ }
- name: Run tests
run: >-
pipx run tox
--installpkg '${{ needs.prepare.outputs.wheel-distribution }}'
-- -rFEx --durations 10 --color yes
- name: Generate coverage report
run: pipx run coverage lcov -o coverage.lcov
- name: Upload partial coverage report
uses: coverallsapp/github-action@master
with:
path-to-lcov: coverage.lcov
github-token: ${{ secrets.github_token }}
flag-name: ${{ matrix.platform }} - py${{ matrix.python }}
parallel: true
finalize:
needs: test
runs-on: ubuntu-latest
steps:
- name: Finalize coverage report
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
publish:
needs: finalize
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with: { python-version: "3.10" }
- name: Retrieve pre-built distribution files
uses: actions/download-artifact@v2
with: { name: python-distribution-files, path: dist/ }
# - name: Build Changelog
# id: github_release
# uses: mikepenz/release-changelog-builder-action@v3
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Create Release
# uses: softprops/action-gh-release@v1
# with:
# tag_name: ${{ github.ref }}
# name: ${{ github.ref }}
# body: ${{steps.github_release.outputs.changelog}}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: "✏️ Generate release changelog" # updates CHANGELOG.md
# uses: heinrichreimer/[email protected]
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Package
env:
# - https://pypi.org/help/#apitoken
# - https://docs.github.com/en/actions/security-guides/encrypted-secrets
TWINE_REPOSITORY: pypi
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: pipx run tox -e publish
# - name: grayskull
# run: |
# sleep 60s
# pip install grayskull conda-souschef
# python scripts/run_grayskull.py
# - name: Push meta.yaml to `xtal2png-feedstock` fork
# uses: dmnemec/copy_file_to_another_repo_action@main
# env:
# API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
# with:
# source_file: 'xtal2png/meta.yaml'
# destination_repo: 'sparks-baird/xtal2png-feedstock'
# destination_folder: 'recipe'
# user_email: '[email protected]'
# user_name: 'sgbaird'
# commit_message: 'Update meta.yaml based on latest PyPI version as faster version of regro-cf-autotick-bot)'