From fcaa4d80a2b315ca3aadb051f1eef98f0d04b56f Mon Sep 17 00:00:00 2001 From: Johnson Chin Date: Mon, 22 Dec 2025 01:04:13 +0800 Subject: [PATCH] feat: added github actions - runs npm test on every PR to main - generates report in XML format --- .github/workflows/ci-test.yml | 43 +++++++++++++++++++ .github/workflows/test-report.yml | 22 ++++++++++ package-lock.json | 70 +++++++++++++++++++++++++++++++ package.json | 2 + 4 files changed, 137 insertions(+) create mode 100644 .github/workflows/ci-test.yml create mode 100644 .github/workflows/test-report.yml diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml new file mode 100644 index 0000000..068ea1d --- /dev/null +++ b/.github/workflows/ci-test.yml @@ -0,0 +1,43 @@ +name: "ci" + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + test: + name: run sdk tests + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x] + + steps: + - name: checkout code + uses: actions/checkout@v4 + + - name: setup node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + + - name: installing dependencies + run: npm ci + + - name: run tests + run: npm run test:ci + env: + WHITELISTED_WALLET_PRIVATE_KEY: ${{ secrets.WHITELISTED_WALLET_PRIVATE_KEY }} + SELLER_ENTITY_ID: ${{ secrets.SELLER_ENTITY_ID }} + SELLER_AGENT_WALLET_ADDRESS: ${{ secrets.SELLER_AGENT_WALLET_ADDRESS }} + + - name: uploads results + uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: test-results-${{ matrix.node-version }} + path: junit.xml diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml new file mode 100644 index 0000000..eb76374 --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,22 @@ +name: "test report" +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +permissions: + contents: read + actions: read + checks: write + +jobs: + report: + runs-on: ubuntu-latest + steps: + - uses: dorny/test-reporter@v2 + with: + artifact: test-results + name: JEST Tests + path: "*.xml" + reporter: jest-junit diff --git a/package-lock.json b/package-lock.json index e512754..636612d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "babel-jest": "^30.2.0", "dotenv": "^17.2.3", "jest": "^30.2.0", + "jest-junit": "^16.0.0", "ts-jest": "^29.4.5", "typescript": "^5.8.3" } @@ -7466,6 +7467,55 @@ "fsevents": "^2.3.3" } }, + "node_modules/jest-junit": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-16.0.0.tgz", + "integrity": "sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "mkdirp": "^1.0.4", + "strip-ansi": "^6.0.1", + "uuid": "^8.3.2", + "xml": "^1.0.1" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/jest-junit/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-junit/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-junit/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/jest-leak-detector": { "version": "30.2.0", "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-30.2.0.tgz", @@ -8455,6 +8505,19 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/mlly": { "version": "1.7.4", "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.4.tgz", @@ -10524,6 +10587,13 @@ } } }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "dev": true, + "license": "MIT" + }, "node_modules/xmlhttprequest-ssl": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.1.2.tgz", diff --git a/package.json b/package.json index 81c4e1c..c724428 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "types": "./dist/index.d.ts", "scripts": { "test": "jest", + "test:ci": "jest --ci --reporters=default --reporters=jest-junit", "test:watch": "jest --watch", "test:coverage": "jest --coverage", "tsup": "tsup src/index.ts --dts --format cjs,esm --out-dir dist" @@ -21,6 +22,7 @@ "babel-jest": "^30.2.0", "dotenv": "^17.2.3", "jest": "^30.2.0", + "jest-junit": "^16.0.0", "ts-jest": "^29.4.5", "typescript": "^5.8.3" },