-
Notifications
You must be signed in to change notification settings - Fork 20
184 lines (154 loc) · 5.79 KB
/
ci-test.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
name: CI-Test
on:
push:
pull_request:
workflow_dispatch:
release:
types: [published, created]
jobs:
lint:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
test:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
name: Tests
runs-on: ${{ matrix.host-os }}
needs: lint
strategy:
matrix:
# host-os: ["ubuntu-latest", "macos-13", "macos-14"]
host-os: ["ubuntu-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
fail-fast: false
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Set env vars
run: |
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/} # just the repo, as opposed to org/repo
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV
python_version="${{ matrix.python-version }}"
export PYTHON_VERSION_NODOT="${python_version//\./}"
echo "PYTHON_VERSION_NODOT=${PYTHON_VERSION_NODOT}" >> $GITHUB_ENV
- name: Set MacOS Deployment Target
if: runner.os == 'macOS'
run: |
export MACOSX_DEPLOYMENT_TARGET="10.15"
echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" >> $GITHUB_ENV
- name: Install micromamba with build dependencies
uses: mamba-org/setup-micromamba@v1
# if: runner.os == 'macOS'
with:
init-shell: bash
environment-name: build-env
create-args: >-
python=${{ matrix.python-version }}
arpack=*=mpi_openmpi*
gfortran
openmpi=4
# - name: Set up Python ${{ matrix.python-version }}
# # if: matrix.host-os != 'macos-latest'
# if: runner.os != 'macOS'
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
- name: Install MacOS dependencies
if: runner.os == 'macOS'
run: |
set -vxeuo pipefail
brew install tree
# python -m pip install delocate
- name: Install dependencies
run: |
set -vxeuo pipefail
bash ./scripts/install-deps.sh
tree .
ls -Al .
ls -Al ./dist/
# - name: Delocate wheels for MacOS
# if: runner.os == 'macOS'
# run: |
# set -vxeuo pipefail
# delocate-wheelpython -v ./dist/${{ env.REPOSITORY_NAME }}-*-cp${PYTHON_VERSION_NODOT}*.whl
- uses: actions/upload-artifact@v3
with:
name: ${{ env.REPOSITORY_NAME }}-wheels
path: dist/*
- name: Test with pytest
run: |
set -vxeuo pipefail
bash ./scripts/run-tests.sh
- name: Build Docs
run: |
set -vxeuo pipefail
bash ./scripts/build-docs.sh
- uses: actions/upload-artifact@v4
with:
name: ${{ env.REPOSITORY_NAME }}-${{ matrix.python-version }}-${{ matrix.host-os }}-docs
path: docs/build/html/
publish-docs:
if: github.repository_owner == 'NSLS-II' && github.ref == 'refs/heads/master'
name: Publish docs
needs: test
runs-on: ${{ matrix.host-os }}
strategy:
matrix:
python-version: ["3.10"]
host-os: ["ubuntu-latest"]
fail-fast: false
steps:
- name: Set env vars
run: |
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/} # just the repo, as opposed to org/repo
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV
- name: Download docs from GitHub artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.REPOSITORY_NAME }}-${{ matrix.python-version }}-${{ matrix.host-os }}-docs
path: docs/build/html/
- name: Deploy documentation to nsls-ii.github.io
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
with:
deploy_key: ${{ secrets.ACTIONS_DOCUMENTATION_DEPLOY_KEY }}
publish_branch: master
publish_dir: ./docs/build/html
external_repository: NSLS-II/NSLS-II.github.io
destination_dir: ${{ env.REPOSITORY_NAME }} # just the repo name, without the "NSLS-II/"
keep_files: true # Keep old files.
force_orphan: false # Keep git history.
publish-to-pypi:
# Hints from:
# - https://github.com/pypa/gh-action-pypi-publish/discussions/28
# - https://github.com/Lightning-AI/lightning/blob/master/.github/workflows/release-pypi.yml
if: github.event_name == 'release'
name: Publish to PyPI
needs: test
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Set env vars
run: |
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/} # just the repo, as opposed to org/repo
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Download wheels from GitHub artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.REPOSITORY_NAME }}-wheels
path: dist/
- name: Publish wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./dist/