Skip to content

Commit 9097438

Browse files
authored
Setup build and test workflows (#201)
* Setup build and test workflows * Add sonar * Fix sonar config * Update pipeline config and remove workflow files for individual checks * Rollback to separate action checks * Set checkmarx tenant id * Set checkmarx tenant id env variable * Remove checkmarx workflow
1 parent a8f7252 commit 9097438

6 files changed

Lines changed: 120 additions & 64 deletions

File tree

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: '20'
18+
cache: 'npm'
19+
20+
- run: npm ci
21+
22+
- name: Lint
23+
run: npm run lint
24+
25+
- name: Unit tests
26+
run: npm test
27+
28+
- name: Build
29+
run: npm run build
30+
31+
- uses: actions/upload-artifact@v4
32+
with:
33+
name: unit-coverage
34+
path: coverage/unit
35+
if-no-files-found: warn

.github/workflows/e2e.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: E2E
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
cypress:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: '20'
18+
cache: 'npm'
19+
20+
- run: npm ci
21+
22+
- name: Cypress E2E tests
23+
uses: cypress-io/github-action@v6
24+
with:
25+
build: npm run build
26+
start: npm start
27+
wait-on: 'http://localhost:3000'
28+
wait-on-timeout: 120
29+
browser: chrome
30+
install: false
31+
32+
- uses: actions/upload-artifact@v4
33+
if: failure()
34+
with:
35+
name: cypress-screenshots
36+
path: cypress/screenshots
37+
38+
- uses: actions/upload-artifact@v4
39+
if: failure()
40+
with:
41+
name: cypress-videos
42+
path: cypress/videos
43+
44+
- uses: actions/upload-artifact@v4
45+
if: always()
46+
with:
47+
name: cypress-coverage
48+
path: coverage/cypress
49+
if-no-files-found: warn

.github/workflows/sonar.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Sonar
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
sonar:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'npm'
21+
22+
- run: npm ci
23+
24+
- name: Unit tests
25+
run: npm test
26+
27+
- name: SonarQube scan
28+
uses: SonarSource/sonarqube-scan-action@v5
29+
env:
30+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
31+
SONAR_HOST_URL: https://sonar.tools.sap

.pipeline/config.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

Jenkinsfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

sonar-project.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
# license agreement you entered into with SAP.
99
#
1010

11-
#Sonar - CDCTOOLBOX-46
12-
sonar.projectKey=cdc-tools-chrome-extension
13-
sonar.pullrequest.github.repository=cx-servicesautomation/sap-customer-data-cloud-toolkit
14-
sonar.sources=src
1511
sonar.host.url=https://sonar.tools.sap
12+
13+
sonar.projectKey=sap-customer-data-cloud-toolkit-sap-customer-data-cloud-toolkit-ed98d
14+
sonar.projectName=sap-customer-data-cloud-toolkit
15+
16+
sonar.sources=src
1617
sonar.exclusions=**/*.test.js,**/__mocks__/*,src/lib/tracker.js
1718

1819
# tests related info
1920
sonar.tests=src
2021
sonar.test.inclusions=**/*.test.js
2122
sonar.javascript.lcov.reportPaths=coverage/cypress/lcov.info,coverage/unit/lcov.info
22-
#sonar.testExecutionReportPaths=testResults/sonar-report.xml

0 commit comments

Comments
 (0)