Skip to content

Meta: Separate CI workflows #487

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

Merged
merged 26 commits into from
Jun 1, 2023
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
32 changes: 32 additions & 0 deletions .github/actions/prepare-playground/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Clone the repository, install dependencies, and configures nx variables

runs:
using: 'composite'
steps:
- name: Fetch trunk
shell: bash
run: git fetch origin trunk --depth=1
- uses: actions/setup-node@v3
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
shell: bash
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci
- name: Set NX_BASE
shell: bash
run: echo "NX_BASE=$(git rev-parse origin/trunk)" >> $GITHUB_ENV
- name: Set NX_HEAD
shell: bash
run: echo "NX_HEAD=$(git rev-parse HEAD)" >> $GITHUB_ENV
40 changes: 29 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,37 @@ on:
pull_request:

jobs:
main:
warmup-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'trunk'
- run: npm ci
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare-playground
format:
runs-on: ubuntu-latest
needs: [warmup-cache]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare-playground
- run: npx nx format:check || npx prettier --check .
- run: npx nx affected --target=lint
typecheck:
runs-on: ubuntu-latest
needs: [warmup-cache]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare-playground
- run: npx nx affected --target=typecheck
- run: npx nx affected --target=lint --parallel=3
- run: npx nx affected --target=test --parallel=3 --configuration=ci
test:
runs-on: ubuntu-latest
needs: [warmup-cache]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare-playground
- run: npx nx affected --target=test --configuration=ci
build:
runs-on: ubuntu-latest
needs: [warmup-cache]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare-playground
- run: npx nx affected --target=build --parallel=3