Skip to content

Transition to Yarn Workspaces #21

Transition to Yarn Workspaces

Transition to Yarn Workspaces #21

Workflow file for this run

name: New Workflow
permissions:
contents: read
on:
pull_request:
branches:
- master
jobs:
find-packages:
name: Get packages within the repository
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
- name: Enable corepack
run: corepack enable
- name: Install action packages
run: yarn workspaces focus @sourceacademy/modules-github-actions
- name: Build actions
run: |
cd ./.github/actions
yarn build
- name: Get Package Information
id: info
uses: ./.github/actions/src/info
outputs:
bundles: ${{ steps.info.outputs.bundles }}
tabs: ${{ steps.info.outputs.tabs }}
libs: ${{ steps.info.outputs.libs }}
libraries:
name: Libaries
runs-on: ubuntu-latest
needs: find-packages
strategy:
fail-fast: false
matrix:
lib: ${{ fromJson(needs.find-packages.outputs.libs) }}
steps:
- name: Check out source code
uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js 💻
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: yarn
- name: Install Dependencies
run: yarn workspaces focus ${{ matrix.lib.name }}
- name: Install Playwright (if needed)
if: matrix.lib.changes == 'true' && matrix.lib.needsPlaywright
run: |
cd ${{ matrix.lib.directory }}
yarn playwright install --with-deps
- name: Run Tests
if: matrix.lib.changes == 'true'
run: |
cd ${{ matrix.lib.directory }}
yarn test
- name: Run Auxillary Tasks
if: matrix.lib.changes == 'true'
run: |
cd ${{ matrix.lib.directory }}
yarn tsc
yarn lint
tabs:
name: Tabs
runs-on: ubuntu-latest
needs: find-packages
strategy:
fail-fast: false
matrix:
tabInfo: ${{ fromJson(needs.find-packages.outputs.tabs) }}
steps:
- name: Check out source code
uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js 💻
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: yarn
- name: Install Dependencies
run: yarn workspaces focus ${{ matrix.tabInfo.name }}
- name: Build Tab
run: yarn workspaces foreach -A --include ${{ matrix.tabInfo.name }} run build
- name: Cache Tab
uses: actions/cache/save@v4
with:
path: ./build/tabs/${{ matrix.tabInfo.tabName }}.js
key: ${{ matrix.tabInfo.name }}
- name: Install Playwright (if needed)
if: matrix.tabInfo.changes == 'true' && matrix.tabInfo.needsPlaywright
run: |
cd ${{ matrix.tabInfo.directory }}
yarn playwright install --with-deps
- name: Run Tests
if: matrix.tabInfo.changes == 'true'
run: |
cd ${{ matrix.tabInfo.directory }}
yarn test
- name: Run Auxillary Tasks
if: matrix.tabInfo.changes == 'true'
run: |
cd ${{ matrix.tabInfo.directory }}
yarn tsc
yarn lint
bundles:
name: Bundles
runs-on: ubuntu-latest
needs: find-packages
strategy:
fail-fast: false
matrix:
bundleInfo: ${{ fromJson(needs.find-packages.outputs.bundles) }}
steps:
- name: Check out source code
uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js 💻
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: yarn
- name: Install Dependencies
run: yarn workspaces focus ${{ matrix.bundleInfo.name }}
- name: Build Bundle
run: |
cd ${{ matrix.bundleInfo.directory }}
yarn build
yarn tsc
- name: Cache Buildtools Compiled Bundle
uses: actions/cache/save@v4
with:
path: ./build/bundles/${{ matrix.bundleInfo.bundleName }}.js
key: ${{ matrix.bundleInfo.name }}-buildtools
- name: Cache tsc Compiled Bundle
uses: actions/cache/save@v4
with:
path: ${{ matrix.bundleInfo.directory }}/dist
key: ${{ matrix.bundleInfo.name }}-tsc
- name: Run Tests
if: matrix.bundleInfo.changes == 'true'
run: |
cd ${{ matrix.bundleInfo.directory }}
yarn test
- name: Run Auxillary Tasks
if: matrix.bundleInfo.changes == 'true'
run: |
cd ${{ matrix.bundleInfo.directory }}
yarn tsc
yarn lint
devserver:
name: Dev Server Tests
runs-on: ubuntu-latest
needs:
- bundles
- tabs
steps:
- name: Check out source code
uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js 💻
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: yarn
- name: Install Dependencies
run: yarn workspaces focus @sourceacademy/modules-devserver