From 06e1e055d61843722ed95a2c6c83c9111248fcae Mon Sep 17 00:00:00 2001 From: kidneyweak Date: Wed, 27 Sep 2023 10:06:44 +0800 Subject: [PATCH] feat: delete sonarqube and add new action --- .github/workflows/codeql.yml | 6 +- .github/workflows/publish-npm-package.yml | 40 +++++++ .github/workflows/sonarqube.yml | 25 ----- .github/workflows/test-report.yml | 29 +++++ .github/workflows/unit-test.yml | 5 + package-lock.json | 126 +++++++--------------- package.json | 3 +- sonar-project.properties | 6 -- 8 files changed, 115 insertions(+), 125 deletions(-) create mode 100644 .github/workflows/publish-npm-package.yml delete mode 100644 .github/workflows/sonarqube.yml create mode 100644 .github/workflows/test-report.yml delete mode 100644 sonar-project.properties diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a4fede29..36b32e04 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,9 +1,11 @@ -name: "CodeQL" +name: "codeql-analysis" on: push: branches: [ main ] pull_request: - branches: [ '*' ] + branches: [ main ] + schedule: + - cron: '0 0 * * 0' # Run at midnight on Sunday jobs: analyze: diff --git a/.github/workflows/publish-npm-package.yml b/.github/workflows/publish-npm-package.yml new file mode 100644 index 00000000..0e61e019 --- /dev/null +++ b/.github/workflows/publish-npm-package.yml @@ -0,0 +1,40 @@ +name: publish-npm-package +on: + release: + types: [ published ] +jobs: + github-packages: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + # Setup .npmrc file to publish to GitHub Packages + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://npm.pkg.github.com' + # Defaults to the user or organization that owns the workflow file + scope: '@cathayddt' + - run: npm ci + - run: npm run build:console + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + npm-registry: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + # how to fix the package name + - run: | + sed -i 's/"name": "@cathayddt\/bdk"/"name": "@cathaybc\/bdk"/' package.json + npm install + - run: npm run build:console + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml deleted file mode 100644 index 052d44c8..00000000 --- a/.github/workflows/sonarqube.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: sonarqube - -on: - push: - branches: [ master ] - -jobs: - sonarqube-scan: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' - - run: npm ci - - run: npm run test:sonar - - uses: sonarsource/sonarqube-scan-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - BROWSERSLIST_IGNORE_OLD_DATA: true - diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml new file mode 100644 index 00000000..315a22de --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,29 @@ +name: test-report +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +permissions: + contents: read + actions: read + checks: write +jobs: + report: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'npm' + - run: npm ci + - run: npm run build:console + - run: npm run test:json + + - uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: mocha-report # Name of the check run which will be created + path: 'test-*.json' # Path to test results (inside artifact .zip) + reporter: mocha-json # Format of test results \ No newline at end of file diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 8384cd05..6a17dcb0 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -18,3 +18,8 @@ jobs: - run: npm ci - run: npm run build:console - run: npm run test:coverage + + - uses: VeryGoodOpenSource/very_good_coverage@v2 + with: + path: './coverage/lcov.info' + min_coverage: 70 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9e59591a..da554288 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,7 +51,6 @@ "eslint-plugin-react": "^7.32.2", "git-cliff": "^1.2.0", "mocha": "^9.1.3", - "mocha-sonarqube-reporter": "^1.0.2", "nodemon": "^2.0.15", "nyc": "^15.1.0", "semver": "^7.3.5", @@ -3397,9 +3396,9 @@ } }, "node_modules/eslint-plugin-import/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -3450,9 +3449,9 @@ } }, "node_modules/eslint-plugin-node/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -3535,9 +3534,9 @@ } }, "node_modules/eslint-plugin-react/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -5141,9 +5140,9 @@ } }, "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -5443,9 +5442,9 @@ } }, "node_modules/make-dir/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -5553,18 +5552,6 @@ "node": ">= 8" } }, - "node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, "node_modules/mkdirp-classic": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", @@ -5613,16 +5600,6 @@ "url": "https://opencollective.com/mochajs" } }, - "node_modules/mocha-sonarqube-reporter": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/mocha-sonarqube-reporter/-/mocha-sonarqube-reporter-1.0.2.tgz", - "integrity": "sha512-YxyaBYQDnxFu3v38HOGPx6N8q1qoRfDNkttA7LciwGaT+5z9KK3rKQYsjEa+ehQIFIvd/S7PzLDTvGWLrqFfmg==", - "dev": true, - "dependencies": { - "mkdirp": "0.5.5", - "xml-escape": "1.1.0" - } - }, "node_modules/mocha/node_modules/minimatch": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", @@ -5769,9 +5746,9 @@ } }, "node_modules/nodemon/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "bin": { "semver": "bin/semver" @@ -7781,12 +7758,6 @@ } } }, - "node_modules/xml-escape": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/xml-escape/-/xml-escape-1.1.0.tgz", - "integrity": "sha1-OQTBQ/qOs6ADDsZG0pAqLxtwbEQ=", - "dev": true - }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -10305,9 +10276,9 @@ } }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true } } @@ -10342,9 +10313,9 @@ "dev": true }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true } } @@ -10405,9 +10376,9 @@ } }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true } } @@ -11495,9 +11466,9 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true } } @@ -11737,9 +11708,9 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true } } @@ -11819,15 +11790,6 @@ "yallist": "^4.0.0" } }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, "mkdirp-classic": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", @@ -11891,16 +11853,6 @@ } } }, - "mocha-sonarqube-reporter": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/mocha-sonarqube-reporter/-/mocha-sonarqube-reporter-1.0.2.tgz", - "integrity": "sha512-YxyaBYQDnxFu3v38HOGPx6N8q1qoRfDNkttA7LciwGaT+5z9KK3rKQYsjEa+ehQIFIvd/S7PzLDTvGWLrqFfmg==", - "dev": true, - "requires": { - "mkdirp": "0.5.5", - "xml-escape": "1.1.0" - } - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -11992,9 +11944,9 @@ "dev": true }, "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true }, "supports-color": { @@ -13493,12 +13445,6 @@ "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", "requires": {} }, - "xml-escape": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/xml-escape/-/xml-escape-1.1.0.tgz", - "integrity": "sha1-OQTBQ/qOs6ADDsZG0pAqLxtwbEQ=", - "dev": true - }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index 9833f524..dff69514 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "test:quorum": "nyc npm run test -- --grep Quorum", "test:fabric": "nyc npm run test -- --grep Fabric", "test:coverage": "nyc npm run test", - "test:sonar": "NODE_ENV=testing nyc --reporter=lcov mocha --reporter mocha-sonarqube-reporter --reporter-options output=coverage/xunit.xml --require ts-node/register ./test/**/*.test.ts --exit", + "test:json": "NODE_ENV=testing BDK_PATH=$(pwd)/test/bdk BDK_DOCKER_HOST_PATH=$(pwd)/test/bdk mocha --reporter json --require ts-node/register ./test/**/*.test.ts --exit > test-results.json", "git:changelog": "git-cliff --unreleased --tag 2.0.3 --prepend CHANGELOG.md", "doc:create": "npx typedoc --readme none --out ./api-docs --packages ." }, @@ -85,7 +85,6 @@ "eslint-plugin-react": "^7.32.2", "git-cliff": "^1.2.0", "mocha": "^9.1.3", - "mocha-sonarqube-reporter": "^1.0.2", "nodemon": "^2.0.15", "nyc": "^15.1.0", "semver": "^7.3.5", diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 6d0fc334..00000000 --- a/sonar-project.properties +++ /dev/null @@ -1,6 +0,0 @@ -sonar.projectKey=bdk-github -sonar.qualitygate.wait=true -sonar.sources=src -sonar.coverage.jacoco.xmlReportPaths=coverage/xunit.xml -sonar.javascript.lcov.reportPaths=coverage/lcov.info -sonar.typescript.tsconfigPath=tsconfig.json