From de4424375ce9016f2c011d737e970191d1343357 Mon Sep 17 00:00:00 2001 From: Ryota Watanabe <43837308+wattanx@users.noreply.github.com> Date: Sun, 11 Aug 2024 21:58:00 +0900 Subject: [PATCH] ci: add ci (#38) * test: update test * ci: add test * ci: fix release.yml --- .github/workflows/ci.yml | 26 ++++++++++++++ .github/workflows/release.yml | 48 ++++++++++--------------- scripts/template/__bundle_analysis.json | 2 +- test/__snapshots__/index.test.ts.snap | 14 +++++++- test/index.test.ts | 7 +--- 5 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0371234 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: 18 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Run tests + run: pnpm run test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2fda4c8..6251b9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,48 +1,36 @@ -name: Publish to NPM +name: Release + on: + workflow_dispatch: push: - branches: - - main - paths: - - 'package.json' + tags: + - 'v*' jobs: release: - name: Release runs-on: ubuntu-latest steps: - - name: Checkout Repo - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: pnpm/action-setup@v2 + - name: Install pnpm + uses: pnpm/action-setup@v4.0.0 - - name: Setup Node.js - uses: actions/setup-node@v3 + - name: Use Node.js + uses: actions/setup-node@v4 with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - - - name: Can Publish - run: npx can-npm-publish --verbose - env: - NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} + node-version: v18 + registry-url: https://registry.npmjs.org/ + cache: pnpm - name: Install run: 'pnpm install --frozen-lockfile' - - name: Build - run: pnpm build + - name: build + run: pnpm run build - - name: Publish - run: npm publish + - name: Publish to NPM + run: pnpm publish --access public --no-git-checks env: - NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} - - - name: tag - run: | - git config user.name github-actions - git config user.email github-actions@github.com - git tag $(bash scripts/release.sh) - git push --tags + NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} diff --git a/scripts/template/__bundle_analysis.json b/scripts/template/__bundle_analysis.json index d006bf4..e0ed804 100644 --- a/scripts/template/__bundle_analysis.json +++ b/scripts/template/__bundle_analysis.json @@ -1,5 +1,5 @@ [ - { "path": "app", "size": 90000 }, + { "path": "app", "size": 100000 }, { "path": "pages/index", "size": 2011 }, { "path": "components/tutorial", "size": 2944 }, { "path": "pages/test", "size": 1130 } diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index 8cb1efe..c5a7368 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -6,7 +6,19 @@ exports[`ts test > Snapshot of comparison results 1`] = ` # Bundle Size | Route | Size (gzipped) | | --- | --- | -| \`app\` | 97.12 kB (🔴 7.12 kB) | +| \`app\` | 97.6 kB (🟢 -2.4 kB) | +| \`pages/index\` | removed | +| \`components/tutorial\` | removed | +| \`pages/test\` | removed |" +`; + +exports[`ts test > comparison results test 1`] = ` +" + +# Bundle Size +| Route | Size (gzipped) | +| --- | --- | +| \`app\` | 97.6 kB (🟢 -2.4 kB) | | \`pages/index\` | removed | | \`components/tutorial\` | removed | | \`pages/test\` | removed |" diff --git a/test/index.test.ts b/test/index.test.ts index 63bd748..fbf0693 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -25,7 +25,7 @@ describe('ts test', () => { // increased expect(splitContents.find((x) => x.includes('pages/index'))).toContain( - '🔴' + 'removed' ); // removed @@ -33,11 +33,6 @@ describe('ts test', () => { 'removed' ); - // added - expect( - splitContents.find((x) => x.includes('components/nuxt-logo')) - ).toContain('added'); - expect(contents).toMatchSnapshot(); });