forked from lcmd-epfl/Q-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (119 loc) · 3.9 KB
/
tests-docs.yml
File metadata and controls
154 lines (119 loc) · 3.9 KB
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
name: "Tests and Docs"
# taken from https://github.com/epassaro/cache-conda-envs
# cancel any previous running or pending jobs from the same branch
concurrency:
group: python-package-conda-cache-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
env:
CACHE_NUMBER: 0 # increase to reset cache manually
jobs:
build:
# do not run twice when push to a branch linked to a PR
# https://github.com/orgs/community/discussions/57827
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: bash -el {0}
strategy:
matrix:
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/qstack
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: qstack
- name: Set cache date
run: echo "DATE=$(date +'%Y%m')" >> $GITHUB_ENV
- name: Use env cache
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key: ${{ matrix.label }}-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache
- name: Update environment
run: conda env update -n qstack -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Build C
run: make -C qstack/regression/lib/
- name: Run tests
run: pytest ./tests
# maybe split back into two workflows depending on each other
build-docs:
needs: build
defaults:
run:
shell: bash -el {0}
strategy:
matrix:
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/qstack
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: qstack
- name: Set cache date
run: echo "DATE=$(date +'%Y%m')" >> $GITHUB_ENV
- name: Restore doc env cache
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key: ${{ matrix.label }}-conda-${{ hashFiles('environment.yml') }}-${{ hashFiles('docs/requirements.txt') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache-doc
- name: Restore env cache
if: steps.cache-doc.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: ${{ env.CONDA }}/envs
key: ${{ matrix.label }}-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
fail-on-cache-miss: true
id: cache
- name: Install documentation requirements
if: steps.cache-doc.outputs.cache-hit != 'true'
run: pip install -r docs/requirements.txt
- name: Build documentation src
run: make build-src -C docs/
- name: Build HTML
run: make html -C docs/
- name: Upload artifacts
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
uses: actions/upload-pages-artifact@v3
with:
path: docs/build/html/
deploy:
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: build-docs
runs-on: ubuntu-latest
environment:
name: github-pages
permissions:
pages: write
id-token: write
steps:
- name: Deploy
uses: actions/deploy-pages@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}