Skip to content

Commit

Permalink
feat: test library import (#19)
Browse files Browse the repository at this point in the history
# Description
- add smoke tests (import) for the built artifact of the library
  • Loading branch information
Couto authored Dec 17, 2024
1 parent 747ea12 commit 7b7cac6
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
with:
storybook_url: ${{ needs.deployment.outputs.environment_url }}

release-preview:
release:
name: Release
runs-on: ubuntu-20.04
needs: ["tests"]
Expand Down
36 changes: 33 additions & 3 deletions .github/workflows/workflow-build-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
jobs:
build:
runs-on: ubuntu-20.04
outputs:
manifest: ${{steps.pack.outputs.manifest}}
tarball: ${{steps.pack.outputs.tarball}}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -27,14 +30,41 @@ jobs:
run: npm run build

- name: Pack library
id: pack
run: |
npm pack
npm pack --json > manifest.json
echo "MANIFEST=$(jq -c . < manifest.json)" >> $GITHUB_ENV
echo "manifest=$(jq -c . < manifest.json)" >> $GITHUB_OUTPUT
echo "tarball=$(jq -r '.[0].filename' < manifest.json)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: ${{fromJson(env.MANIFEST)[0].filename}}
name: ${{steps.pack.outputs.tarball}}
path: |
manifest.json
${{fromJson(env.MANIFEST)[0].filename}}
${{steps.pack.outputs.tarball}}
test:
needs: ["build"]
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v4
with:
name: ${{needs.build.outputs.tarball}}
path: "./"

- name: Setup NPM Project
run: npm init -y

- name: Install Library and Peer Dependencies
run: npm install -S react ${{needs.build.outputs.tarball}}

- run: ls -la
- run: ls -la node_modules

- name: Smoke Test import
run: |
echo "import { Button } from '@yldio/percoct-ui'" > index.mjs
echo "const { Button } = require('@yldio/percoct-ui')" > index.js
node index.mjs
node index.js
46 changes: 39 additions & 7 deletions .github/workflows/workflow-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
required: true

jobs:
sanity:
prettier:
runs-on: ubuntu-20.04
steps:
- name: Checkout
Expand All @@ -27,12 +27,6 @@ jobs:
- name: Verify dependencies provenance
run: npm audit signatures

- name: Verify dependencies provenance
run: npm audit signatures

- name: Verify dependencies provenance
run: npm audit signatures

- name: Prettier
uses: EPMatt/reviewdog-action-prettier@v1
with:
Expand All @@ -41,6 +35,25 @@ jobs:
level: warning
fail_on_error: true

lint:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Verify dependencies provenance
run: npm audit signatures

- name: Lint
uses: reviewdog/action-eslint@v1
with:
Expand All @@ -49,6 +62,25 @@ jobs:
level: warning
fail_level: "error"

typescript:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Verify dependencies provenance
run: npm audit signatures

- name: Typecheck
uses: EPMatt/reviewdog-action-tsc@v1
with:
Expand Down
20 changes: 15 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"type": "git",
"url": "git+https://github.com/yldio/percoct-ui.git"
},
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"type": "module",
"files": [
Expand Down Expand Up @@ -69,6 +69,7 @@
"prettier": "3.4.2",
"prop-types": "^15.8.1",
"rollup": "^4.28.1",
"rollup-plugin-peer-deps-external": "^2.2.4",
"storybook": "^8.4.7",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.0",
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typescript from "@rollup/plugin-typescript";
import peerDepsExternal from "rollup-plugin-peer-deps-external";

import packageJson from "./package.json" with { type: "json" };

Expand All @@ -9,6 +10,6 @@ export default [
{ file: packageJson.main, format: "cjs", sourcemap: true },
{ file: packageJson.module, format: "esm", sourcemap: true },
],
plugins: [typescript()],
plugins: [peerDepsExternal(), typescript()],
},
];

0 comments on commit 7b7cac6

Please sign in to comment.