Skip to content

Commit

Permalink
Switch to pnpm and Github actions. (#263)
Browse files Browse the repository at this point in the history
* Switch to pnpm and Github actions.

* Add changeset

* Fix

* Try again

* Fix

* Try this

* Fix

* Fix

* Fix

* Try to fix tests

* Fix tests

* Simplify

* yarn -> pnpm

* pnpm changes

* Changeset fix

* Fix

* Fix tests
  • Loading branch information
joeldenning authored Mar 3, 2021
1 parent 0861b90 commit 905c0cc
Show file tree
Hide file tree
Showing 65 changed files with 11,372 additions and 20,069 deletions.
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/master/docs/common-questions.md)
9 changes: 9 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch"
}
22 changes: 22 additions & 0 deletions .changeset/famous-needles-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"create-single-spa": minor
"generator-single-spa": minor
"single-spa-web-server-utils": minor
"single-spa-welcome": minor
"webpack-config-single-spa": minor
"webpack-config-single-spa-react": minor
"webpack-config-single-spa-react-ts": minor
"webpack-config-single-spa-ts": minor
---

- The create-single-spa project now uses pnpm workspaces and changesets instead of lerna.
- Remove deprecated babel-eslint package in favor of new @babel/eslint-parser package.
- Fix typescript problems in pnpm packages.
- Add support for creation of pnpm packages. Resolves #211.
- Add name field for utility packages.
- No longer depend on beta versions of create-single-spa packages
- Rename template package.jsons to avoid detection by monorepo tooling
- Fix usage of @testing-library/jest-dom in yarn pnp and pnpm
- Switch to Github actions instead of Travis - travis stopped reporting test results
- prettierignore pnpm-lock.yaml files
- Improve support for format and check-format commands on Windows
25 changes: 25 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build and Test

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: "15"
- uses: pnpm/[email protected]
with:
version: 5.17.2
- run: git checkout main && git checkout $GITHUB_SHA
- run: pnpm install --frozen-lockfile
- run: pnpx changeset status
- run: pnpm test --recursive
- run: pnpm run lint --recursive
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ tests/fixtures
.DS_Store
*.svelte
*.js.map
coverage
coverage
pnpm-lock.yaml
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

23 changes: 15 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@

## Running the create-single-spa CLI

We're using [lerna](https://lerna.js.org/).
We're using [pnpm workspaces](https://pnpm.js.org/en/workspaces).

1. `yarn install`
2. `yarn bootstrap`
3. `node packages/create-single-spa/bin/create-single-spa.js ../some-test-dir`
1. `pnpm install`
2. `node packages/create-single-spa/bin/create-single-spa.js ../some-test-dir`

Note that create-single-spa can run in the current directory by default, but you can provide a different destination directory through the CLI (as shown above with `some-test-dir`).

## Add changeset for each PR

This project uses [changesets](https://github.com/atlassian/changesets) to manage versioning of each of the packages. Before you create a pull request, run the following:

```sh
pnpmx changeset
```

## Tests

There are two kinds of tests - end-to-end (e2e) and package-specific tests. The package-specific tests reside inside of each package and can be run with `yarn test:packages`. The end-to-end tests can be run with `yarn test:e2e`. To run both, you can run `yarn test`.
There are two kinds of tests - end-to-end (e2e) and package-specific tests. The package-specific tests reside inside of each package and can be run with `pnpm test --recursive`. The end-to-end tests can be run with `pnpm run test:e2e`.

Note that the end-to-end tests run create-single-spa several times to create several "fixture" directories, which takes a fair amount of time. To avoid having to recreate the fixtures every test run, the tests will reuse an existing fixtures directory if one is present. This means you only have to create the fixtures once. To clean out a specific fixture so that it is recreated, simply delete the directory. To clean out all fixtures, you can run `yarn clean-tests`.
Note that the end-to-end tests run create-single-spa several times to create several "fixture" directories, which takes a fair amount of time. To avoid having to recreate the fixtures every test run, the tests will reuse an existing fixtures directory if one is present. This means you only have to create the fixtures once. To clean out a specific fixture so that it is recreated, simply delete the directory. To clean out all fixtures, you can run `pnpm run clean-tests`.

You can also run only one e2e test by specifying the name of the test in the cli `yarn test:e2e react-app-js-webpack`. Also, you can add `--watch` to any yarn test:e2e command to get the jest watcher.
You can also run only one e2e test by specifying the name of the test in the cli `pnpm run test:e2e react-app-js-webpack`. Also, you can add `--watch` to any pnpm test:e2e command to get the jest watcher.

If you're having trouble diagnosing why a test is failing, try running the tests manually in a command line. Change directories via `cd tests/fixtures/<fixture-name>` and then run `yarn build` (or whichever command is failing).
If you're having trouble diagnosing why a test is failing, try running the tests manually in a command line. Change directories via `cd tests/fixtures/<fixture-name>` and then run `pnpm run build` (or whichever command is failing).
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
testEnvironment: "node",
// Fun times waiting on yarn / npm install inside of CI
// Fun times waiting on pnpm installs inside of CI
testTimeout: 120000,
testRegex: "tests\\/e2e\\/.+test.js",
watchPathIgnorePatterns: ["<rootDir>/tests/fixtures/"],
Expand Down
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
{
"name": "root",
"devDependencies": {
"@changesets/cli": "^2.14.1",
"@types/jest": "^26.0.16",
"concurrently": "^5.3.0",
"husky": "^4.3.5",
"husky": "^4.3.8",
"jest": "^26.6.3",
"jest-cli": "^26.6.3",
"lerna": "^3.22.1",
"jest-util": "^26.6.2",
"mkdirp": "^1.0.4",
"nixt": "^0.5.1",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"rimraf": "^3.0.2"
},
"scripts": {
"bootstrap": "lerna bootstrap",
"clean-tests": "rimraf tests/fixtures",
"test": "yarn clean-tests && concurrently -n w: 'yarn:test:*'",
"test:packages": "lerna run test",
"test": "pnpm run clean-tests && pnpm run test:e2e",
"test:e2e": "jest",
"lint": "lerna run lint",
"publish-all": "lerna publish",
"format": "prettier \"./**/*\" --write"
"format": "prettier . --write"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-single-spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"generator-single-spa": "^2.1.1",
"generator-single-spa": "workspace:*",
"yargs": "^16.2.0",
"yeoman-environment": "^2.10.3"
}
Expand Down
Loading

0 comments on commit 905c0cc

Please sign in to comment.