Merge pull request #1 from nigelhorne/dependabot/github_actions/actio… #28
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
| --- | |
| # Create https://nigelhorne.github.io/Data-Random-String-Matches/coverage/ | |
| name: Test Dashboard | |
| permissions: | |
| contents: write # needed to push to gh-pages | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| perl: ["5.40"] | |
| steps: | |
| # Checkout repository | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| # Install Perl via perlbrew | |
| - name: Setup Perl | |
| uses: shogo82148/actions-setup-perl@v1 | |
| with: | |
| perl-version: ${{ matrix.perl }} | |
| # install cpanminus | |
| # cpanm-options: --notest | |
| # - name: Update Ubuntu Packages | |
| # run: | | |
| # sudo apt-get update | |
| # sudo apt-get -y upgrade | |
| # sudo ntpdate -u pool.ntp.org | |
| # if: runner.os == 'Linux' | |
| # Install module dependencies (from cpanfile or manually) | |
| - name: Install dependencies | |
| run: | | |
| cpanm --notest --installdeps . | |
| cpanm -iqn ExtUtils::MakeMaker Test::Most Devel::Cover Devel::Cover::Report::Html | |
| # Optional: run Perl::Critic static checks | |
| # - name: Run Perl::Critic | |
| # run: | | |
| # cpanm Perl::Critic | |
| # perlcritic --verbose 5 lib || true | |
| - name: Run tests manually | |
| run: | | |
| prove -l -b -v t | |
| # Run the tests with Devel::Cover for coverage | |
| - name: Run tests with coverage | |
| run: | | |
| COVER_VERBOSE=1 cover -test | |
| working-directory: ${{ github.workspace }} | |
| # Generate HTML coverage report | |
| - name: Generate HTML report | |
| run: | | |
| mkdir -p cover_html | |
| cover -report html -outputdir cover_html | |
| # working-directory: ${{ github.workspace }} | |
| - name: Check for HTML report | |
| run: | | |
| if [ ! -f cover_html/coverage.html ]; then | |
| echo "HTML report not found. Skipping deployment." | |
| exit 1 | |
| fi | |
| - name: Rename coverage.html to index.html | |
| run: | | |
| mv cover_html/coverage.html cover_html/index.html | |
| - name: Generate custom coverage index | |
| run: | | |
| mkdir -p cover_db | |
| # cover -dump > cover_db/cover.json | |
| cover -report json -outputdir cover_db | |
| perl scripts/generate_index.pl | |
| - name: Archive coverage snapshot | |
| run: | | |
| mkdir -p coverage_history | |
| TIMESTAMP=$(date +%Y-%m-%d) | |
| SHA=$(git rev-parse --short HEAD) | |
| cp cover_db/cover.json "coverage_history/${TIMESTAMP}-${SHA}.json" | |
| # Remove older history | |
| # ls -t coverage_history/*.json | tail -n +31 | xargs rm -f | |
| - name: Commit coverage snapshot | |
| run: | | |
| git config user.name "GitHub Actions" | |
| git config user.email "github-actions@github.com" | |
| git add coverage_history/ | |
| git commit -m "Add coverage snapshot for $TIMESTAMP ($SHA)" || echo "No changes to commit" | |
| git pull --rebase | |
| git push origin HEAD:${{ github.ref_name }} | |
| # Deploy HTML report to GitHub Pages | |
| - name: Publish coverage report | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./cover_html | |
| destination_dir: coverage | |
| user_name: github-actions | |
| user_email: github-actions@github.com | |
| keep_files: true |