Updates testing and linting #18
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docs | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
branches: | |
- "main" | |
jobs: | |
build_and_deploy_docs: | |
name: Documentation Building and Deployment | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
path: cvpack | |
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: | |
micromamba-version: '1.4.3-0' | |
environment-file: cvpack/devtools/conda-envs/docs_env.yaml | |
environment-name: docs | |
create-args: >- | |
python=3.9 | |
- name: Install package | |
shell: bash -l {0} | |
run: | | |
cd cvpack/ | |
python -m pip install . --no-deps | |
micromamba list | |
- name: Build Documentation | |
shell: bash -l {0} | |
run: | | |
cd cvpack/ | |
sphinx-build ./docs ./html | |
- name: Run tests | |
shell: bash -l {0} | |
run: | | |
cd cvpack/ | |
pytest | |
- name: Get coverage report | |
id: coverage | |
shell: bash -l {0} | |
run: | | |
cd cvpack/ | |
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: 'cvpack/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" | |
else | |
cd cvpack/ | |
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 | |
rsync -va --delete-excluded html/ docs/ | |
rsync -va --delete-excluded htmlcov/ docs/coverage/ | |
touch docs/.nojekyll | |
git add -f docs/* | |
git add -f docs/.nojekyll | |
git add -f docs/coverage/* | |
git commit -m "Docs from $GITHUB_REF $GITHUB_SHA" || echo "Branch is up to date" | |
git push -f origin gh-pages | |
echo "::endgroup::" | |
fi |