From 6119025ab086a80698e3eb674c503ae3bae051dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20=C5=BBydek?= Date: Wed, 23 Aug 2023 13:25:02 +0200 Subject: [PATCH 1/6] ci: use shared workflows --- .github/workflows/analyze-commits.yml | 11 +++++++ .github/workflows/coverage-diff.yml | 12 ++++++++ .github/workflows/docs-and-coverage.yml | 11 +++++++ .github/workflows/docs.yml | 25 ---------------- .github/workflows/release.yml | 30 +++++-------------- .github/workflows/test.yml | 40 +++++++------------------ package.json | 1 + 7 files changed, 52 insertions(+), 78 deletions(-) create mode 100644 .github/workflows/analyze-commits.yml create mode 100644 .github/workflows/coverage-diff.yml create mode 100644 .github/workflows/docs-and-coverage.yml delete mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/analyze-commits.yml b/.github/workflows/analyze-commits.yml new file mode 100644 index 0000000..6c78cb9 --- /dev/null +++ b/.github/workflows/analyze-commits.yml @@ -0,0 +1,11 @@ +name: Analyze Commit Messages +on: + pull_request: + +permissions: + pull-requests: write + contents: write +jobs: + analyze-commits: + name: Generate docs and coverage report + uses: fingerprintjs/dx-team-toolkit/.github/workflows/analyze-commits.yml@v1 diff --git a/.github/workflows/coverage-diff.yml b/.github/workflows/coverage-diff.yml new file mode 100644 index 0000000..02c9521 --- /dev/null +++ b/.github/workflows/coverage-diff.yml @@ -0,0 +1,12 @@ +name: Check coverage for PR + +on: + pull_request: + +jobs: + run-tests-check-coverage: + name: Run tests & check coverage + permissions: + checks: write + pull-requests: write + uses: fingerprintjs/dx-team-toolkit/.github/workflows/coverage-diff.yml@v1 diff --git a/.github/workflows/docs-and-coverage.yml b/.github/workflows/docs-and-coverage.yml new file mode 100644 index 0000000..e409382 --- /dev/null +++ b/.github/workflows/docs-and-coverage.yml @@ -0,0 +1,11 @@ +name: Generate docs and coverage report + +on: + push: + branches: + - main + +jobs: + generate-docs-and-coverage: + name: Generate docs and coverage report + uses: fingerprintjs/dx-team-toolkit/.github/workflows/docs-and-coverage.yml@v1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 80362f3..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Generate docs - -on: - push: - branches: - - main - -jobs: - generate-docs: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v2 - - - name: Install dependencies - run: yarn install - - - name: Create the docs - run: yarn run docs - - - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@8817a56e5bfec6e2b08345c81f4d422db53a2cdc - with: - branch: gh-pages - folder: docs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 82bdd15..b0b7b14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,4 @@ -name: Release - +name: release on: push: branches: @@ -7,24 +6,9 @@ on: - test jobs: - release: - environment: production - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - persist-credentials: false - - - name: Install dependencies - run: yarn install - - - name: Build library - run: yarn run package - - - name: Release - run: yarn release - env: - GITHUB_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - HUSKY: 0 + build-and-release: + name: 'Build project, run CI checks and publish new release' + uses: fingerprintjs/dx-team-toolkit/.github/workflows/release-typescript-project.yml@v1 + secrets: + GH_RELEASE_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }} + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9528e89..89b5c79 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,32 +1,12 @@ -# Reference on this file: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions -name: Lint, build and test +name: ci on: - pull_request: + push: + branches-ignore: + - main + paths-ignore: + - '**.md' + jobs: - build: - name: Lint, build and test - runs-on: ubuntu-latest - timeout-minutes: 3 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Cache - uses: actions/cache@v2 - with: - path: | - **/node_modules - !**/dist/node_modules - key: nodemodules-${{ hashFiles('**/yarn.lock') }} - restore-keys: nodemodules- - - name: Install Node packages - run: yarn install - - name: Build - run: yarn build-all - env: - VITE_API_KEY: ${{ secrets.API_KEY }} - - name: Lint - run: yarn lint && yarn check - - name: Tests - run: yarn test - - name: Typecheck - run: yarn test:dts + build-and-check: + name: Build project and run CI checks + uses: fingerprintjs/dx-team-toolkit/.github/workflows/build-typescript-project.yml@v1 diff --git a/package.json b/package.json index 5030bbf..5226a01 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ ], "scripts": { "prepare": "husky install && yarn sync-pkg-version && yarn --cwd examples/svelte-kit-ts && yarn --cwd examples/svelte-kit && yarn --cwd examples/spa", + "build": "yarn package", "package": "svelte-kit package", "package:watch": "svelte-kit package --watch", "check": "svelte-check --tsconfig tsconfig.json", From 6c0e9cee2e92e7367a44e2ede199a1131ea18cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20=C5=BBydek?= Date: Wed, 23 Aug 2023 13:33:36 +0200 Subject: [PATCH 2/6] build: don't extend svelte-kit config --- tsconfig.json | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 5c56cee..5b03c9a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,8 @@ { - "extends": "./.svelte-kit/tsconfig.json", "compilerOptions": { + "importsNotUsedAsValues": "error", + "isolatedModules": true, + "preserveValueImports": true, "allowJs": true, "checkJs": true, "esModuleInterop": true, @@ -8,6 +10,17 @@ "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": true, - "strict": true - } + "strict": true, + "moduleResolution": "node", + "module": "esnext", + "target": "esnext" + }, + "include": [ + "src/**/*.js", + "src/**/*.ts", + "src/**/*.svelte" + ], + "exclude": [ + "node_modules/**", + ] } From f4476931fa7cdd445beadd15cd6d35e4c7d39143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20=C5=BBydek?= Date: Wed, 23 Aug 2023 13:34:42 +0200 Subject: [PATCH 3/6] build: add coverage --- jest.config.js | 2 ++ package.json | 1 + 2 files changed, 3 insertions(+) diff --git a/jest.config.js b/jest.config.js index 009f044..f891a3a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,4 +13,6 @@ export default { }, moduleFileExtensions: ['svelte', 'js', 'ts'], setupFilesAfterEnv: ['/__tests__/setup.ts'], + collectCoverageFrom: ['./src/**/**.{ts,tsx}'], + coverageReporters: ['lcov', 'json-summary', ['text', { file: 'coverage.txt', path: './' }]], }; diff --git a/package.json b/package.json index 5226a01..d326a79 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "lint:fix": "yarn format && yarn lint -- --fix .", "format": "prettier --write .", "test": "jest", + "test:coverage": "jest --coverage", "test:dts": "tsc --noEmit --isolatedModules dist/index.d.ts", "sync-pkg-version": "node scripts/syncVersion.js && yarn format", "build-all": "yarn package && yarn --cwd examples/svelte-kit build && yarn --cwd examples/spa build && yarn --cwd examples/svelte-kit-ts", From 75f611f16ea8ac3940415423afab2924b9f3e6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20=C5=BBydek?= Date: Thu, 24 Aug 2023 15:37:47 +0200 Subject: [PATCH 4/6] docs(README): add coverage --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f674106..df2f5a5 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ Monthly downloads from NPM + + coverage + MIT license @@ -125,7 +128,7 @@ Fingerprint Pro usage is billed per API call. To reduce API calls, it is a good ## Documentation -See the [generated SDK API reference here](https://fingerprintjs.github.io/fingerprintjs-pro-react/). +See the [generated SDK API reference here](https://fingerprintjs.github.io/fingerprintjs-pro-svelte/). This library uses Fingerprint Pro JavaScript agent under the hood. See our documentation for the full [JavaScript Agent API reference](https://dev.fingerprint.com/docs/js-agent). @@ -136,6 +139,6 @@ The `getData` function throws errors directly from the JS Agent without changing ## License -This project is licensed under the MIT license. See the [LICENSE](https://github.com/fingerprintjs/fingerprintjs-pro-react/blob/main/LICENSE) file for more info. +This project is licensed under the MIT license. See the [LICENSE](https://github.com/fingerprintjs/fingerprintjs-pro-svelte/blob/main/LICENSE) file for more info. From e044f260f1c5e65e5152b0533c71926c2d7ad03b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20=C5=BBydek?= Date: Fri, 25 Aug 2023 14:44:39 +0200 Subject: [PATCH 5/6] ci: add prepare command --- .github/workflows/docs-and-coverage.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docs-and-coverage.yml b/.github/workflows/docs-and-coverage.yml index e409382..19f8bd3 100644 --- a/.github/workflows/docs-and-coverage.yml +++ b/.github/workflows/docs-and-coverage.yml @@ -9,3 +9,7 @@ jobs: generate-docs-and-coverage: name: Generate docs and coverage report uses: fingerprintjs/dx-team-toolkit/.github/workflows/docs-and-coverage.yml@v1 + with: + prepare-gh-pages-commands: | + mv docs/* ./gh-pages + mv coverage/lcov-report ./gh-pages/coverage From 7a75ee03b365348503c7ae7c0e5ab8b50f15ee46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20=C5=BBydek?= Date: Mon, 28 Aug 2023 11:23:08 +0200 Subject: [PATCH 6/6] ci: restore old tests name --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 89b5c79..9af5ac4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: ci +name: Lint, build and test on: push: branches-ignore: