-
Notifications
You must be signed in to change notification settings - Fork 31
140 lines (125 loc) · 4.85 KB
/
host_docs.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
name: Host Documentation
on:
# Triggers the workflow on push events but only for the main branch
push:
branches: [ main ]
jobs:
# This job is called test_docs.
build_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Run unit test
run: |
echo ::group:: Set up environment
echo "=============================================================";
echo "Run #${GITHUB_RUN_NUMBER}";
echo "Run ID: ${GITHUB_RUN_ID}";
echo "Testing: ${GITHUB_REPOSITORY}";
echo "Triggered by: ${GITHUB_EVENT_NAME}";
echo "Initiated by: ${GITHUB_ACTOR}";
echo "=============================================================";
echo "=============================================================";
echo "Create conda environment";
echo "=============================================================";
source $CONDA/etc/profile.d/conda.sh;
echo $CONDA/bin >> $GITHUB_PATH;
conda create -n OpenMDAO python=3.8 numpy=1 scipy=1 -q -y;
conda activate OpenMDAO;
pip install --upgrade pip
echo "=============================================================";
echo "Install PETSc";
echo "=============================================================";
conda install -c conda-forge mpi4py petsc4py -q -y;
echo "=============================================================";
echo "Install OpenMDAO";
echo "=============================================================";
cd ..;
pip install testflo;
pip install redbaron
git clone -q https://github.com/OpenMDAO/OpenMDAO;
cd OpenMDAO;
pip install .[all];
cd ../mphys;
pip install -e .[all];
echo "=============================================================";
echo "List installed packages/versions";
echo "=============================================================";
conda list;
echo ::endgroup::
echo ::group:: Run the unit tests
cd tests/unit_tests
testflo
cd ../../
echo ::endgroup::
echo ::group:: Initialize various paths
repo_dir=$GITHUB_WORKSPACE
doc_dir=$repo_dir/docs
echo Workspace: $GITHUB_WORKSPACE
echo Repository: $repo_dir
echo Documentation: $doc_dir
echo ::endgroup::
echo ::group:: Installing Sphinx
echo Installing sphinx via pip
pip3 install -U sphinx
echo Adding user bin to system path
PATH=$HOME/.local/bin:$PATH
if ! command -v sphinx-build &>/dev/null; then
echo Sphinx is not successfully installed
exit 1
else
echo Everything goes well
fi
echo ::endgroup::
echo ::group:: Creating temp directory
tmp_dir=$(mktemp -d -t pages-XXXXXXXXXX)
echo Temp directory \"$tmp_dir\" is created
echo ::endgroup::
echo ::group:: Running Sphinx builder
cd docs
make html
mv _build/html/* $tmp_dir
echo ::endgroup::
echo ::group:: Setting up git repository
echo Setting up git configure
cd $repo_dir
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git stash
INPUT_TARGET_BRANCH=gh-pages
echo Setting up branch $INPUT_TARGET_BRANCH
branch_exist=$(git ls-remote --heads origin refs/heads/$INPUT_TARGET_BRANCH)
if [ -z "$branch_exist" ]; then
echo Branch doesn\'t exist, create an empty branch
git checkout --force --orphan $INPUT_TARGET_BRANCH
else
echo Branch exists, checkout to it
git checkout --force $INPUT_TARGET_BRANCH
fi
git clean -fd
echo ::endgroup::
echo ::group:: Committing HTML documentation
cd $repo_dir
echo Deleting all file in repository
cp -r .git $tmp_dir
rm -vrf ..?* .[!.]* *
echo Copying HTML documentation to repository
cp -r $tmp_dir/.git .
cp -vr $tmp_dir/* .
touch .nojekyll
echo Adding HTML documentation to repository index
git add .
git status
echo Recording changes to repository
git commit --allow-empty -m "Add changes for $GITHUB_SHA"
echo ::endgroup::
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages