-
Notifications
You must be signed in to change notification settings - Fork 2
155 lines (130 loc) · 4.22 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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
# CONDA_ENV_PATH: conda-lock.yml
CONDA_ENV_PATH: .conda-linux-64.lock
MIN_PYTHON_VERSION: 3.12
PYTHON_MODULE_FOLDER: 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',]
paths-ignore: ['docs/**']
push:
branches: ['main', 'crop-cli']
paths-ignore: ['docs/**']
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/lite-action@main
if: always()
pytest:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout Code Repository
uses: actions/checkout@main
- name: Build Conda Environment
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: ${{ env.CONDA_ENV_NAME }}
environment-file: ${{ env.CONDA_ENV_PATH }}
auto-activate-base: false
miniforge-version: latest
use-mamba: true
- name: Run Python Tests
# The first line below may be temporary,
# see this solution:
# https://github.com/pyenv/pyenv/issues/2625
run: |
mamba install libsqlite --force-reinstall
mamba run -n ${{ env.CONDA_ENV_NAME }} --cwd python pytest -m "not darwin and not mount"
shell: bash -el {0}
# - name: Copy test coverage results
# run: |
# cp ${{ 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 }}
docs:
needs: [linter, pytest]
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Download coverage svg
uses: actions/download-artifact@v3
with:
name: coverage-badge
path: ${{ env.GH_PAGE_PATH }}${{ env.COVERAGE_SVG_PATH }}
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
- name: Build Conda Environment
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: ${{ env.CONDA_ENV_NAME }}
environment-file: ${{ env.CONDA_ENV_PATH }}
auto-activate-base: false
miniforge-version: latest
- name: Run `quartodoc`
shell: bash -el {0}
run: |
mamba run -n ${{ env.CONDA_ENV_NAME }} quartodoc build
- name: Install Python and Dependencies
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'
- name: Install gdal and local libraries
run: |
sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install gdal-bin libgdal-dev
pip install ./python
- name: Render and Publish
uses: quarto-dev/quarto-actions/publish@v2
with:
target: gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The below raises a code 137 error on `GitHub` Actions
# docker:
# needs: [linter, pytest]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@main
#
# - name: Build and Test with Root permission
# run: |
# docker compose build jupyter
# docker compose up jupyter --detach
# docker compose exec jupyter bash -c "conda run -n ${{ env.CONDA_ENV_NAME }} --cwd python pytest"
#
# - name: Clean-up
# run: docker compose down