Skip to content
Merged
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
40 changes: 12 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ jobs:
build:
runs-on: ${{ matrix.os }}

# TODO(NODE16): Re-enable node16.
# Presently, serverless has _huge_ zips that are way bigger than expected
# on node16 (which also fails tests). We might just upgrade serverless
# first, then reenable tests.
# https://github.com/FormidableLabs/serverless-jetpack/issues/239
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [12.x, 14.x]
node-version: [22.x, 24.x]

steps:
# Checkout
Expand All @@ -29,27 +24,23 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"

- name: Use node_modules cache
id: node-modules-cache
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('./yarn.lock') }}
key: node-modules-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
node-modules-${{ runner.os }}-${{ matrix.node-version }}-
node-modules-${{ runner.os }}-

- name: Project installation
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --prefer-offline --frozen-lockfile --non-interactive
run: npm ci
env:
CI: true

- name: Checks (lint, unit tests)
run: yarn run check

# Caching: test scenarios
# **Note**: _don't_ use permissive restore-keys because we skip installs
# all together.
Expand All @@ -58,22 +49,15 @@ jobs:
uses: actions/cache@v4
with:
path: |
test/packages/*/npm/node_modules
test/packages/*/yarn/node_modules
key: test-packages-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('test/packages/*/npm/package-lock.json', 'test/packages/*/yarn/yarn.lock') }}
test/packages/*/node_modules
key: test-packages-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('test/packages/*/package-lock.json') }}

# Detect if `test/packages/*/*/node_modules` exists in any form and skip
# installs on a per-directory basis.
- name: Benchmark installation
if: steps.test-packages-cache.outputs.cache-hit != 'true'
run: yarn benchmark:ci --skip-if-exists
env:
CI: true
- name: Install test fixtures
run: npm run test:install

- name: CLI tests
run: yarn test:cli
# Note: linting also catches the `test/packages/*` fixtures.
- name: Checks (lint, unit tests)
run: npm run check

- name: Benchmark
run: yarn benchmark --parallel
- name: Benchmark tests
run: yarn benchmark:test
- name: CLI tests
run: npm run test:cli
15 changes: 6 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,23 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 24

- name: Install dependencies
run: yarn install --frozen-lockfile
run: npm ci

- name: Build
run: yarn build

- name: Testing Setups
run: yarn benchmark:ci
run: npm run build

- name: Unit Tests
run: yarn test:cli
run: npm run test:cli

- name: PR or Publish
id: changesets
uses: changesets/action@v1
with:
version: yarn changeset version
publish: yarn changeset publish
version: npm exec changeset version
publish: npm exec changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
node_modules
npm-debug.log*
yarn-error.log*
/package-lock.json
yarn.lock
/all-lock-files.txt

aws/.service*
Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

137 changes: 14 additions & 123 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,116 +5,27 @@ Thanks for contributing!

## Development

We primarily develop in `yarn`, but use `npm` in our benchmarks. Please make sure to have something like:
We manage dependencies using `npm`. Note that for the time being, our development tools assume a Unix-like environment, which means Mac, Linux, or something like the Windows Subsystem for Linux.

* node: `8+`
* yarn: (anything modern)
* npm: (anything modern)

available. Also note that for the time being, our development tools assume a Unix-like environment, which means Mac, Linux, or something like the Windows Subsystem for Linux.

Our development revolves around various fixture packages we have in `test`. Get set up with:

```sh
$ yarn

# If not changing deps
$ yarn benchmark:ci
# If changing deps
$ yarn benchmark:install
```

to install the root project and a lot of fixture packages. (This is **meant** to take a while as we install a lot of dependencies to give us sizable app simulations to work with...) You will need to re-run `benchmark:install` whenever you update dependencies inside `test/` packages.

Our present fixture setup is:

```
$ tree test/packages/ -L 2
test/packages/
├── complex
│   ├── npm
│   └── yarn
└── simple
├── npm
└── yarn
```

**Note**: Only **some** of the scenarios contribute to the timed benchmark results as some scenarios don't actually use either built-in Serverless or Jetpack packaging.

For ease of development, we want to do `yarn benchmark:ci`/`yarn benchmark:install` and install the respective yarn/npm packages **once**. However, this means we keep duplicates of source code / package.json files across the `npm`/`yarn` variant directories. To keep things in sync, we designate the `yarn` directory as "the source of truth" for everything except for `SCENARIO/npm/package-lock.json` and copy files across scenarios with:

