Skip to content

Create azure-webapps-node.yml #1

Create azure-webapps-node.yml

Create azure-webapps-node.yml #1

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# Tests are executed and coverage reports are emitted as to the action summary
# A dependent workflow which uses workflow_run as a trigger reads the archived outputs and emits comments to the PR triggering this build
name: Build and Test
on:
push:
branches: [main, release/**, next/**]
pull_request:
branches: [main, release/**, next/**]
permissions:
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install -g lerna
- name: Install node_modules
run: yarn
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- run: node scripts/setVersion.js --next
- run: yarn build
- run: yarn lint
- run: yarn test
- name: Archive test results
uses: actions/upload-artifact@v4 # upload test results
if: always() # run this step even if previous step failed
with:
name: test-results-${{ matrix.node-version }}
path: testResults/junit.xml
- name: Archive coverage artifacts
uses: actions/upload-artifact@v4 # upload coverage rartifacts
if: always() # run this step even if previous step failed
with:
name: coverage-${{ matrix.node-version }}
path: coverage/
- name: Code Coverage Summary Report
uses: irongut/[email protected]
with:
filename: coverage/cobertura-coverage.xml
badge: true
format: 'markdown'
output: 'both'
- name: Write to Job Summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
# The check-build-matrix returns success if all matrix jobs in build are successful; otherwise, it returns a failure.
# Use this as a PR status check for GitHub Policy Service instead of individual matrix entry checks.
check-build-matrix:
runs-on: ubuntu-latest
needs: build
if: always()
steps:
- name: All build matrix options are successful
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: One or more build matrix options failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
sonarcloud:
name: SonarCloud Analysis
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: coverage-*
merge-multiple: true
path: coverage/
- name: Run sonar cloud analysis
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}