Skip to content

Commit 094fd9f

Browse files
authored
feat: adds github actions for build and test (#10)
* adds github actions for build and test * fixes actions * fixes actions * fixes actions * adds lcov provider * adds lcov provider * action versions * edit actions * removes unnecessary step
1 parent 2b5cc02 commit 094fd9f

File tree

9 files changed

+154
-6
lines changed

9 files changed

+154
-6
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build React Native Package and Playground
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
merge_group:
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js 22.x
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 22.x
25+
26+
- name: Install pnpm
27+
uses: pnpm/action-setup@v4
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
32+
- name: Build
33+
run: pnpm build

.github/workflows/sonarqube.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: SonarQube
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
merge_group:
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
sonarqube:
15+
name: SonarQube
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js 22.x
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 22.x
25+
26+
- name: Install pnpm
27+
uses: pnpm/action-setup@v4
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
32+
- name: Run tests with coverage
33+
run: |
34+
pnpm test:coverage
35+
36+
- name: SonarQube Scan
37+
uses: SonarSource/sonarqube-scan-action@2500896589ef8f7247069a56136f8dc177c27ccf
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
40+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Run unit tests for react-native package
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
merge_group:
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js 22.x
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 22.x
25+
26+
- name: Install pnpm
27+
uses: pnpm/action-setup@v4
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
32+
- name: Test
33+
run: pnpm test

apps/playground/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"dev": "expo start --reset-cache",
77
"android": "expo start --android",
88
"ios": "expo start --ios",
9-
"clean": "rimraf .turbo node_modules .expo"
9+
"clean": "rimraf .turbo node_modules .expo",
10+
"build": "expo export"
1011
},
1112
"dependencies": {
1213
"@formbricks/react-native": "workspace:*",

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"dev": "turbo run dev",
77
"lint": "turbo run lint",
88
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
9-
"check-types": "turbo run check-types"
9+
"check-types": "turbo run check-types",
10+
"test": "turbo run test --no-cache",
11+
"test:coverage": "turbo run test:coverage --no-cache"
1012
},
1113
"devDependencies": {
1214
"prettier": "^3.5.3",

packages/react-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"dev": "vite build --watch --mode dev",
3939
"clean": "rimraf .turbo node_modules dist .turbo",
4040
"test": "vitest",
41-
"coverage": "vitest run --coverage"
41+
"test:coverage": "vitest run --coverage"
4242
},
4343
"dependencies": {
4444
"@react-native-community/netinfo": "11.4.1",

packages/react-native/vite.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ const config = (): UserConfig => {
3131
fileName: "index",
3232
},
3333
},
34-
plugins: [dts({ rollupTypes: true, bundledPackages: ["@formbricks/types"] })],
34+
plugins: [
35+
dts({ rollupTypes: true, bundledPackages: ["@formbricks/types"] }),
36+
],
3537
test: {
3638
setupFiles: ["./vitest.setup.ts"],
3739
coverage: {
3840
provider: "v8",
39-
reporter: ["text", "json", "html"],
40-
include: ["src/lib/**/*.ts"],
41+
reporter: ["text", "json", "html", "lcov"],
42+
include: ["src/**/*.ts"],
43+
exclude: ["src/types/**/*.ts"],
4144
},
4245
},
4346
});

sonar-project.properties

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SonarQube Configuration for Formbricks React Native
2+
sonar.projectKey=formbricks_react-native
3+
sonar.organization=formbricks
4+
5+
# Source code paths
6+
sonar.sources=packages/react-native/src,apps/playground/src
7+
sonar.tests=packages/react-native/src
8+
9+
# Test inclusions and exclusions
10+
sonar.test.inclusions=**/*.test.*,**/*.spec.*
11+
sonar.test.exclusions=**/node_modules/**,**/dist/**,**/build/**,**/coverage/**,**/.turbo/**
12+
13+
# General exclusions
14+
sonar.exclusions=**/node_modules/**,**/dist/**,**/build/**,**/coverage/**,**/.turbo/**,**/apps/playground/**,**/*.config.js,**/*.config.ts,**/vite.config.ts,**/vitest.setup.ts,**/tsconfig.json,**/package.json,**/pnpm-lock.yaml,**/turbo.json,**/pnpm-workspace.yaml,**/assets/**,**/android/**,**/ios/**,**/android/**/*,**/ios/**/*,**/*.gradle,**/*.plist,**/*.pbxproj,**/*.xcworkspace,**/*.xcodeproj
15+
16+
# Language specific settings
17+
sonar.javascript.lcov.reportPaths=packages/react-native/coverage/lcov.info
18+
sonar.typescript.tsconfigPath=packages/react-native/tsconfig.json,apps/playground/tsconfig.json
19+
20+
# Coverage settings
21+
sonar.coverage.exclusions=**/node_modules/**,**/dist/**,**/build/**,**/coverage/**,**/.turbo/**,**/apps/playground/**,**/*.config.js,**/*.config.ts,**/vite.config.ts,**/vitest.setup.ts,**/tsconfig.json,**/package.json,**/pnpm-lock.yaml,**/turbo.json,**/pnpm-workspace.yaml

turbo.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@
1616
"dev": {
1717
"cache": false,
1818
"persistent": true
19+
},
20+
"@formbricks/react-native:build": {
21+
"dependsOn": ["^build"],
22+
"cache": false
23+
},
24+
"playground:build": {
25+
"dependsOn": ["@formbricks/react-native:build"],
26+
"outputs": ["apps/playground/out/**"],
27+
"cache": false
28+
},
29+
"test": {
30+
"outputs": []
31+
},
32+
"test:coverage": {
33+
"outputs": []
1934
}
2035
}
2136
}

0 commit comments

Comments
 (0)