Skip to content

Commit c7259de

Browse files
committed
Started the test dashboard workflow
1 parent cb9bb65 commit c7259de

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

.github/workflows/dashboard.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
# Create https://nigelhorne.github.io/Data-Random-String-Matches/coverage/
3+
name: Test Dashboard
4+
5+
permissions:
6+
contents: write # needed to push to gh-pages
7+
8+
on:
9+
push:
10+
branches: [main, master]
11+
pull_request:
12+
branches: [main, master]
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
perl: ["5.40"]
20+
steps:
21+
# Checkout repository
22+
- uses: actions/checkout@v5
23+
with:
24+
fetch-depth: 0
25+
26+
# Install Perl via perlbrew
27+
- name: Setup Perl
28+
uses: shogo82148/actions-setup-perl@v1
29+
with:
30+
perl-version: ${{ matrix.perl }}
31+
# install cpanminus
32+
# cpanm-options: --notest
33+
34+
- name: Update Ubuntu Packages
35+
run: |
36+
sudo apt-get update
37+
sudo apt-get -y upgrade
38+
if: runner.os == 'Linux'
39+
40+
# Install module dependencies (from cpanfile or manually)
41+
- name: Install dependencies
42+
run: |
43+
cpanm --notest --installdeps .
44+
cpanm -iqn ExtUtils::MakeMaker Test::Most Devel::Cover Devel::Cover::Report::Html
45+
46+
# Optional: run Perl::Critic static checks
47+
# - name: Run Perl::Critic
48+
# run: |
49+
# cpanm Perl::Critic
50+
# perlcritic --verbose 5 lib || true
51+
52+
- name: Run tests manually
53+
run: |
54+
prove -l -b -v t
55+
56+
# Run the tests with Devel::Cover for coverage
57+
- name: Run tests with coverage
58+
run: |
59+
COVER_VERBOSE=1 cover -test
60+
working-directory: ${{ github.workspace }}
61+
62+
# Generate HTML coverage report
63+
- name: Generate HTML report
64+
run: |
65+
mkdir -p cover_html
66+
cover -report html -outputdir cover_html
67+
# working-directory: ${{ github.workspace }}
68+
69+
- name: Check for HTML report
70+
run: |
71+
if [ ! -f cover_html/coverage.html ]; then
72+
echo "HTML report not found. Skipping deployment."
73+
exit 1
74+
fi
75+
76+
- name: Rename coverage.html to index.html
77+
run: |
78+
mv cover_html/coverage.html cover_html/index.html
79+
80+
- name: Generate custom coverage index
81+
run: |
82+
mkdir -p cover_db
83+
# cover -dump > cover_db/cover.json
84+
cover -report json -outputdir cover_db
85+
perl scripts/generate_index.pl
86+
87+
- name: Archive coverage snapshot
88+
run: |
89+
mkdir -p coverage_history
90+
TIMESTAMP=$(date +%Y-%m-%d)
91+
SHA=$(git rev-parse --short HEAD)
92+
cp cover_db/cover.json "coverage_history/${TIMESTAMP}-${SHA}.json"
93+
# Remove older history
94+
# ls -t coverage_history/*.json | tail -n +31 | xargs rm -f
95+
96+
- name: Commit coverage snapshot
97+
run: |
98+
git config user.name "GitHub Actions"
99+
git config user.email "github-actions@github.com"
100+
git add coverage_history/
101+
git commit -m "Add coverage snapshot for $TIMESTAMP ($SHA)" || echo "No changes to commit"
102+
git pull --rebase
103+
git push origin HEAD:${{ github.ref_name }}
104+
105+
# Deploy HTML report to GitHub Pages
106+
- name: Publish coverage report
107+
uses: peaceiris/actions-gh-pages@v4
108+
with:
109+
github_token: ${{ secrets.GITHUB_TOKEN }}
110+
publish_dir: ./cover_html
111+
destination_dir: coverage
112+
user_name: github-actions
113+
user_email: github-actions@github.com
114+
keep_files: true

0 commit comments

Comments
 (0)