Skip to content

Switch to hosted coverage report #594

Switch to hosted coverage report

Switch to hosted coverage report #594

Workflow file for this run

name: CI
on: pull_request
env:
FORCE_COLOR: 3
permissions:
contents: read
jobs:
lint:
name: Lint
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: Brightspace/third-party-actions@actions/checkout
- name: Set up node
uses: Brightspace/third-party-actions@actions/setup-node
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint (ESLint)
run: npm run lint:eslint
- name: Lint (EditorConfig)
run: npm run lint:editorconfig
licenses:
name: Check Licenses
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: Brightspace/third-party-actions@actions/checkout
- name: Set up node
uses: Brightspace/third-party-actions@actions/setup-node
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Check licenses
run: npm run license-check
test:
name: Test
timeout-minutes: 15
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: Brightspace/third-party-actions@actions/checkout
- name: Set up node
uses: Brightspace/third-party-actions@actions/setup-node
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: |
npm ci
npx playwright install --with-deps
- name: Run tests
run: npm run test:all
- name: Generate coverage report info
if: github.actor != 'dependabot[bot]'
id: coverage-info
run: |
COMMON_PATH="$GITHUB_REPOSITORY/$GITHUB_RUN_ID/$GITHUB_RUN_ATTEMPT"
DESTINATION="s3://test-reporting-coverage/$COMMON_PATH/"
SOURCE='./coverage/lcov-report/'
URL="https://test-reporting.d2l.dev/coverage/$COMMON_PATH/"
echo "destination=$DESTINATION" >> $GITHUB_OUTPUT
echo "source=$SOURCE" >> $GITHUB_OUTPUT
echo "url=$URL" >> $GITHUB_OUTPUT
- name: Assume role
if: github.actor != 'dependabot[bot]'
uses: Brightspace/third-party-actions@aws-actions/configure-aws-credentials
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
aws-session-token: ${{secrets.AWS_SESSION_TOKEN}}
aws-region: us-east-1
role-to-assume: arn:aws:iam::427469055187:role/github+Brightspace+test-reporting-node
role-duration-seconds: 3600
- name: Upload code coverage
if: github.actor != 'dependabot[bot]'
uses: BrightspaceUI/actions/publish-to-s3@main
with:
bucket-path: ${{steps.coverage-info.outputs.destination}}
publish-directory: ${{steps.coverage-info.outputs.source}}
- name: Generate test summary
id: test-summary
uses: Brightspace/third-party-actions@actions/github-script
with:
script: |
const { env } = await import('node:process');
const { COVERAGE_REPORT_URL: coverageReportUrl } = env;
const { summary } = core;
summary.clear();
if (coverageReportUrl) {
summary.addHeading('Coverage report', 3);
summary.addLink('Report', coverageReportUrl);
}
summary.addHeading('Generated reports', 3);
const reporters = [{
name: 'mocha',
path: './d2l-test-report-mocha.json'
}, {
name: 'playwright',
path: './d2l-test-report-playwright.json'
}, {
name: '@web/test-runner',
path: './d2l-test-report-web-test-runner.json'
}];
for (const { name, path } of reporters) {
let report = require(path);
report = JSON.stringify(report, null, 2);
report = `\n\n\`\`\`json\n${report}\n\`\`\`\n\n`;
summary.addDetails(name, report);
}
summary.write({ overwrite: true });
core.setOutput('report', summary.stringify());
env:
COVERAGE_REPORT_URL: ${{steps.coverage-info.outputs.url}}
- name: Leave comment
uses: BrightspaceUI/actions/comment-on-pr@main
with:
message: ${{steps.test-summary.outputs.report}}
post-mode: hide-previous