-
Notifications
You must be signed in to change notification settings - Fork 5
181 lines (156 loc) · 5.54 KB
/
gh-ci.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
181
name: Cookiecutter CI
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
schedule:
# weekly tests
- cron: "0 0 * * 0"
defaults:
run:
shell: bash
env:
ARTIFACT_NAME: demo-mdakit-repos
OUTPUT_DIRECTORY: /home/runner/example_outputs
GH_USER: github-actions
GH_EMAIL: "[email protected]"
GH_REPOSITORY: "github.com/${{ github.repository }}.git"
jobs:
cookiecutter-main-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
# check last three versions of Python
last-n-minor-python-release: [2, 1, 0]
steps:
- uses: actions/checkout@v3
- id: get-python-version
uses: MDAnalysis/get-latest-python-version@main
with:
last-n-minor-release: ${{ matrix.last-n-minor-python-release }}
- name: Environment information
run: |
uname -a
df -h
ulimit -a
echo "Using Python ${{ steps.get-python-version.outputs.python-version }}"
- name: Set up Python ${{ steps.get-python-version.outputs.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ steps.get-python-version.outputs.python-version }}
- name: Install dependencies
run: |
python -m pip install -U pytest pyyaml cookiecutter
- name: Run cookiecutter tests
run: |
# --keep-test-outputs also saves the generated repositories
if [[ ${{ matrix.os }} == "ubuntu-latest" ]] ; then
PYTEST_FLAGS="--keep-test-outputs $OUTPUT_DIRECTORY"
else
PYTEST_FLAGS=""
fi
echo "PYTEST_FLAGS=${PYTEST_FLAGS}"
pytest tests/ $PYTEST_FLAGS
- name: Run cookie CI
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: ./.github/actions/run-cookie-ci
with:
source-directory: ${{ env.OUTPUT_DIRECTORY }}/TestMDAKit_with_condaforge-deps_and_ReadTheDocs/mdakit-cookie
- name: Upload artifact
if: ${{ matrix.os == 'ubuntu-latest' && matrix.last-n-minor-python-release == 0 }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.OUTPUT_DIRECTORY }}
retention-days: 3
update-repo-examples:
if: github.event_name != 'pull_request'
needs: cookiecutter-main-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Make output directory
run: mkdir $OUTPUT_DIRECTORY
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.OUTPUT_DIRECTORY }}
- name: Push to cookie repo
uses: ./.github/actions/push-to-cookie
with:
source-directory: ${{ env.OUTPUT_DIRECTORY }}
target-ssh-deploy-key: ${{ secrets.MDAKIT_COOKIE_SSH_DEPLOY_KEY }}
- name: Push to remote
env:
GH_USER: github-actions
GH_EMAIL: "[email protected]"
GH_REPOSITORY: "github.com/${{ github.repository }}.git"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# dynamic vars
BRANCH="${GITHUB_REF#refs/heads/}"
REV=$(git rev-parse --short HEAD)
cd $HOME
mkdir examples
cd examples
# set up git
git init
git config user.name $GH_USER
git config user.email $GH_EMAIL
git remote add upstream "https://${GH_USER}:${GH_TOKEN}@${GH_REPOSITORY}"
git fetch --depth 50 upstream $BRANCH examples
git reset upstream/examples
# update examples
for keep in README.md ; do
if [[ -e $keep ]] ; then
cp $keep ${{ env.OUTPUT_DIRECTORY }}/
fi
done
rm -rf *
mv ${{ env.OUTPUT_DIRECTORY }}/* .
# push back to GitHub
git add .
git diff-index --quiet HEAD -- || git commit -m "rebuilt examples from branch ${BRANCH} with CI at ${REV}"
git push -q upstream HEAD:examples
build_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install conda dependencies
uses: conda-incubator/setup-miniconda@v2
with:
environment-file: docs/requirements.yaml
add-pip-as-python-dependency: true
architecture: x64
miniforge-variant: Mambaforge
use-mamba: true
channels: conda-forge, defaults
activate-environment: cookiecutter-mdakit-docs
auto-update-conda: true
show-channel-urls: true
- name: Build docs
shell: bash -l {0}
working-directory: docs
run: make html
- name: Deploy docs
if: github.event_name != 'pull_request'
working-directory: docs/_build/html
run: |
BRANCH="${GITHUB_REF#refs/heads/}"
REV=$(git rev-parse --short HEAD)
git init
git config user.name $GH_USER
git config user.email $GH_EMAIL
git remote add upstream "https://${GH_USER}:${{ secrets.GITHUB_TOKEN }}@${GH_REPOSITORY}"
git fetch --depth 50 upstream $BRANCH gh-pages
git reset upstream/gh-pages
touch .
touch .nojekyll
git add .
git diff-index --quiet HEAD -- || git commit -m "rebuilt html docs from branch ${BRANCH} with sphinx at ${REV}"
git push -q upstream HEAD:gh-pages