-
Notifications
You must be signed in to change notification settings - Fork 401
139 lines (118 loc) · 4.4 KB
/
check.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
# This GitHub workflow runs on every commit.
name: Pull request checks
on:
pull_request:
jobs:
# Check that source code is black-ified
black:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
name: Checkout repository
- uses: actions/setup-python@v4
name: Setup Python
with:
python-version: 3.9
- name: Install black
run: |
python -m pip install --upgrade pip
pip install black
- name: Run black
run: |
black --check .
# This job is copied over from `deploy.yaml`
build-environment:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
# See: https://github.com/marketplace/actions/setup-conda
- uses: s-weigand/setup-conda@v1
with:
conda-channels: "conda-forge"
# Build cache of environment
- name: Cache conda environment
id: cache-environment
uses: actions/cache@v3
# Conda environment build step depends on two files,
# so we ensure that the hash key contains both their hashes.
with:
path: |
nams.tar.gz
key: ${{ runner.os }}-${{ hashFiles('environment.yml') }}-${{ hashFiles('scripts/ci/build_environment.sh') }}-env
- name: Build environment
if: steps.cache-environment.outputs.cache-hit != 'true'
run: bash scripts/ci/build_environment.sh
# See: https://github.com/actions/upload-artifact
- name: Upload environment
uses: actions/upload-artifact@v3
with:
name: nams-tarball
path: nams.tar.gz
# This job is copied over from `deploy.yaml`
build-deploy-website:
runs-on: ubuntu-22.04
needs: build-environment
steps:
- uses: actions/checkout@v3
# https://github.com/actions/download-artifact
- name: Download environment tarball
uses: actions/download-artifact@v3
with:
name: nams-tarball
- name: Unpack environment and activate it
run: bash scripts/ci/unpack_environment.sh
# Build cache of website
- name: Cache website
id: cache-website
uses: actions/cache@v3
# Website build step depends on the following files:
# - mkdocs.yml
# - scripts/ci/build_website.sh
# - docs/
# - environment.yml
# so we ensure that the hash key contains all of their hashes.
with:
path: |
site
key: ${{ runner.os }}-mkdocs.${{ hashFiles('mkdocs.yml') }}-scripts.${{ hashFiles('scripts/ci/build_website.sh') }}-source.${{ hashFiles('notebooks') }}-env.${{ hashFiles('environment.yml') }}
- name: Build website
if: steps.cache-website.outputs.cache-hit != 'true'
run: |
bash scripts/ci/build_website.sh
# https://www.bradmcgonigle.com/blog/github-action-for-continuous-deployment
# - NETLIFY_SITE_ID maps to the netlify site's API ID
# - NETLIFY_AUTH_TOKEN maps to netlify's Personal Access Token that I set on a per-user basis
- name: Netlify PR preview
uses: netlify/actions/cli@master
with:
args: deploy --site ${{ secrets.NETLIFY_SITE_ID }} --auth ${{ secrets.NETLIFY_AUTH_TOKEN }} --dir=site/
# This job is copied over from `deploy.yaml`
build-deploy-leanpub:
runs-on: ubuntu-22.04
needs: build-environment
steps:
- uses: actions/checkout@v3
- name: Download environment tarball
uses: actions/download-artifact@v3
with:
name: nams-tarball
- name: Unpack environment and activate it
run: bash scripts/ci/unpack_environment.sh
# Build cache of leanpub source
- name: Cache LeanPub
id: cache-leanpub
uses: actions/cache@v3
# Leanpub build step depends on the following files:
# - scripts/bookbuilder
# - scripts/ci/build_website.sh
# - docs
# - environment.yml
# so we ensure that the hash key contains all of their hashes.
with:
path: |
site
key: ${{ runner.os }}-bookbuilder.${{ hashFiles('scripts/bookbuilder') }}-scripts.${{ hashFiles('scripts/ci/build_website.sh') }}-source.${{ hashFiles('notebooks') }}-env.${{ hashFiles('environment.yml') }}
- name: Build leanpub manuscript files
if: steps.cache-leanpub.outputs.cache-hit != 'true'
run: |
bash scripts/ci/build_leanpub.sh