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

Add Jest tests and publish automation with changesets #9

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
5 changes: 5 additions & 0 deletions .changeset/beige-dolls-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@single-spa/import-map-injector": minor
---

Add Jest tests and automation for publishing
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
83 changes: 83 additions & 0 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build, Test, Release

on:
push:
branches: main
pull_request:
branches: "*"

jobs:
build_lint_test:
name: Build, Lint, and Test
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Install Pnpm
uses: pnpm/[email protected]
with:
version: 8.6.9

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm run lint

- name: Check format
run: pnpm run check-format

- name: Check types
run: pnpm run typecheck

- name: Test
run: pnpm run test --coverage

- name: Build
run: pnpm run build

release:
name: Release
needs: build_lint_test
permissions:
contents: write # To push release tags
pull-requests: write # To create release pull requests
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Install Pnpm
uses: pnpm/[email protected]
with:
version: 8.6.9

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build

- name: Create Release Pull Request or Publish to NPM
id: changesets
uses: changesets/action@v1
with:
publish: pnpm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 8 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('jest').Config} */
module.exports = {
collectCoverageFrom: ["src/**/*.ts"],
resetMocks: true,
restoreMocks: true,
setupFiles: ["./jest.setup.js"],
testEnvironment: "jsdom",
};
3 changes: 3 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import jestFetchMock from "jest-fetch-mock";

jestFetchMock.enableMocks();
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
"build": "concurrently pnpm:build:*",
"prepublishOnly": "pnpm run build",
"build:types": "tsc",
"build:lib": "rollup -c"
"build:lib": "rollup -c",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false",
"changeset": "changeset",
"release": "changeset publish"
},
"keywords": [],
"author": "Joel Denning",
Expand All @@ -37,15 +41,23 @@
"@babel/eslint-parser": "^7.22.10",
"@babel/preset-env": "^7.22.10",
"@babel/preset-typescript": "^7.22.5",
"@changesets/cli": "^2.26.2",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-terser": "^0.4.3",
"@types/jest": "^29.5.4",
"babel-jest": "^29.6.2",
"concurrently": "^8.2.0",
"eslint": "^8.47.0",
"eslint-config-ts-important-stuff": "^1.1.0",
"express": "^4.18.2",
"husky": "^8.0.3",
"jest": "^29.5.0",
"jest-cli": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-fetch-mock": "^3.0.3",
"prettier": "^3.0.2",
"rollup": "^3.28.0",
"typescript": "^5.1.6"
}
},
"packageManager": "[email protected]"
}
Loading