From 7ad41291ed69945e70b00169eccb0365a24c473c Mon Sep 17 00:00:00 2001 From: Newton <5769156+iamnewton@users.noreply.github.com> Date: Sat, 9 Nov 2024 23:15:16 -0800 Subject: [PATCH 1/4] feat: update to get parity Signed-off-by: Newton <5769156+iamnewton@users.noreply.github.com> --- .github/workflows/dependencies.yml | 11 +++++----- .github/workflows/deploy.yml | 2 +- .github/workflows/greetings.yml | 3 ++- .github/workflows/lint.yml | 8 ++++++++ .github/workflows/publish.yml | 4 ++++ .github/workflows/test.yml | 32 +++++++++++++++++++++++++++++- codecov.yml | 27 +++++++++++++++++++++++++ package-lock.json | 16 +++++++-------- package.json | 16 +++++++-------- vite.config.ts | 2 +- 10 files changed, 95 insertions(+), 26 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 0c33fa2..f095198 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -1,5 +1,6 @@ -name: Dependabot auto-merge -on: +name: Dependencies + +on: # yamllint disable-line rule:truthy - pull_request permissions: @@ -10,13 +11,11 @@ jobs: dependabot: name: Update the dependencies runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'theholocron/nextjs-template' + if: github.event.pull_request.user.login == 'dependabot[bot]' steps: - - uses: dependabot/fetch-metadata@4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d + - uses: dependabot/fetch-metadata@v2 name: Fetch Dependabot metadata id: metadata - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - run: gh pr merge --auto --merge "$PR_URL" name: Enable auto-merge for Dependabot PRs diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7b47f0a..8e6a8ed 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,7 +20,7 @@ jobs: id: deploy-github-pages name: Publish Storybook to GitHub Pages with: - build_command: npm run build:storybook + build_command: npm run build:storybook --output-dir=docs install_command: npm ci path: docs environment: diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index b039df3..aaef0a7 100755 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -8,6 +8,7 @@ jobs: greeting: name: Greet new interactions runs-on: ubuntu-latest + if: github.event.issue.user.login != 'iamnewton' || github.event.pull_request.user.login != 'iamnewton' steps: - uses: actions/first-interaction@v1 with: @@ -21,7 +22,7 @@ jobs: Your patience is much appreciated and we will get back to you as quickly as possible. pr-message: > - Hey @${{ github.event.issue.user.login }}! + Hey @${{ github.event.pull_request.user.login }}! We really appreciate you taking the time to help out with this PR. The collaborators on this project attempt to help as many people as possible, but we are a limited number of volunteers, so it is diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a241932..0c566e9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,6 +82,14 @@ jobs: # VALIDATE_YAML_PRETTIER: true => turning it off because its writing 4 spaces instead of 2 YAML_CONFIG_FILE: "yamllint.config.yml" + - uses: crazy-max/ghaction-import-gpg@v6 + name: Import GPG Key + with: + git_user_signingkey: true + git_commit_gpgsign: true + GPG_PRIVATE_KEY: ${{ secrets.SUPER_LINTER_GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.SUPER_LINTER_GPG_PASSPHRASE }} + - uses: stefanzweifel/git-auto-commit-action@v5 name: Commit and push linting fixes # Run only on: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e5e2363..7e52d65 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,6 +26,8 @@ jobs: - run: npm ci name: Install dependencies + env: + HUSKY: 0 - run: npm publish name: Publish to GitHub @@ -49,6 +51,8 @@ jobs: - run: npm ci name: Install dependencies + env: + HUSKY: 0 - run: npm publish --access public name: Publish to GitHub Packages diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 28c068a..bc9d655 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,36 @@ on: # yamllint disable-line rule:truthy - push jobs: + unit: + name: Run tests and collect coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + name: Checkout repository + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + name: Setup Node.js @v20 + with: + cache: npm + node-version: 20.x + + - run: npm ci + name: Install dependencies + + - run: npx playwright install --with-deps + name: Install Playwright + + - run: npm run build:storybook --quiet + name: Build Storybook + + - run: | + npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ + "npx http-server storybook-static --port 6006 --silent" \ + "npx wait-on tcp:6006 && npm run test:storybook -- --coverage" + name: Run tests with coverage + # Run visual and composition tests with Chromatic visual-and-composition: name: Test Visual and Composition @@ -57,7 +87,7 @@ jobs: - run: | npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ - "npx http-server docs --port 6006 --silent" \ + "npx http-server storybook-static --port 6006 --silent" \ "npx wait-on tcp:6006 && npm run test:storybook" name: Serve Storybook and run tests diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..6aecb67 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,27 @@ +coverage: + status: + # Apply default rules for flags coverage not uploaded + default_rules: + flag_coverage_not_uploaded_behavior: exclude + + # Set project-specific coverage targets + project: + array: + target: auto + threshold: 1% # PR fails if coverage drops by 1% or more + misc: + target: auto + threshold: 1% + storage: + target: auto + threshold: 1% + string: + target: auto + threshold: 1% + uri: + target: auto + threshold: 1% + +comment: + layout: "reach, diff, flags, files" + behavior: default diff --git a/package-lock.json b/package-lock.json index cbdb253..d5f5095 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,14 +15,14 @@ "devDependencies": { "@codesandbox/storybook-addon": "^0.2.0", "@storybook/nextjs": "^8.2.5", - "@theholocron/commitlint-config": "^3.4.4", - "@theholocron/eslint-config": "^3.4.4", - "@theholocron/jest-config": "^3.4.4", - "@theholocron/lint-staged-config": "^3.4.4", - "@theholocron/prettier-config": "^3.4.4", - "@theholocron/storybook-config": "^3.4.4", - "@theholocron/stylelint-config": "^3.4.4", - "@theholocron/tsconfig": "^3.4.4", + "@theholocron/commitlint-config": "^3.5.1", + "@theholocron/eslint-config": "^3.5.1", + "@theholocron/jest-config": "^3.5.1", + "@theholocron/lint-staged-config": "^3.5.1", + "@theholocron/prettier-config": "^3.5.1", + "@theholocron/storybook-config": "^3.5.1", + "@theholocron/stylelint-config": "^3.5.1", + "@theholocron/tsconfig": "^3.5.1", "@tsconfig/next": "^2.0.3", "@types/node": "^22.9.0", "@types/react": "^18.3.12", diff --git a/package.json b/package.json index cce234f..339302c 100644 --- a/package.json +++ b/package.json @@ -48,14 +48,14 @@ "devDependencies": { "@codesandbox/storybook-addon": "^0.2.0", "@storybook/nextjs": "^8.2.5", - "@theholocron/commitlint-config": "^3.4.4", - "@theholocron/eslint-config": "^3.4.4", - "@theholocron/jest-config": "^3.4.4", - "@theholocron/lint-staged-config": "^3.4.4", - "@theholocron/prettier-config": "^3.4.4", - "@theholocron/storybook-config": "^3.4.4", - "@theholocron/stylelint-config": "^3.4.4", - "@theholocron/tsconfig": "^3.4.4", + "@theholocron/commitlint-config": "^3.5.1", + "@theholocron/eslint-config": "^3.5.1", + "@theholocron/jest-config": "^3.5.1", + "@theholocron/lint-staged-config": "^3.5.1", + "@theholocron/prettier-config": "^3.5.1", + "@theholocron/storybook-config": "^3.5.1", + "@theholocron/stylelint-config": "^3.5.1", + "@theholocron/tsconfig": "^3.5.1", "@tsconfig/next": "^2.0.3", "@types/node": "^22.9.0", "@types/react": "^18.3.12", diff --git a/vite.config.ts b/vite.config.ts index e6abe5b..2ca76fa 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,7 +6,6 @@ import react from "@vitejs/plugin-react"; * @see https://vitejs.dev/config/ */ export default defineConfig({ - plugins: [react()], build: { lib: { entry: path.resolve(__dirname, "src/index.ts"), // Entry point of your library @@ -24,6 +23,7 @@ export default defineConfig({ }, }, }, + plugins: [react()], resolve: { alias: { "@": path.resolve(__dirname, "./src"), // Example alias, adjust as needed From 6e4b64b63af5ec838be1e1843a5c3bbb0e24c4cc Mon Sep 17 00:00:00 2001 From: Newton <5769156+iamnewton@users.noreply.github.com> Date: Sat, 9 Nov 2024 23:24:33 -0800 Subject: [PATCH 2/4] chore: fix deploy Signed-off-by: Newton <5769156+iamnewton@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- .github/workflows/test.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8e6a8ed..7b47f0a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,7 +20,7 @@ jobs: id: deploy-github-pages name: Publish Storybook to GitHub Pages with: - build_command: npm run build:storybook --output-dir=docs + build_command: npm run build:storybook install_command: npm ci path: docs environment: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bc9d655..3724502 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: - run: npx playwright install --with-deps name: Install Playwright - - run: npm run build:storybook --quiet + - run: npm run build:storybook -- --quiet --output-dir=docs name: Build Storybook - run: | @@ -82,7 +82,7 @@ jobs: - run: npx playwright install --with-deps name: Install Playwright - - run: npm run build:storybook --quiet + - run: npm run build:storybook -- --quiet --output-dir=docs name: Build Storybook - run: | From 82a1e59111c783dbca6ad1017cef65e3fd52d3a2 Mon Sep 17 00:00:00 2001 From: Newton <5769156+iamnewton@users.noreply.github.com> Date: Sat, 9 Nov 2024 23:29:01 -0800 Subject: [PATCH 3/4] chore: fix directory Signed-off-by: Newton <5769156+iamnewton@users.noreply.github.com> --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3724502..4e5f3a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: - run: | npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ - "npx http-server storybook-static --port 6006 --silent" \ + "npx http-server docs --port 6006 --silent" \ "npx wait-on tcp:6006 && npm run test:storybook -- --coverage" name: Run tests with coverage @@ -87,7 +87,7 @@ jobs: - run: | npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ - "npx http-server storybook-static --port 6006 --silent" \ + "npx http-server docs --port 6006 --silent" \ "npx wait-on tcp:6006 && npm run test:storybook" name: Serve Storybook and run tests From 1575ca30375f203c2c46d789e0975b6a35e68116 Mon Sep 17 00:00:00 2001 From: Newton <5769156+iamnewton@users.noreply.github.com> Date: Sat, 9 Nov 2024 23:34:02 -0800 Subject: [PATCH 4/4] chore: add in codecov Signed-off-by: Newton <5769156+iamnewton@users.noreply.github.com> --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e5f3a0..fdaa3ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,6 +34,11 @@ jobs: "npx wait-on tcp:6006 && npm run test:storybook -- --coverage" name: Run tests with coverage + - uses: codecov/codecov-action@v4 + name: Upload results to Codecov + with: + token: ${{ secrets.CODECOV_TOKEN }} + # Run visual and composition tests with Chromatic visual-and-composition: name: Test Visual and Composition