Dashboard build and publish #201
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
name: Dashboard build and publish | |
on: | |
workflow_dispatch: | |
workflow_call: | |
# Allow only one concurrent workflow, skipping runs queued between the run | |
# in-progress and latest queued. And cancel in-progress runs. | |
concurrency: | |
group: | |
${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
# Set the environment variables to be used in all jobs defined in this workflow | |
env: | |
CI_BRANCH: ${{ github.head_ref || github.ref_name }} | |
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | |
DEVELOP_BRANCH: develop | |
REPO_OWNER: ${{ github.repository_owner }} | |
REPO_NAME: ${{ github.event.repository.name }} | |
jobs: | |
dashboard: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
with: | |
fetch-depth: 0 | |
- name: Set up pixi | |
uses: prefix-dev/[email protected] | |
with: | |
environments: default | |
activate-environment: default | |
run-install: true | |
frozen: true | |
cache: false | |
post-cleanup: false | |
- name: Install and setup development dependencies | |
shell: bash | |
run: | | |
pixi run dev | |
pixi add --pypi --git https://github.com/enhantica/badgery badgery | |
- name: Run docstring coverage and code complexity/maintainability checks | |
run: | | |
for BRANCH in ${{ env.DEFAULT_BRANCH }} ${{ env.DEVELOP_BRANCH }} ${{ env.CI_BRANCH }}; do | |
echo "=== Processing branch $BRANCH ===" | |
if [ -d "../$BRANCH" ]; then | |
echo "Branch $BRANCH already processed, skipping" | |
continue | |
fi | |
git worktree add ../$BRANCH origin/$BRANCH | |
mkdir -p reports/$BRANCH | |
echo "Docstring coverage for branch $BRANCH" | |
pixi run interrogate -c pyproject.toml --fail-under=0 ../$BRANCH/src > reports/$BRANCH/coverage-docstring.txt | |
echo "Cyclomatic complexity for branch $BRANCH" | |
pixi run radon cc -s -j ../$BRANCH/src > reports/$BRANCH/cyclomatic-complexity.json | |
echo "Maintainability index for branch $BRANCH" | |
pixi run radon mi -j ../$BRANCH/src > reports/$BRANCH/maintainability-index.json | |
echo "Raw metrics for branch $BRANCH" | |
pixi run radon raw -s -j ../$BRANCH/src > reports/$BRANCH/raw-metrics.json | |
done | |
- name: Generate dashboard HTML | |
run: > | |
pixi run python -m badgery --config .badgery.yaml --repo ${{ | |
github.repository }} --branch ${{ env.CI_BRANCH }} --output index.html | |
- name: Prepare publish directory | |
run: | | |
mkdir -p _dashboard_publish/${{ env.REPO_NAME }}/${{ env.CI_BRANCH }} | |
cp index.html _dashboard_publish/${{ env.REPO_NAME }}/${{ env.CI_BRANCH }} | |
- name: Publish to main branch of ${{ github.repository }} | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
external_repository: ${{ env.REPO_OWNER }}/dashboard | |
publish_branch: ${{ env.DEFAULT_BRANCH }} | |
personal_token: ${{ secrets.GH_API_PERSONAL_ACCESS_TOKEN }} | |
publish_dir: ./_dashboard_publish | |
keep_files: true | |
- name: Add dashboard link to summary | |
run: | | |
URL="https://${{ env.REPO_OWNER }}.github.io/dashboard/${{ env.REPO_NAME }}/${{ env.CI_BRANCH }}" | |
echo "Dashboard link: [$URL]($URL)" >> $GITHUB_STEP_SUMMARY |