-
Notifications
You must be signed in to change notification settings - Fork 5
/
{{cookiecutter._ci_name}}.yaml
180 lines (153 loc) · 5.67 KB
/
{{cookiecutter._ci_name}}.yaml
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
name: GH Actions CI
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
# Weekly tests at midnight on Sundays run on main by default:
# Scheduled workflows run on the latest commit on the default or base branch.
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
- cron: "0 0 * * 0"
concurrency:
# Specific group naming so CI is only cancelled
# within same PR or on merge to main
group: {{ "${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}" }}
cancel-in-progress: true
defaults:
run:
shell: bash {% if cookiecutter.__dependency_source != 'pip' %} -l {0} {% endif %}
jobs:
environment-config:
runs-on: ubuntu-latest
outputs:
stable-python-version: {{ "${{ steps.get-compatible-python.outputs.stable-python }}" }}
python-matrix: {{ "${{ steps.get-compatible-python.outputs.python-versions }}" }}
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- id: get-compatible-python
uses: MDAnalysis/mdanalysis-compatible-python@main
with:
release: "latest"
main-tests:
if: "github.repository == '{{ cookiecutter.github_host_account }}/{{ cookiecutter.repo_name }}'"
needs: environment-config
runs-on: {{ '${{ matrix.os }}' }}
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
python-version: {% raw %}${{ fromJSON(needs.environment-config.outputs.python-matrix) }}{% endraw %}
mdanalysis-version: ["latest", "develop"]
steps:
- uses: actions/checkout@v4
- name: Build information
run: |
uname -a
df -h
ulimit -a
{% if cookiecutter.__dependency_source == 'pip' %}
- name: Set up Python {{ '${{ matrix.python-version }}' }}
uses: actions/setup-python@v4
with:
python-version: {{ '${{ matrix.python-version }}' }}
- name: Install testing dependencies
run: |
python -m pip install -U pytest pytest-xdist pytest-cov codecov
{% else %}
# More info on options: https://github.com/conda-incubator/setup-miniconda
- name: Install conda dependencies
uses: conda-incubator/setup-miniconda@v2
with:
python-version: {{ '${{ matrix.python-version }}' }}
environment-file: devtools/conda-envs/test_env.yaml
add-pip-as-python-dependency: true
architecture: x64
{% if cookiecutter.__dependency_source == 'conda-forge' %}
miniforge-variant: Mambaforge
use-mamba: true
channels: conda-forge, defaults
{% elif cookiecutter.__dependency_source == 'anaconda' %}
channels: defaults
{% endif %}
activate-environment: {{cookiecutter.repo_name}}-test
auto-update-conda: true
auto-activate-base: false
show-channel-urls: true
{% endif %}
- name: Install MDAnalysis version
uses: MDAnalysis/install-mdanalysis@main
with:
version: {{ "${{ matrix.mdanalysis-version }}" }}
install-tests: false
installer: {% if cookiecutter.__dependency_source == 'conda-forge' %} mamba {% else %} pip {% endif %}
shell: bash {% if cookiecutter.__dependency_source != 'pip' %} -l {0} {% endif %}
- name: Install package
run: |
python --version
python -m pip install . {% if cookiecutter.__dependency_source != 'pip' %} --no-deps {% endif %}
- name: Python information
run: |
which python
which pip
pip list
{% if cookiecutter.__dependency_source != 'pip' %}
conda info
conda list
{% endif %}
- name: Run tests
run: |
pytest -n 2 -v --cov={{ cookiecutter.package_name }} --cov-report=xml --color=yes {{ cookiecutter.package_name }}/tests/
- name: codecov
if: github.repository == '{{ cookiecutter.github_host_account }}/{{ cookiecutter.repo_name }}' && github.event_name != 'schedule'
uses: codecov/codecov-action@v3
with:
file: coverage.xml
name: codecov-{{ '${{ matrix.os }}' }}-py{{ '${{ matrix.python-version }}' }}
verbose: True
pylint_check:
if: "github.repository == '{{ cookiecutter.github_host_account }}/{{ cookiecutter.repo_name }}'"
needs: environment-config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: {{ '${{ needs.environment-config.outputs.stable-python-version }}' }}
- name: Install Pylint
run: |
which pip
which python
pip install pylint mdanalysis
- name: Run Pylint
env:
PYLINTRC: .pylintrc
run: |
pylint {{ cookiecutter.repo_name }}
pypi_check:
if: "github.repository == '{{ cookiecutter.github_host_account }}/{{ cookiecutter.repo_name }}'"
needs: environment-config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python {{ '${{ needs.environment-config.outputs.stable-python-version }}' }}
uses: actions/setup-python@v4
with:
python-version: {{ '${{ needs.environment-config.outputs.stable-python-version }}' }}
- name: Install dependencies
run: |
pip install pipx twine
- name: Build package
run: |
python -m pipx run build --sdist
- name: Check package build
run: |
DISTRIBUTION=$(ls -t1 dist/{{ cookiecutter.repo_name }}-*.tar.gz | head -n 1)
test -n "${DISTRIBUTION}" || { echo "no distribution dist/{{ cookiecutter.repo_name }}-*.tar.gz found"; exit 1; }
echo "twine check $DISTRIBUTION"
twine check $DISTRIBUTION