File tree Expand file tree Collapse file tree 6 files changed +172
-3
lines changed
Expand file tree Collapse file tree 6 files changed +172
-3
lines changed Original file line number Diff line number Diff line change 1+ name : Publish Release Telemetry SDK
2+
3+ on :
4+ push :
5+ tags :
6+ - ' *'
7+
8+ jobs :
9+ # Build and publish to npm registry
10+ build-and-publish :
11+ runs-on : ubuntu-latest
12+ defaults :
13+ run :
14+ working-directory : js
15+ steps :
16+ # Step 1: Checkout the source code from the tag
17+ - uses : actions/checkout@v3
18+
19+ # Step 2: Set up Node.js environment for building
20+ # Uses Node.js 16 which is stable and well-supported
21+ - name : Set up Node.js 16
22+ uses : actions/setup-node@v3
23+ with :
24+ node-version : ' 16'
25+ cache : ' npm'
26+ cache-dependency-path : ' js/package-lock.json'
27+ registry-url : ' https://registry.npmjs.org'
28+ always-auth : true
29+
30+ # Step 3: Cache npm dependencies to speed up builds
31+ # This caches the node_modules directory between workflow runs
32+ - name : Cache npm packages
33+ id : cache-npm
34+ uses : actions/cache@v3
35+ with :
36+ path : js/node_modules
37+ key : ${{ runner.os }}-npm-${{ hashFiles('js/package-lock.json') }}
38+ restore-keys : |
39+ ${{ runner.os }}-npm-
40+
41+ # Step 4: Install dependencies
42+ - name : Install dependencies
43+ run : npm install
44+
45+ # Step 5: Build the SDK
46+ # This creates the bundled telemetry SDK in the dist directory
47+ - name : Build Telemetry SDK
48+ run : npm run build
49+
50+ # Step 7: Publish to npm registry
51+ - name : Publish to npm
52+ env :
53+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
54+ run : npm publish --access public
Original file line number Diff line number Diff line change 1+ name : Build, Test and Lint
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - ' *'
7+
8+ jobs :
9+ build-test-sonar :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v3
13+
14+ - name : Set up Node.js
15+ uses : actions/setup-node@v3
16+ with :
17+ node-version : ' 18'
18+
19+ - name : Install dependencies
20+ run : npm install
21+ working-directory : js
22+
23+ - name : Build
24+ run : npm run build
25+ working-directory : js
26+
27+ - name : Run tests
28+ run : npm test
29+ working-directory : js
30+ continue-on-error : true
31+
32+ # - name: Install SonarQube scanner
33+ # run: npm install -g sonarqube-scanner
34+
35+ # - name: Run SonarQube scanner
36+ # env:
37+ # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+ # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
39+ # run: sonar-scanner
40+
41+ lint :
42+ runs-on : ubuntu-latest
43+ steps :
44+ - uses : actions/checkout@v3
45+
46+ - name : Set up Node.js
47+ uses : actions/setup-node@v3
48+ with :
49+ node-version : ' 18'
50+
51+ - name : Install dependencies
52+ run : npm install
53+ working-directory : js
54+
55+ - name : Run ESLint
56+ run : npm run lint
57+ working-directory : js
Original file line number Diff line number Diff line change 1+ require ( 'eslint-plugin-only-warn' ) ;
2+
3+ module . exports = {
4+ plugins : [ 'only-warn' ] ,
5+ env : {
6+ browser : true ,
7+ es2021 : true ,
8+ node : true ,
9+ jasmine : true
10+ } ,
11+ extends : [
12+ 'eslint:recommended'
13+ ] ,
14+ parserOptions : {
15+ ecmaVersion : 12 ,
16+ sourceType : 'module'
17+ } ,
18+ rules : {
19+ 'no-unused-vars' : 'warn' ,
20+ 'no-console' : 'off'
21+ }
22+ } ;
Original file line number Diff line number Diff line change @@ -910,6 +910,32 @@ let data = { // Required
910910 * Travis integration
911911
912912
913-
913+ # GitHub Actions
914+
915+ ## Build and Test on Pull Request
916+
917+ This GitHub Actions workflow runs ** build, test, and lint checks** automatically when a pull request is opened against any branch.
918+
919+ ### When It Runs
920+
921+ - ** Trigger** : On every ` pull_request ` to any branch (` '**' ` )
922+
923+ ### Prerequisites Before Triggering
924+
925+ Make sure the following are set up ** before** opening a pull request:
926+
927+ ### Secrets
928+ ` SONAR_TOKEN ` : For SonarQube authentication
929+
930+ ## NPM Publish Github action
931+
932+ ### When It Runs
933+
934+ - ** Trigger** : On every tag creation from any branch (` '*' ` )
935+
936+ ### Prerequisites
937+
938+ Make sure that ` NPM_TOKEN ` is set in Secrets before creating a tag.
914939
940+ Note: The secrets and variables should be set in Github UI (` settings/secrets and variables/actions ` )
915941
Original file line number Diff line number Diff line change 2323 "karma-ng-html2js-preprocessor" : " 1.0.0" ,
2424 "karma-phantomjs-launcher" : " ^1.0.4" ,
2525 "karma-verbose-reporter" : " 0.0.6" ,
26- "rimraf" : " 2.6.2"
26+ "rimraf" : " 2.6.2" ,
27+ "eslint" : " ^8.57.0" ,
28+ "eslint-plugin-only-warn" : " ^1.0.4"
2729 },
2830 "scripts" : {
2931 "test" : " karma start karma.renderer.config.js" ,
3032 "codecov" : " codecov" ,
3133 "test-sdk" : " karma start karma.renderer.config.js" ,
32- "build" : " node_modules/.bin/rimraf ./dist && node bundle-schema.js && node buildSDK.js && node_modules/.bin/cpy package.json ./dist && node_modules/.bin/cpy README.md ./dist"
34+ "build" : " node_modules/.bin/rimraf ./dist && node bundle-schema.js && node buildSDK.js && node_modules/.bin/cpy package.json ./dist && node_modules/.bin/cpy README.md ./dist" ,
35+ "lint" : " eslint . --ext .js"
3336 },
3437 "repository" : {
3538 "type" : " git" ,
Original file line number Diff line number Diff line change 1+ # sonar.projectName=sunbird-telemetry-sdk
2+ # sonar.language=js
3+ # sonar.sources=.
4+ # sonar.projectKey=project-sunbird_sunbird-telemetry-sdk
5+ # sonar.host.url=https://sonarcloud.io
6+ # sonar.organization=project-sunbird
7+ # sonar.projectVersion=1.0
You can’t perform that action at this time.
0 commit comments