```sh
$ yarn benchmark:build
```

From there you can run various packaging configurations and perform benchmarks.

```sh
$ TEST_PKG=yarn TEST_SCENARIO=simple yarn benchmark
$ TEST_PKG=yarn TEST_SCENARIO=simple,complex yarn benchmark
$ TEST_PKG=yarn,npm TEST_SCENARIO=simple yarn benchmark

# Faster, because scenarios run in parallel, but less reliable results because
# of impact on your machine. Use this for faster development, but do a normal
# serial benchmark for pasting results.
# ... using all CPU cores
$ yarn benchmark --parallel
# ... or set the level of concurrency manually
$ yarn benchmark --concurrency=2
```

After this, we can run benchmark specific QA stuff:
Get set up with:

```sh
$ yarn benchmark:test
$ npm install
$ npm run test:install
```

(The `lint` needs the individual installs and `test` needs file list output from a full benchmark).
to install the root project and our test fixtures.

## Checks

### Fast stuff

Run these often -- unit tests and lint:

```sh
$ yarn lint
$ yarn test
$ npm run lint
$ npm run test

# ... or all together ...
$ yarn run check
```

### Slow stuff

Run these before a PR and when changing things / kicking tires...

*Requirements*: For CLI and benchmark tests...

```sh
# Install once (or on changes to dependencies or fixtures)
$ yarn benchmark:ci # or yarn benchmark:install if changing deps
$ yarn benchmark:build
```

*CLI tests*: Use the fixtures

```sh
$ yarn test:cli
```

*Benchmark tests*: Run the benchmark to gather data and assess correctness of packages vs. real Serverless.

```sh
$ yarn benchmark
$ yarn benchmark:test
```

*Serverless Enterprise*: Unfortunately, these tests require a login account and special `SERVERLESS_ACCESS_KEY` environment variable. The Jetpack project has two active tokens for `localdev` and `ci`. You can enable these and our `dashboard` tests with something like:

```sh
$ SERVERLESS_ACCESS_KEY="<INSERT_HERE>" yarn benchmark
$ SERVERLESS_ACCESS_KEY="<INSERT_HERE>" yarn benchmark:test
$ npm run check
```

## Before submitting a PR...
Expand All @@ -123,34 +34,14 @@ Before you go ahead and submit a PR, make sure that you have done the following:

```sh
# Update the documentation TOCs (and commit changes).
$ yarn run build
$ npm run build

# Run lint and unit tests
$ yarn run check

# Make sure all fixtures are updated and valid
$ yarn benchmark:install
$ yarn benchmark:ci
$ yarn benchmark:build
$ npm run check

# After this, you can run the CLI tests which use real fixtures in E2E scenarios
# They're relatively slow (several seconds a test), but nowhere near as slow
# as the benchmark.
$ yarn test:cli

# Run a benchmark.
# Then, actually generate the benchmark.
# _Note_: Unfortunately, this takes some **time**. Grab a ☕
$ yarn benchmark
# Now, test the benchmark for correctness.
$ yarn benchmark:test

# If the timed benchmark stats and/or usage is notably different
# than what's in README.md, update relevant sections and commit your changes.
$ vim README.md

# Run all final checks.
$ yarn run check
# They're relatively slow (several seconds a test).
$ npm run test:cli
```

### Using changesets
Expand All @@ -168,7 +59,7 @@ Here are more details:
When you would like to add a changeset (which creates a file indicating the type of change), in your branch/PR issue this command:

```sh
$ yarn changeset
$ npm exec changeset
```

to produce an interactive menu. Navigate the packages with arrow keys and hit `<space>` to select 1+ packages. Hit `<return>` when done. Select semver versions for packages and add appropriate messages. From there, you'll be prompted to enter a summary of the change. Some tips for this summary:
Expand Down Expand Up @@ -211,4 +102,4 @@ On the merge of a version packages PR, the changesets GitHub action will publish
4. Run `npm publish` and publish to NPM if all is well.
5. Run `git push && git push --tags`

</details>
</details>
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019 Formidable Labs
Copyright (c) 2025 Nearform

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading
Loading