-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (98 loc) · 3.18 KB
/
Docs.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
name: Docs
on:
push:
branches:
- "main"
tags:
- v*
pull_request:
branches:
- "main"
jobs:
build_and_deploy_docs:
name: Documentation Building and Deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: devtools/conda-envs/docs_env.yaml
environment-name: docs
create-args: >-
python=3.11
openmm>=8.1
- name: Install package
shell: bash -l {0}
run: |
micromamba install -y -c mdtools openmm-cpp-forces
python -m pip install . --no-deps
micromamba list
- name: Build Documentation
shell: bash -l {0}
run: |
if [ "$GITHUB_EVENT_NAME" == "push" ] && [ "$GITHUB_REF_TYPE" == "tag" ]; then
export CVPACK_VERSION=${{ github.ref_name }}
else
export CVPACK_VERSION=dev
fi
sphinx-build ./docs ./html
- name: Run tests
shell: bash -l {0}
run: |
pytest
- name: Get coverage report
id: coverage
shell: bash -l {0}
run: |
COVERAGE=$(coverage report | tail -1 | awk '{print $4}')
OFFSET=$(((${COVERAGE::-1}-35)/6-1))
[[ $OFFSET < 0 ]] && OFFSET=0
PALETTE="000111222333"
CODE=${PALETTE:$OFFSET:3}
COLOR=$(echo $CODE | sed -e "s/0/red,/g; s/1/orange,/g; s/2/yellow,/g; s/3/green,/g; s/,$//")
echo "coverage=${COVERAGE}" | tee -a "${GITHUB_OUTPUT}"
echo "color=${COLOR}" | tee -a "${GITHUB_OUTPUT}"
- name: Generate coverage badge
uses: emibcn/badge-action@v2.0.2
with:
label: 'Coverage'
label-color: 'black'
status: ${{ steps.coverage.outputs.coverage }}
color: ${{ steps.coverage.outputs.color }}
path: 'htmlcov/coverage.svg'
- name: Deploy documentation
shell: bash -l {0}
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
echo "Deployment is deactivated on pull requests"
exit 0
elif [ "$GITHUB_REF_TYPE" == "tag" ]; then
subdirs=(${{ github.ref_name }} latest)
else
subdirs=(development)
fi
git reset --hard HEAD
set -x
echo "::group::Push page to gh-pages branch"
git config user.name "$(git show --format=%an -s)"
git config user.email "$(git show --format=%ae -s)"
git fetch origin
git switch gh-pages
for subdir in ${subdirs[@]}; do
dir=docs/$subdir
rsync -va --delete-excluded html/ $dir/
rsync -va --delete-excluded htmlcov/ $dir/coverage/
git add -f $dir/*
done
touch docs/.nojekyll
git commit -m "Docs from $GITHUB_REF $GITHUB_SHA" || echo "Branch is up to date"
git push -f origin gh-pages
echo "::endgroup::"