From 6a1d697d446744da7f87d58706660656abbfd5c1 Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 13 Sep 2024 14:57:57 -0300 Subject: [PATCH 1/3] ci: setup realtime build and pr checks --- .github/workflows/checks.yml | 79 ++++++++++++++++++++++++++++++++ packages/realtime/.gitignore | 1 + packages/realtime/jest.config.js | 4 ++ packages/realtime/package.json | 5 +- pnpm-lock.yaml | 29 ++++-------- turbo.json | 5 ++ 6 files changed, 102 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/checks.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..0d896db --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,79 @@ +name: Run Checks + +on: + pull_request: + types: + - opened + - synchronize +jobs: + delete-comments: + runs-on: ubuntu-latest + steps: + - uses: izhangzhihao/delete-comment@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + delete_user_name: SuperViz-Dev + issue_number: ${{ github.event.number }} + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20] + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.10.0 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --no-frozen-lockfile + env: + NPM_CONFIG_USERCONFIG: .npmrc.ci + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Create a .version.js file + run: | + touch .version.js && echo "echo \"export const version = 'test'\" > .version.js" | bash - + - name: Create a .remote-config.js file + run: | + touch .remote-config.js && echo "echo \"module.exports = { remoteConfig: { apiUrl: 'https://dev.nodeapi.superviz.com' }};\" > .remote-config.js" | bash - + - name: Run tests + run: pnpm run build + test-unit-realtime: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20] + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.10.0 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --no-frozen-lockfile + env: + NPM_CONFIG_USERCONFIG: .npmrc.ci + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Create a .version.js file + run: | + touch .version.js && echo "echo \"export const version = 'test'\" > .version.js" | bash - + - name: Create a .remote-config.js file + run: | + touch .remote-config.js && echo "echo \"module.exports = { remoteConfig: { apiUrl: 'https://dev.nodeapi.superviz.com' }};\" > .remote-config.js" | bash - + - name: Run tests + run: pnpm run test:unit:ci --filter=@superviz/realtime + - name: Post PR Comment + run: npx github-actions-ctrf packages/realtime/ctrf/ctrf-report.json --pr-comment + if: always() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/packages/realtime/.gitignore b/packages/realtime/.gitignore index 2dbff46..7cae9c5 100644 --- a/packages/realtime/.gitignore +++ b/packages/realtime/.gitignore @@ -131,6 +131,7 @@ dist dist/ coverage/ +ctrf/ .DS_Store .version.js .remote-config.js \ No newline at end of file diff --git a/packages/realtime/jest.config.js b/packages/realtime/jest.config.js index b478659..a2f49f0 100644 --- a/packages/realtime/jest.config.js +++ b/packages/realtime/jest.config.js @@ -17,4 +17,8 @@ module.exports = { '^.+\\.js$': 'ts-jest', }, setupFiles: ['/jest.setup.js'], + reporters: [ + 'default', + ['jest-ctrf-json-reporter', {}], + ], }; diff --git a/packages/realtime/package.json b/packages/realtime/package.json index 2d00846..d118d65 100644 --- a/packages/realtime/package.json +++ b/packages/realtime/package.json @@ -54,12 +54,12 @@ }, "homepage": "https://github.com/SuperViz/realtime#readme", "devDependencies": { - "@superviz/eslint-config": "workspace:*", - "@superviz/typescript-config": "workspace:*", "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", "@esm-bundle/chai": "^4.3.4-fix.0", "@jest/globals": "^29.7.0", + "@superviz/eslint-config": "workspace:*", + "@superviz/typescript-config": "workspace:*", "@types/debug": "^4.1.12", "@types/jest": "^29.5.12", "@types/node": "^20.14.8", @@ -69,6 +69,7 @@ "eslint": "8.56.0", "husky": "^9.0.11", "jest": "^29.7.0", + "jest-ctrf-json-reporter": "^0.0.9", "semantic-release": "^24.0.0", "semantic-release-version-file": "^1.0.2", "ts-jest": "^29.2.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aec29c7..3171b2a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -51,8 +51,8 @@ importers: packages/realtime: dependencies: '@superviz/socket-client': - specifier: ^1.12.0 - version: 1.12.1 + specifier: workspace:* + version: link:../socket-client browser-or-node: specifier: ^3.0.0 version: 3.0.0 @@ -111,6 +111,9 @@ importers: jest: specifier: ^29.7.0 version: 29.7.0(@types/node@20.16.5) + jest-ctrf-json-reporter: + specifier: ^0.0.9 + version: 0.0.9 semantic-release: specifier: ^24.0.0 version: 24.1.1(typescript@5.6.2) @@ -882,9 +885,6 @@ packages: '@socket.io/component-emitter@3.1.2': resolution: {integrity: sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==} - '@superviz/socket-client@1.12.1': - resolution: {integrity: sha512-ZUSVQJP4OJ+isujpeqkjSZnuCAd5qeqrbFR7rS6OiaQi/fnsALxZchm9Sy+46yVw5xMNuBp1j8p7lW19wCC4DA==} - '@types/babel__core@7.20.5': resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} @@ -2435,6 +2435,9 @@ packages: ts-node: optional: true + jest-ctrf-json-reporter@0.0.9: + resolution: {integrity: sha512-mxuUPZ/npUEoPyjE/vHQhdNVhuxV3NzdIPIWjoreW4rMisaDKlD7x4oERU4HEC9mlI7dQkwcOHo9BJzGIgieKw==} + jest-diff@29.7.0: resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -4704,20 +4707,6 @@ snapshots: '@socket.io/component-emitter@3.1.2': {} - '@superviz/socket-client@1.12.1': - dependencies: - '@reactivex/rxjs': 6.6.7 - debug: 4.3.7 - lodash: 4.17.21 - rxjs: 7.8.1 - semantic-release-version-file: 1.0.2 - socket.io-client: 4.7.5 - zod: 3.23.8 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - '@types/babel__core@7.20.5': dependencies: '@babel/parser': 7.25.6 @@ -6672,6 +6661,8 @@ snapshots: - babel-plugin-macros - supports-color + jest-ctrf-json-reporter@0.0.9: {} + jest-diff@29.7.0: dependencies: chalk: 4.1.2 diff --git a/turbo.json b/turbo.json index c51c01b..4d08b16 100644 --- a/turbo.json +++ b/turbo.json @@ -22,6 +22,8 @@ "dependsOn": ["^watch"] }, "build": { + "cache": false, + "persistent": false, "dependsOn": ["^build"], "inputs": ["$TURBO_DEFAULT$", ".env*"], "outputs": [".next/**", "!.next/cache/**"] @@ -32,6 +34,9 @@ "dev": { "cache": false, "persistent": true + }, + "@superviz/realtime#build": { + "dependsOn": ["@superviz/socket-client#build"] } } } From 77c1b176021a1097f97e78ebac5d1f4cd9796de0 Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 13 Sep 2024 15:01:51 -0300 Subject: [PATCH 2/3] ci: build the dependencies before run the tests --- turbo.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/turbo.json b/turbo.json index 4d08b16..af9e5d3 100644 --- a/turbo.json +++ b/turbo.json @@ -37,6 +37,18 @@ }, "@superviz/realtime#build": { "dependsOn": ["@superviz/socket-client#build"] + }, + "@superviz/realtime#test:unit": { + "dependsOn": ["@superviz/socket-client#build"] + }, + "@superviz/realtime#test:unit:watch": { + "dependsOn": ["@superviz/socket-client#build"] + }, + "@superviz/realtime#test:unit:coverage": { + "dependsOn": ["@superviz/socket-client#build"] + }, + "@superviz/realtime#test:unit:ci": { + "dependsOn": ["@superviz/socket-client#build"] } } } From 2e69994a0557678edad5776712eaebedaf798999 Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 13 Sep 2024 15:03:41 -0300 Subject: [PATCH 3/3] ci: create remote config and version file before try to build --- .github/workflows/checks.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0d896db..254a34d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -37,11 +37,11 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Create a .version.js file run: | - touch .version.js && echo "echo \"export const version = 'test'\" > .version.js" | bash - + touch packages/realtime/.version.js && echo "echo \"export const version = 'test'\" > .version.js" | bash - - name: Create a .remote-config.js file run: | - touch .remote-config.js && echo "echo \"module.exports = { remoteConfig: { apiUrl: 'https://dev.nodeapi.superviz.com' }};\" > .remote-config.js" | bash - - - name: Run tests + touch packages/realtime/.remote-config.js && echo "echo \"module.exports = { remoteConfig: { apiUrl: 'https://dev.nodeapi.superviz.com' }};\" > .remote-config.js" | bash - + - name: Run builds run: pnpm run build test-unit-realtime: runs-on: ubuntu-latest @@ -66,10 +66,10 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Create a .version.js file run: | - touch .version.js && echo "echo \"export const version = 'test'\" > .version.js" | bash - + touch packages/realtime/.version.js && echo "echo \"export const version = 'test'\" > .version.js" | bash - - name: Create a .remote-config.js file run: | - touch .remote-config.js && echo "echo \"module.exports = { remoteConfig: { apiUrl: 'https://dev.nodeapi.superviz.com' }};\" > .remote-config.js" | bash - + touch packages/realtime/.remote-config.js && echo "echo \"module.exports = { remoteConfig: { apiUrl: 'https://dev.nodeapi.superviz.com' }};\" > .remote-config.js" | bash - - name: Run tests run: pnpm run test:unit:ci --filter=@superviz/realtime - name: Post PR Comment