Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: verify importing js exports works before versioning #239

Merged
merged 17 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
86cd2fb
test: verify importing js exports works before versioning
skjalgepalg Oct 9, 2023
767e42f
test: add test for commonJS exports
skjalgepalg Oct 10, 2023
3e4cb00
feat: generate d.mts files for better type coverage
skjalgepalg Oct 10, 2023
0db018c
chore: remove duplicate types file and references
skjalgepalg Oct 10, 2023
86a4e49
chore: run attw in preversion to verify type declarations
skjalgepalg Oct 10, 2023
b2cd38b
chore: run preversion in check action
skjalgepalg Oct 10, 2023
5b51b44
chore: remove redundant publish dry-run from check action
skjalgepalg Oct 10, 2023
c09457c
chore: rename testpack script and separate preversion script from test
skjalgepalg Oct 11, 2023
fd322bc
chore: add .nvmrc to use specific node version (lts/hydrogen)
skjalgepalg Oct 11, 2023
17f955c
chore: update check-action to use nvmrc and specify when to run
skjalgepalg Oct 11, 2023
3874113
docs: add sections regarding testing and nvm, plus use npm ci
skjalgepalg Oct 11, 2023
8780cfd
chore: use node v20.8.0 to match github actions npm requirements
skjalgepalg Oct 11, 2023
390ebf7
test: verify large format logos for jsx and vanilla in js and mjs
skjalgepalg Oct 16, 2023
b94ac02
test: wip add jsdom and run iife scaffold on test runs
skjalgepalg Oct 17, 2023
c746dcc
test: verify that iife-script adds svg tag with children to head
skjalgepalg Oct 19, 2023
16a2c96
chore: remove commented code
skjalgepalg Oct 19, 2023
fcceee9
chore: cancel-in-progress for github action runs except for master br…
skjalgepalg Oct 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 14 additions & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
name: Build and dry-run publish to npmjs
on: push
name: Build and test package
on:
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
cache: "npm"
- run: npm install -g npm
- run: npm ci
# Build to verify
- run: npm run build
# Dry-run a publish to log package contents
- run: npm publish --dry-run
# Verify built artefacts
- run: npm run test
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.8.0
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ First clone `@nrk/core-icons` and install its dependencies:
```bash
git clone git@github.com:nrkno/core-icons.git
cd core-icons
npm install
# Install dependencies according to package-lock-file
npm ci
npm start # Your browser will open documentation with hot reloading
```

Expand All @@ -30,8 +31,34 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
git checkout -b feature/my-changes
# Update the source code
npm run build
# Test to ensure integrity
npm run test
git commit -am "<type>[optional scope]: <desciption>"
git push --set-upstream origin feature/my-changes
# Make a PR to the master branch,
# Assign a developer to review your code
```

## Testing

We use [Testpack-cli](https://github.com/qwertie/testpack) to ensure published exports work as intended. In short it does the following:

- Runs `npm pack` and moves the generated archive to a sibling test folder `nrk-core-icons-testpack` (which is created if not present) to core-icons
- npm-installs React in the testpack-folder
- Copies the `test`-folder to the testpack-folder
- Runs the `testpack-script` in the testpack-folder
- Cleans up

We use [arethetypeswring/cli](https://github.com/arethetypeswrong/arethetypeswrong.github.io/tree/main/packages/cli) to verify that our type declarations are available for consumers.

- We purposefully ignore the [false-cjs](https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md)-rule as our types are generated from [@nrk/svg-to-js](https://github.com/nrkno/svg-to-js) which only gives us cjs types. We chose not to duplicate the `d.ts`-file to a `d.mts` to solve this error as it could lead to unexpected behavior for consumers.

## nvm

Uses [Node Version Manager](https://github.com/nvm-sh/nvm/blob/master/README.md#intro) (nvm) to organize node version

nvm config is saved in `.nvmrc`, set appropriate node version using:

```shell
nvm use
```