Skip to content

Commit

Permalink
Merge pull request #539 from xmtp/rygine/yarn
Browse files Browse the repository at this point in the history
Migrate to yarn, vitest
  • Loading branch information
rygine authored Feb 26, 2024
2 parents adb30f5 + c61360a commit 845d6f1
Show file tree
Hide file tree
Showing 41 changed files with 12,302 additions and 21,934 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- main
pull_request:

jobs:
build:
name: Build
Expand All @@ -13,5 +14,12 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run build
cache: 'yarn'
env:
SKIP_YARN_COREPACK_CHECK: '1'
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
50 changes: 47 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
name: Lint
name: Code checks
on:
push:
branches:
- main
pull_request:

jobs:
typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
env:
SKIP_YARN_COREPACK_CHECK: '1'
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- name: Typecheck
run: yarn typecheck

lint:
name: Lint
runs-on: ubuntu-latest
Expand All @@ -13,5 +32,30 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run lint
cache: 'yarn'
env:
SKIP_YARN_COREPACK_CHECK: '1'
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- name: Lint
run: yarn lint

prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
env:
SKIP_YARN_COREPACK_CHECK: '1'
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- name: Format check
run: yarn format:check
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
env:
SKIP_YARN_COREPACK_CHECK: '1'
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: npm ci
run: yarn
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
run: yarn semantic-release
38 changes: 30 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,46 @@ on:
branches:
- main
pull_request:

jobs:
test:
name: Test
node:
name: node
runs-on: ubuntu-latest
strategy:
matrix:
env: ['node', 'jsdom']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: npm ci
cache: 'yarn'
env:
SKIP_YARN_COREPACK_CHECK: '1'
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- run: ./dev/docker-compose up -d
- run: npm run test:${{ matrix.env }}
- run: yarn test:node
env:
NODE_OPTIONS: '-r dd-trace/ci/init'
DD_ENV: ci:${{ matrix.env }}
DD_ENV: ci:node
DD_SERVICE: xmtp-js
DD_CIVISIBILITY_AGENTLESS_ENABLED: 'true'
DD_API_KEY: ${{ secrets.DD_API_KEY }}

browser:
name: happy-dom
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
env:
SKIP_YARN_COREPACK_CHECK: '1'
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- run: ./dev/docker-compose up -d
- run: yarn test:browser
16 changes: 7 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ dist
# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
# yarn
.pnp.*
scratch
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# generated docs
docs/
Expand All @@ -125,6 +126,3 @@ tmp/

# Benchmark results
bench/results

# rollup build plugin output
build/rollup-plugin-resolve-extensions/index.js
7 changes: 2 additions & 5 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
dist
coverage
docs
tmp
build/rollup-plugin-resolve-extensions/index.js
CODEOWNERS
.yarn
1 change: 1 addition & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ module.exports = {
trailingComma: 'es5',
arrowParens: 'always',
printWidth: 80,
plugins: ['prettier-plugin-packagejson'],
}
893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.1.0.cjs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compressionLevel: mixed
enableGlobalCache: false
enableTelemetry: false
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.1.0.cjs
22 changes: 14 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,27 @@ After a pull request is submitted, a single approval is required to merge it.

Please make sure you have a compatible version as specified in `package.json`. We recommend using a Node version manager such as [nvm](https://github.com/nvm-sh/nvm) or [nodenv](https://github.com/nodenv/nodenv).

#### Yarn

This repository uses the [Yarn package manager](https://yarnpkg.com/). To use it, enable [Corepack](https://yarnpkg.com/corepack), if it isn't already, by running `corepack enable`.

### Useful commands

- `npm install`: Installs all dependencies
- `npm run bench`: Run the benchmarking suite
- `npm run build`: Builds all SDK packages
- `npm test`: Run the unit test suite
- `npm run test:setup`: Start a local development node using Docker (only needs to be run once)
- `npm run lint`: Lint with ESLint
- `npm run typecheck`: Typecheck with `tsc`
- `yarn`: Installs all dependencies
- `yarn bench`: Run the benchmarking suite
- `yarn build`: Builds the JS SDK
- `yarn format`: Run prettier format and write changes
- `yarn format:check`: Run prettier format check
- `yarn test`: Run the unit test suite
- `yarn test:setup`: Start a local development node using Docker (only needs to be run once)
- `yarn lint`: Lint with ESLint
- `yarn typecheck`: Typecheck with `tsc`

### Testing and validation

Please add unit tests when appropriate and ensure that all unit tests are passing before submitting a pull request. Note that some unit tests require a backend node to be running locally. The `test:setup` command can be run a single time to start the node in the background using Docker.

Manual validation requires setting up a client app such as the [example app](https://github.com/xmtp/example-chat-react). Once you have cloned and run the example app, it will use a published npm version of `xmtp-js` by default. You can point it to your local `xmtp-js` repository by running `npm i file:~/path/to/xmtp-js` from the `example-chat-react` directory, which will update its `package.json`. Once the example app is running, any further changes you make to `xmtp-js` will be reflected in the app after you run `npm run build` in the `xmtp-js` directory and then reload the app.
Manual validation requires setting up a client app such as the [example app](https://github.com/xmtp/example-chat-react). Once you have cloned and run the example app, it will use a published npm version of `xmtp-js` by default. You can point it to your local `xmtp-js` repository by using `yarn link` or `npm link` from the `example-chat-react` directory, which will update its `package.json`. Once the example app is running, any further changes you make to `xmtp-js` will be reflected in the app after you run `yarn build` in the `xmtp-js` directory and then reload the app.

### Auto-releasing and commit conventions

Expand Down
15 changes: 0 additions & 15 deletions jest.config.cjs

This file was deleted.

42 changes: 0 additions & 42 deletions jest.jsdom.env.cjs

This file was deleted.

Loading

0 comments on commit 845d6f1

Please sign in to comment.