-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (112 loc) · 4.06 KB
/
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
name: CI
# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
CONDA_ENV_NAME: clim-recal
MIN_PYTHON_VERSION: 3.9
PYTHON_MODULE_FOLDER: /home/jovyan/python/
COVERAGE_SVG_FOLDER: docs/assets/
COVERAGE_SVG_FILE_NAME: coverage.svg
# replace below with references to previous config lines
COVERAGE_SVG_PATH: docs/assets/coverage.svg
GH_PAGE_PATH: _gh-page
on:
pull_request:
branches: ['main', 'doc-deploy', 'ruth-notebook-for-workshop', 'r-docker-refactor']
paths-ignore: ['docs/**']
push:
branches: ['main', 'doc-deploy', 'ruth-notebook-for-workshop', 'r-docker-refactor']
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: write
jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@main
- name: Set up Python
uses: actions/setup-python@main
with:
python-version: ${{ env.MIN_PYTHON_VERSION }}
- name: Run pre-commit
uses: pre-commit/action@main
- name: Update pre-commit
uses: pre-commit-ci/[email protected]
if: always()
# With no caching at all the entire ci process takes 4m 30s to complete!
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@main
- name: Build, Test and Save Test Coverage
run: |
docker compose build
docker compose up --detach
docker compose exec jupyter bash -c "conda run -n $CONDA_ENV_NAME --cwd python pytest -p no:sugar"
export JUPYTER_ID=$(docker compose ps -q jupyter)
echo "jupyter_id=$JUPYTER_ID" >> $GITHUB_ENV
echo "jupyter_id=$JUPYTER_ID"
- name: Check accessing saved jupyter_id
run: |
echo ${{ env.jupyter_id }}
- name: Copy test coverage results
run: |
docker cp ${{ env.jupyter_id }}:${{ env.PYTHON_MODULE_FOLDER }}${{ env.COVERAGE_SVG_PATH }} ${{ env.COVERAGE_SVG_FOLDER }}
- name: Archive coverage svg
uses: actions/upload-artifact@v3
with:
name: coverage-badge
path: ${{ env.COVERAGE_SVG_PATH }}
- name: Tear down the Stack
run: docker compose down
docs:
needs: [linter, pytest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download coverage svg
uses: actions/download-artifact@v3
with:
name: coverage-badge
path: ${{ env.GH_PAGE_PATH }}${{ env.COVERAGE_SVG_PATH }}
# Other options for documentation build for future testing outside docker
# - name: Set up conda environment
# uses: conda-incubator/setup-miniconda@v2
# with:
# activate-environment: environment.yml
#
# From https://github.com/r-lib/actions/tree/v2-branch/setup-r
# - name: Setup R
# uses: r-lib/actions/setup-r@v2
# Potentially necessary for future interactive documentation builds following uatk-spc
# - name: Install node
# uses: actions/setup-node@v2
# with:
# node-version: 18.x
# cache: 'npm'
# cache-dependency-path: web/package-lock.json
#
# - name: Build web app
# run: |
# cd web
# npm ci
# npm run build --if-present
# mv dist ../docs/_book/app
- name: Build docker quarto
run: |
# A potentially quicker build option to try in future, requires running in detatched mode
# DOCKER_BUILDKIT=1 docker build --no-cache -f compose/docs/Dockerfile --target builder --tag 'clim-recal-docs' .
docker compose build docs
docker compose up --detach
docker cp $(docker compose ps -q docs):/usr/local/apache2/htdocs/ ${{ env.GH_PAGE_PATH }}
- name: Publish
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.GH_PAGE_PATH }}
keep_files: false