-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (92 loc) · 4.15 KB
/
dashboard.yml
File metadata and controls
111 lines (92 loc) · 4.15 KB
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
name: Dashboard build and publish
on:
workflow_dispatch:
workflow_call:
permissions:
contents: read
concurrency:
group: dashboard-publish-${{ github.repository }}
cancel-in-progress: false
# 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@v6
with:
fetch-depth: 0
- name: Set up pixi
uses: ./.github/actions/setup-pixi
- name: Install badgery
shell: bash
run: pixi add --pypi --git https://github.com/enhantica/badgery badgery
- name: Run docstring coverage and code complexity/maintainability checks
run: |
for BRANCH in $DEFAULT_BRANCH $DEVELOP_BRANCH $CI_BRANCH; do
echo
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 }}
# Create GitHub App token for pushing to external dashboard repo.
# The 'repositories' parameter is required to grant access to repos
# other than the one where the workflow is running.
- name: Setup easyscience[bot]
id: bot
uses: ./.github/actions/setup-easyscience-bot
with:
app-id: ${{ vars.EASYSCIENCE_APP_ID }}
private-key: ${{ secrets.EASYSCIENCE_APP_KEY }}
repositories: |
${{ github.event.repository.name }}
dashboard
# Push to external dashboard repository with retry logic.
# Retry is needed to handle transient GitHub API/authentication issues
# that occasionally cause 403 errors when multiple workflows push concurrently.
# Uses personal_token (not github_token) as GITHUB_TOKEN cannot access external repos.
- name:
Push to ${{ env.REPO_OWNER }}/dashboard/${{ env.REPO_NAME }}/${{ env.CI_BRANCH
}}
shell: bash
env:
DASHBOARD_COMMIT_MESSAGE: ${{ env.CI_BRANCH }}
DASHBOARD_GIT_USER_EMAIL:
${{ vars.EASYSCIENCE_APP_ID }}+easyscience[bot]@users.noreply.github.com
DASHBOARD_PUSH_ATTEMPTS: '3'
DASHBOARD_PUSH_DELAY_SECONDS: '15'
DASHBOARD_PUBLISH_BRANCH: master
DASHBOARD_REMOTE_REPOSITORY: ${{ env.REPO_OWNER }}/dashboard
DASHBOARD_SOURCE_DIR: ./_dashboard_publish
DASHBOARD_TOKEN: ${{ steps.bot.outputs.token }}
run: bash ./.github/scripts/publish-dashboard.sh
- 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