Documentation #584
This file contains hidden or 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
| --- | |
| # Does include the PyPi badge | |
| ##################### | |
| ## GitHub Workflow ## | |
| ##################### | |
| name: Documentation | |
| permissions: | |
| contents: write | |
| on: # yamllint disable-line rule:truthy | |
| workflow_run: | |
| workflows: | |
| - Validation | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| jobs: | |
| ################# | |
| ## Python 3.12 ## | |
| ################# | |
| validate312: | |
| name: Python 3.12 | |
| runs-on: ubuntu-latest | |
| env: | |
| PYTHON: python3 | |
| steps: | |
| # Standard project construction | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: {python-version: '3.12'} | |
| # Additional workflow dependency | |
| - name: Install ImageMagick | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| ghostscript \ | |
| imagemagick \ | |
| libmagickwand-dev | |
| # Standard project construction | |
| - name: Checkout main branch | |
| uses: actions/checkout@v4 | |
| with: | |
| path: main | |
| # Standard project construction | |
| - name: Checkout static branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: static | |
| path: static | |
| # Build the test environment | |
| - name: Build environment | |
| working-directory: main | |
| run: | | |
| pip install enbasics[badges] | |
| make -s venv-create | |
| # Build the test environment | |
| - name: Build environment | |
| working-directory: static | |
| run: mkdir -p badges | |
| # Construct additional content | |
| - name: Build documentation | |
| id: sphinx | |
| working-directory: main | |
| run: | | |
| make -s sphinx | |
| rsync -ltr --delete \ | |
| sphinx/html/ \ | |
| ../static/sphinx/ | |
| # Construct additional content | |
| - name: Cache the information | |
| run: | | |
| FLAKE8="unknown" | |
| PYLINT="unknown" | |
| RUFF="unknown" | |
| MYPY="unknown" | |
| YAMLLINT="unknown" | |
| PYTEST="unknown" | |
| COVERAGE="unknown" | |
| SPHINX="unknown" | |
| if [ -f "static/validate/index.json" ]; then | |
| FLAKE8=$(jq -r '.flake8 // "unknown"' static/validate/index.json) | |
| PYLINT=$(jq -r '.pylint // "unknown"' static/validate/index.json) | |
| RUFF=$(jq -r '.ruff // "unknown"' static/validate/index.json) | |
| MYPY=$(jq -r '.mypy // "unknown"' static/validate/index.json) | |
| YAMLLINT=$(jq -r '.yamllint // "unknown"' static/validate/index.json) | |
| PYTEST=$(jq -r '.pytest // "unknown"' static/validate/index.json) | |
| COVERAGE=$(jq -r '.coverage // "unknown"' static/validate/index.json) | |
| SPHINX=$(jq -r '.sphinx // "unknown"' static/validate/index.json) | |
| fi | |
| echo "flake8=$FLAKE8" >> $GITHUB_ENV | |
| echo "pylint=$PYLINT" >> $GITHUB_ENV | |
| echo "ruff=$RUFF" >> $GITHUB_ENV | |
| echo "mypy=$MYPY" >> $GITHUB_ENV | |
| echo "yamllint=$YAMLLINT" >> $GITHUB_ENV | |
| echo "pytest=$PYTEST" >> $GITHUB_ENV | |
| echo "coverage=$COVERAGE" >> $GITHUB_ENV | |
| echo "sphinx=$SPHINX" >> $GITHUB_ENV | |
| # Construct additional content | |
| - name: Build badge for Flake8 | |
| working-directory: main | |
| run: | | |
| STATUS="${{ env.flake8 }}" | |
| python -m enbasics.execution.badges \ | |
| --output "../static/badges/flake8.png" \ | |
| --label "Flake8" \ | |
| --value "$STATUS" | |
| # Construct additional content | |
| - name: Build badge for Pylint | |
| working-directory: main | |
| run: | | |
| STATUS="${{ env.pylint }}" | |
| python -m enbasics.execution.badges \ | |
| --output "../static/badges/pylint.png" \ | |
| --label "Pylint" \ | |
| --value "$STATUS" | |
| # Construct additional content | |
| - name: Build badge for Ruff | |
| working-directory: main | |
| run: | | |
| STATUS="${{ env.ruff }}" | |
| python -m enbasics.execution.badges \ | |
| --output "../static/badges/ruff.png" \ | |
| --label "Ruff" \ | |
| --value "$STATUS" | |
| # Construct additional content | |
| - name: Build badge for Mypy | |
| working-directory: main | |
| run: | | |
| STATUS="${{ env.mypy }}" | |
| python -m enbasics.execution.badges \ | |
| --output "../static/badges/mypy.png" \ | |
| --label "Mypy" \ | |
| --value "$STATUS" | |
| # Construct additional content | |
| - name: Build badge for YAMLlint | |
| working-directory: main | |
| run: | | |
| STATUS="${{ env.yamllint }}" | |
| python -m enbasics.execution.badges \ | |
| --output "../static/badges/yamllint.png" \ | |
| --label "YAMLlint" \ | |
| --value "$STATUS" | |
| # Construct additional content | |
| - name: Build badge for Pytest | |
| working-directory: main | |
| run: | | |
| STATUS="${{ env.pytest }}" | |
| python -m enbasics.execution.badges \ | |
| --output "../static/badges/pytest.png" \ | |
| --label "Pytest" \ | |
| --value "$STATUS" | |
| # Construct additional content | |
| - name: Build badge for Coverage.py | |
| working-directory: main | |
| run: | | |
| STATUS="${{ env.coverage }}" | |
| python -m enbasics.execution.badges \ | |
| --output "../static/badges/coverage.png" \ | |
| --label "Coverage.py" \ | |
| --value "${STATUS}%" | |
| # Construct additional content | |
| - name: Build badge for Sphinx | |
| working-directory: main | |
| run: | | |
| STATUS="${{ env.sphinx }}" | |
| python -m enbasics.execution.badges \ | |
| --output "../static/badges/sphinx.png" \ | |
| --label "Sphinx" \ | |
| --value "$STATUS" | |
| # Construct additional content | |
| - name: Build badge for PyPi | |
| working-directory: main | |
| run: | | |
| PACKAGE="${GITHUB_REPOSITORY##*/}" | |
| INFO=$(curl -s https://pypi.org/pypi/$PACKAGE/json) | |
| VERSION=$( \ | |
| echo "$INFO" \ | |
| | jq -r '.info.version // "unknown"') | |
| RELEASE=$( \ | |
| echo "$INFO" \ | |
| | jq -r --arg VERSION "$VERSION" \ | |
| '.releases[$VERSION][0].upload_time // "unknown"') | |
| python -m enbasics.execution.badges \ | |
| --output "../static/badges/pypi.png" \ | |
| --label "PyPi" \ | |
| --value "$VERSION" \ | |
| --color "teal" \ | |
| --date "$RELEASE" | |
| # Save content in static branch | |
| - name: Store static content | |
| if: github.ref_name == 'main' | |
| run: | | |
| git config --global \ | |
| user.email "github@workflow" | |
| git config --global \ | |
| user.name "GitHub Workflows" | |
| cd static | |
| git add badges | |
| git add sphinx | |
| if git diff --cached --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m 'Update from workflow' | |
| git push origin static | |
| fi |