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

Yarn Workspaces #32

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 0 additions & 28 deletions .all-dependencies.js

This file was deleted.

10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,jsx,ts,tsx,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
62 changes: 0 additions & 62 deletions .eslint-rules.js

This file was deleted.

35 changes: 35 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Setup Environment
inputs:
yarn-workspaces-focus:
required: false
type: string
skip-yarn-install:
required: false
default: false
runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
- name: Enable Corepack
shell: bash
run: corepack enable
- name: Cache node_modules
if: ${{ inputs.skip-yarn-install != 'true' }}
uses: actions/cache@v4
env:
cache-name: node_modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ env.cache-name }}${{ inputs.yarn-workspaces-focus && format('-{0}', inputs.yarn-workspaces-focus) || '' }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}${{ inputs.yarn-workspaces-focus && format('-{0}', inputs.yarn-workspaces-focus) || '' }}-
save-always: true
- name: Install dependencies
if: ${{ inputs.skip-yarn-install != 'true' }}
shell: bash
run: |
yarn preinstall
${{ inputs.yarn-workspaces-focus && format('yarn workspaces focus {0}', inputs.yarn-workspaces-focus) || 'yarn install'}}
95 changes: 95 additions & 0 deletions .github/workflows/basic-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Basic Tests
on:
push:
branches:
- main
paths-ignore:
- '**/README.md'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
paths-ignore:
- '**/README.md'

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Environment
uses: ./.github/actions/setup-environment
- name: Lint
run: |
yarn lint

typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Environment
uses: ./.github/actions/setup-environment
- name: Typecheck
run: |
yarn typecheck

prepare-test:
name: Prepare Test
runs-on: ubuntu-latest
outputs:
# Expose the workspace path output from the list-workspaces step for other jobs to use it.
workspace-paths: ${{ steps.list-workspaces.outputs.workspace-paths }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Environment
uses: ./.github/actions/setup-environment
with:
skip-yarn-install: true
- name: List workspaces with tests
uses: zetavg/[email protected]
id: list-workspaces
with:
# Check if the workspace has a "test" script defined in its package.json.
condition: '[ -f "$workspace_path/package.json" ] && jq -e ".scripts.test" "$workspace_path/package.json"'

test:
needs: prepare-test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Use the workspace paths from the prepare-test job to create a matrix of workspaces to test.
dir: ${{ fromJson(needs.prepare-test.outputs.workspace-paths) }}
name: Test ${{ matrix.dir }}
defaults:
run:
working-directory: ${{ matrix.dir }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get workspace package name
id: get-workspace-package-name
run: |
package_name=$(jq -r '.name' package.json)
echo "Package name: ${package_name}"
echo "name=${package_name}" >> $GITHUB_OUTPUT
- name: Setup environment
uses: ./.github/actions/setup-environment
# with:
# yarn-workspaces-focus: ${{ steps.get-workspace-package-name.outputs.name }}
- name: Test
run: |
FORCE_COLOR=true yarn test
Loading
Loading