-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (127 loc) · 4.5 KB
/
build_workflow.yml
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
name: CI/CD Build Workflow
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
CANCEL_OTHERS: true
PATHS_IGNORE: '["**/README.rst", "**/docs/**", "**/ISSUE_TEMPLATE/**", "**/pull_request_template.md", "**/.vscode/**"]'
jobs:
check-jobs-to-skip:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: true
paths_ignore: '["**/README.md", "**/docs/**", "**/ISSUE_TEMPLATE/**", "**/pull_request_template.md", "**/.vscode/**"]'
pre-commit-hooks:
needs: check-jobs-to-skip
if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true' }} || ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Code Repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install and Run Pre-commit
uses: pre-commit/[email protected]
build:
needs: check-jobs-to-skip
if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true' }} || ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Set up Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: "ESMBenchmarkViz_ci"
miniforge-variant: Mambaforge
miniforge-version: latest
environment-file: conda-env/environment.yml
use-mamba: true
mamba-version: "*"
channel-priority: strict
auto-update-conda: true
# Used for refreshing the cache every 24 hours to avoid inconsistencies of package
# versions between the CI pipeline and local installations.
- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Conda
uses: actions/cache@v3
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{
steps.get-date.outputs.today }}-${{
hashFiles('conda-env/environment.yml') }}-${{ env.CACHE_NUMBER}}
env:
# Increase this value to reset cache if conda/environment.yml has not changed in the workflow
CACHE_NUMBER: 0
- name: Install ESMBenchmarkViz
# Source: https://github.com/conda/conda-build/issues/4251#issuecomment-1053460542
run: |
python -m pip install --no-build-isolation --no-deps -e .
- name: Run Tests
run: |
pytest
- name: Run Unit Tests
run: pytest tests
publish-docs:
if: ${{ github.event_name == 'push' }} || ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Cache Conda
uses: actions/cache@v3
env:
# Increase this value to reset cache if conda-env/environment.yml has not changed in the workflow
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('conda-env/environment.yml') }}
- name: Set up Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: "ESMBenchmarkViz_dev"
miniforge-variant: Miniforge3
miniforge-version: latest
environment-file: conda-env/environment.yml
channel-priority: strict
auto-update-conda: true
- name: Install ESMBenchmarkViz
# Source: https://github.com/conda/conda-build/issues/4251#issuecomment-1053460542
run: |
python -m pip install --no-build-isolation --no-deps -e .
- name: Sphinx build
run: |
sphinx-build docs _build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
force_orphan: true