Skip to content

Transition to Yarn Workspaces #36

Transition to Yarn Workspaces

Transition to Yarn Workspaces #36

Workflow file for this run

name: new-workflow
permissions:
contents: read
on:
pull_request:
branches:
- master
jobs:
setup-repotools:
name: Setup Repotools package
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
with:
sparse-checkout: ./lib/repotools
- name: Enable Corepack
run: corepack enable
- name: Use Node.js 💻
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: yarn
- name: Check cache for repotools
uses: actions/cache/restore@v4
id: cache-repotools
with:
path: ./lib/repotools/dist
key: repotools
- name: Install Repotools Dependencies
run: yarn workspaces focus @sourceacademy/modules-repotools
- name: Build Repotools
if: steps.cache-repotools.outputs.cache-hit != 'true'
run: yarn workspaces foreach -A --include @sourceacademy/modules-repotools run build
- name: Cache Repotools
if: steps.cache-repotools.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ./lib/repotools/dist
key: repotools
find-packages:
name: Determine the packages present in the repo for the given type
needs: setup-repotools
runs-on: ubuntu-latest
strategy:
matrix:
type: ['libs', 'bundles', 'tabs']
outputs:
libs: ${{ steps.find.outputs.libs }}
bundles: ${{ steps.find.outputs.bundles }}
tabs: ${{ steps.find.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: Setup actions
run: yarn workspaces focus @sourceacademy/modules-github-actions --production
- name: Find Packages
id: find
uses: ./.github/actions/src/info
with:
type: ${{ matrix.type }}
build-libs:
name: Build and compile libraries
runs-on: ubuntu-latest
needs: find-packages
strategy:
matrix:
package: ${{ fromJSON(needs.find-packages.outputs.libs) }}
steps:
- name: Check out source code
uses: actions/checkout@v4
# with:
# sparse-checkout: ${{ matrix.package.directory }}
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn workspaces focus ${{ matrix.package.name }}
- name: Check cache
uses: actions/cache/restore@v4
id: cache
with:
path: ${{ matrix.package.directory }}/dist
key: ${{ matrix.package.name }}
- name: Build ${{ matrix.package.name }}
if: steps.cache.outputs.cache-hit != 'true'
run: yarn workspaces foreach -A --include ${{ matrix.package.name }} run build
- name: Store in Cache
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ matrix.package.directory }}/dist
key: ${{ matrix.package.name }}
# test-libs:
# name: Test and Typecheck libraries
# runs-on: ubuntu-latest
# needs: find-packages
# strategy:
# matrix:
# package: ${{ 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.package.name }}
# - name: Restore repotools
# uses: actions/cache/restore@v4
# with:
# path: ./lib/repotools/dist
# key: repotools
# - name: tsc and test
# run: |
# cd ${{ matrix.package.directory }}
# yarn tsc
# yarn test
test-tabs:
name: Test and Typecheck tabs
runs-on: ubuntu-latest
needs:
- build-libs
- find-packages
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.find-packages.outputs.tabs) }}
defaults:
run:
working-directory: ${{ matrix.package.directory }}
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: Setup actions
run: yarn workspaces focus @sourceacademy/modules-github-actions --production
- name: Filter paths
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
changed:
- ${{ matrix.package.directory }}/**
- name: Restore buildtools
uses: actions/cache/restore@v4
with:
key: "@sourceacademy/modules-buildtools"
path: ./lib/buildtools/dist
- name: Restore repotools
uses: actions/cache/restore@v4
with:
key: "@sourceacademy/modules-repotools"
path: ./lib/repotools/dist
- name: Install dependencies
uses: ./.github/actions/src/install-deps
with:
directory: ${{ matrix.package.directory }}
packageName: ${{ matrix.package.name }}
testRequired: ${{ steps.filter.outputs.changed == 'true' }}
- name: tsc and test
if: steps.filter.outputs.changed == 'true'
run: |
yarn tsc
yarn test
- name: Build
run: yarn build