forked from Fusion-Power-Plant-Framework/bluemira
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (115 loc) · 4 KB
/
ci.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
name: bluemira_ci
on:
pull_request:
push:
branches:
- develop
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
# FreeCAD and click do not play nicely together, so make sure we're using the
# environment variables that are set in the conda env (this is needed because
# GitHub Actions run in their own shell so conda environment variables don't appear
# to be picked up.
env:
LANG: 'C'
LC_ALL: 'C'
PYTHONIOENCODING: 'utf-8'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout bluemira-private-data
uses: actions/checkout@v4
if: ${{ !github.event.pull_request.head.repo.fork }}
with:
repository: 'Fusion-Power-Plant-Framework/bluemira-private-data'
ssh-key: ${{ secrets.BLUEMIRA_PRIVATE_DATA_DEPLOY_KEY }}
path: './bluemira-private-data'
- name: Move bluemira-private-data
working-directory: "/home/runner/work/"
if: ${{ !github.event.pull_request.head.repo.fork }}
run: |
mv ~/work/bluemira/bluemira/bluemira-private-data ~/work/bluemira/bluemira-private-data
- name: Cache pip
uses: actions/cache@v4
env:
# Increase this value to reset cache if requirements.txt has not changed
PIP_CACHE_NUMBER: 1
with:
path: ~/.cache/pip
key:
${{ runner.os }}-pip-${{ env.PIP_CACHE_NUMBER }}-${{
hashFiles('requirements.txt', 'requirements-develop.txt', 'setup.py') }}
- name: Cache conda
uses: actions/cache@v4
env:
# Increase this value to reset cache if conda/environment.yml has not changed
CONDA_CACHE_NUMBER: 1
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CONDA_CACHE_NUMBER }}-${{
hashFiles(
'conda/environment.yml',
'requirements.txt',
'requirements-develop.txt',
'requirements-conda.txt',
'setup.py'
) }}
- name: Install Environment
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: bluemira
environment-file: conda/environment.yml
miniforge-version: "latest"
use-only-tar-bz2: false
miniforge-variant: Mambaforge
use-mamba: true
- name: Install bluemira
shell: bash -l {0}
run: pip install -U -e .
- name: Freeze conda env
shell: bash -l {0}
run: |
conda env export -n bluemira > bluemira.yml
- uses: actions/upload-artifact@v4
with:
name: bluemira.yml
path: bluemira.yml
- name: Check Code Quality
shell: bash -l {0}
run: |
pre-commit run --all-files
- name: Build Documentation bluemira
shell: bash -l {0}
run: |
sphinx-build -j auto -W documentation/source documentation/build
- name: Run pytest bluemira
shell: bash -l {0}
env:
# Flag to run longrun tests when merging dependency updates
# https://github.com/actions/runner/issues/409#issuecomment-752775072
PYTEST_LONGRUN: ${{ github.event.pull_request.head.ref == 'develop_dependencies' && '--longrun' || '' }}
PYTEST_PRIVATE: ${{ !github.event.pull_request.head.repo.fork && '--private' || '' }}
run: |
export PYTHONPATH="$(pwd)/eudemo"
pytest --cov=bluemira \
--cov-report html:htmlcov_bluemira \
--cov-report xml \
--json-report \
--json-report-indent=3 \
tests eudemo/eudemo_tests --reactor ${PYTEST_PRIVATE} ${PYTEST_LONGRUN}
- name: Upload test report
uses: actions/upload-artifact@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: report-json
path: .report.json
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: ${{ github.ref_name == 'develop' || github.ref_name == 'main' }}