forked from microsoftgraph/microsoft-graph-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (83 loc) · 3.17 KB
/
pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# 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 }}