Skip to content

Commit

Permalink
ci: add ci (#38)
Browse files Browse the repository at this point in the history
* test: update test

* ci: add test

* ci: fix release.yml
  • Loading branch information
wattanx authored Aug 11, 2024
1 parent 1043c09 commit de44243
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 38 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
48 changes: 18 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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 [email protected]
git tag $(bash scripts/release.sh)
git push --tags
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
2 changes: 1 addition & 1 deletion scripts/template/__bundle_analysis.json
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
14 changes: 13 additions & 1 deletion test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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`] = `
"
<!-- __NUXTJS_BUNDLE -->
# Bundle Size
| Route | Size (gzipped) |
| --- | --- |
| \`app\` | 97.6 kB (🟢 -2.4 kB) |
| \`pages/index\` | removed |
| \`components/tutorial\` | removed |
| \`pages/test\` | removed |"
Expand Down
7 changes: 1 addition & 6 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,14 @@ describe('ts test', () => {

// increased
expect(splitContents.find((x) => x.includes('pages/index'))).toContain(
'🔴'
'removed'
);

// removed
expect(splitContents.find((x) => x.includes('pages/test'))).toContain(
'removed'
);

// added
expect(
splitContents.find((x) => x.includes('components/nuxt-logo'))
).toContain('added');

expect(contents).toMatchSnapshot();
});

Expand Down

0 comments on commit de44243

Please sign in to comment.