Skip to content

test: add coverage with istanbul #6

test: add coverage with istanbul

test: add coverage with istanbul #6

Workflow file for this run

name: TICS Report
on:
push:
branches:
- main
- ci-add-tics-workflow
jobs:
test-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm install
- name: Run tests with coverage
run: |
set -x
yarn test:coverage
zip -r coverage/coverage-report.zip coverage/
# Clean up any unwanted directories if necessary
find . -type d -name "unwanted-dir" -exec rm -r {} +
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/coverage-report.zip
retention-days: 1
publish-coverage-report:
name: publish-coverage-report
runs-on: ubuntu-latest
needs: test-coverage
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
token: ${{ secrets.GITHUB_TOKEN }}
- name: Cleanup coverage directory
run: |
rm -rf coverage
mkdir coverage
- name: Download coverage report artifact
uses: actions/download-artifact@v4
with:
name: coverage-report
path: coverage
- name: Set Git User
run: |
git config --global user.email "github-action@example.com"
git config --global user.name "GitHub Action"
- name: Push coverage Report
timeout-minutes: 3
run: |
git add .
git commit -m "workflow: update coverage report"
while true; do
git pull --rebase
if [ $? -ne 0 ]; then
echo "Failed to rebase. Please review manually."
exit 1
fi
git push
if [ $? -eq 0 ]; then
echo "Successfully pushed HTML report to repo."
exit 0
fi
done
- name: Output Report URL as Workflow Annotation
run: |
FULL_HTML_REPORT_URL=FULL_HTML_REPORT_URL=https://canonical.github.io/maas-ui/coverage
echo "::notice title=Published Test Coverage Report::$FULL_HTML_REPORT_URL"
tics-report:
runs-on: ubuntu-latest
needs: publish-coverage-report
steps:
- uses: actions/checkout@v4
- name: Run TICS Analyzer
uses: tiobe/tics-github-action@v3
with:
mode: qserver
project: maas-ui
viewerUrl: https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=config
ticsAuthToken: ${{ secrets.TICSAUTHTOKEN }}
installTics: true
tmpdir: /tmp/tics
branchdir: .
- name: Upload TICS Report
if: always()
uses: actions/upload-artifact@v4
with:
name: tics-report
path: /tmp/tics/ticstmpdir
retention-days: 7