Documentation updates #4
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: Pull Request | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
# These are needed because secrets can not be used in 'if' expressions | |
env: | |
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
TEST_PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }} | |
RTD_WEBHOOK_URL: ${{ secrets.RTD_WEBHOOK_URL }} | |
RTD_WEBHOOK_TOKEN: ${{ secrets.RTD_WEBHOOK_TOKEN }} | |
jobs: | |
# Useful for workflow debugging | |
# printJob: | |
# name: Print event | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Dump GitHub context | |
# env: | |
# GITHUB_CONTEXT: ${{ toJson(github) }} | |
# run: | | |
# echo "$GITHUB_CONTEXT" | |
check_configuration: | |
name: Check for service configuration secrets | |
runs-on: ubuntu-latest | |
steps: | |
# Report on which services are configured | |
- name: Read the Docs URL | |
if: "!(env.RTD_WEBHOOK_URL)" | |
run: echo "::warning title=RTD_WEBHOOK_URL not set::Read the Docs functionality not enabled. Add RTD_WEBHOOK_URL to your repo secrets if you want it enabled." | |
- name: Read the Docs Token | |
if: "!(env.RTD_WEBHOOK_TOKEN)" | |
run: echo "::warning title=RTD_WEBHOOK_TOKEN not set::Read the Docs functionality not enabled. Add RTD_WEBHOOK_TOKEN to your repo secrets if you want it enabled." | |
- name: test.PyPI Token | |
if: "!(env.TEST_PYPI_TOKEN)" | |
run: echo "::warning title=TEST_PYPI_TOKEN not Set::PyPI functionality not enabled. Add PYPI_TOKEN to your repo secrets if you want it enabled." | |
- name: test.PyPI Token | |
if: "!(env.TEST_PYPI_TOKEN)" | |
run: echo "::warning title=TEST_PYPI_TOKEN not Set::test.PyPI functionality not enabled. Add TEST_PYPI_TOKEN to your repo secrets if you want it enabled." | |
run_tests: | |
name: Run all build and unit tests | |
runs-on: ubuntu-latest | |
steps: | |
# Clone the base template | |
- name: Clone base template | |
uses: actions/checkout@v3 | |
with: | |
repository: 'ADACS-Australia/adacs_template_python_base' | |
path: __adacs_template_python_base | |
# Set the path where the base template will be stored and move it there | |
- name: Set temporary path | |
run: echo "TEMP_DIR=$(mktemp -d)" >> $GITHUB_ENV | |
- name: Move base template | |
run: mv __adacs_template_python_base $TEMP_DIR | |
- name: Set path to new base template location | |
run: echo "BASE_TEMPLATE_PATH=$(echo $TEMP_DIR/__adacs_template_python_base )" >> $GITHUB_ENV | |
# Set-up dependencies | |
- name: Check-out repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Needed for tags to be fetched; see https://github.com/actions/checkout/issues/290 | |
# Uncomment if you need mpi | |
# - name: Set-up MPI | |
# uses: mpi4py/setup-mpi@v1 | |
# Uncomment if you need Cuda | |
# - name: Set-up Cuda Toolkit | |
# run: sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc | |
- name: Set-up Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Set-up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'poetry' | |
# Configure project | |
- name: Set project version | |
run: poetry version $(git describe --tags --abbrev=0) | |
# Install the project (we need some of the tools installed here for liniting etc) | |
- name: Install the project | |
run: poetry install --no-interaction --extras "docs dev" | |
# Enforce code formating standards | |
# note: --config is needed to prevent ruff from using a version elsewhere in the project. | |
# This is important for template projects, for example. | |
- name: Enforce linting | |
run: poetry run ruff check --config pyproject.toml . | |
- name: Enforce formating | |
run: poetry run black . | |
# Make sure the Poetry project is properly maintained | |
- name: Enforce maintainance of Poetry project | |
run: | | |
poetry check | |
poetry lock --check | |
# Set-up some dummy git credentials so the tests (which use git) will run | |
- name: Set-up git credentials | |
run: | | |
git config --global user.email "git@user.org" | |
git config --global user.name "Git, User" | |
# Run tests | |
- name: Generate build | |
run: poetry build | |
- name: Code tests | |
run: poetry run pytest | |
- name: Documentation build test | |
run: poetry run make -f docs/Makefile docs | |