Skip to content

Yarn Workspaces Follow Up #1852

Yarn Workspaces Follow Up

Yarn Workspaces Follow Up #1852

Workflow file for this run

name: On Pull Request
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@v5
- name: Initialize Github Actions
uses: ./.github/actions/src/init
with:
package-name: '@sourceacademy/modules-github-actions'
- name: Build actions
run: |
cd ./.github/actions
yarn build
- name: Test Actions
run: |
cd ./.github/actions
yarn test
- name: Fetch Master branch
run: git fetch origin master
- name: Get Package Information
id: info
uses: ./.github/actions/src/info
outputs:
bundles: ${{ steps.info.outputs.bundles }}
libs: ${{ steps.info.outputs.libs }}
tabs: ${{ steps.info.outputs.tabs }}
devserver: ${{ steps.info.outputs.devserver }}
docserver: ${{ steps.info.outputs.docserver }}
workflows: ${{ steps.info.outputs.workflows }}
libraries:
if: ${{ needs.find-packages.outputs.libs != '[]' }}
needs: find-packages
strategy:
fail-fast: false
matrix:
lib: ${{ fromJson(needs.find-packages.outputs.libs) }}
os: ['ubuntu-latest', 'windows-latest']
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'pwsh' || 'bash' }}
name: ${{ matrix.lib.name }} library (${{ matrix.os }})
steps:
- name: Check out source code
uses: actions/checkout@v5
- name: Initialize ${{ matrix.lib.name }}
uses: ./.github/actions/src/init
with:
package-name: ${{ matrix.lib.name }}
playwright: ${{ matrix.lib.needsPlaywright }}
shell: ${{ matrix.os == 'windows-latest' && 'pwsh' || 'bash' }}
# Only thing we really need to do on Windows is run tests (without coverage)
- name: Run Tests (Windows)
if: matrix.os == 'windows-latest'
run: yarn workspaces foreach -A --include ${{ matrix.lib.name }} run test
- name: Run Tests (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: yarn workspaces foreach -A --include ${{ matrix.lib.name }} run test --coverage
- name: Run Auxillary Tasks
if: matrix.os == 'ubuntu-latest'
run: yarn workspaces foreach -A --include ${{ matrix.lib.name }} run tsc
tabs:
if: ${{ needs.find-packages.outputs.tabs != '[]' }}
runs-on: ubuntu-latest
needs: find-packages
strategy:
fail-fast: false
matrix:
tabInfo: ${{ fromJson(needs.find-packages.outputs.tabs) }}
name: ${{ matrix.tabInfo.tabName }} Tab
steps:
- name: Check out source code
uses: actions/checkout@v5
- name: Initialize ${{ matrix.tabInfo.tabName }}
uses: ./.github/actions/src/init
with:
package-name: ${{ matrix.tabInfo.name }}
playwright: ${{ matrix.tabInfo.needsPlaywright && matrix.tabInfo.changes }}
- name: Build Tab
run: |
cd ${{ matrix.tabInfo.directory }}
yarn build
- name: Upload Tab Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tabInfo.tabName }}-tab
path: ./build/tabs/${{ matrix.tabInfo.tabName }}.js
- name: Run Tests
# https://github.com/vitest-dev/vitest/issues/5477
# Known Vitest issue for coverage running in browser mode
# Momentarily disable coverage checking on Github Actions for tabs
run: |
cd ${{ matrix.tabInfo.directory }}
yarn test
- name: Run Auxillary Tasks
run: |
cd ${{ matrix.tabInfo.directory }}
yarn tsc
bundles:
if: ${{ needs.find-packages.outputs.bundles != '[]' }}
runs-on: ubuntu-latest
needs: find-packages
strategy:
fail-fast: false
matrix:
bundleInfo: ${{ fromJson(needs.find-packages.outputs.bundles) }}
name: ${{ matrix.bundleInfo.bundleName }} Bundle
steps:
- name: Check out source code
uses: actions/checkout@v5
- name: Initialize ${{ matrix.bundleInfo.name }}
uses: ./.github/actions/src/init
with:
package-name: ${{ matrix.bundleInfo.name }}
playwright: ${{ matrix.bundleInfo.needsPlaywright }}
- name: Build Bundle
run: |
cd ${{ matrix.bundleInfo.directory }}
yarn build
yarn tsc
- name: Build Bundle Docs
run: |
cd ${{ matrix.bundleInfo.directory }}
yarn buildtools build docs
- name: Run Tests
run: |
cd ${{ matrix.bundleInfo.directory }}
yarn test --coverage
devserver:
name: Dev Server Tasks
runs-on: ubuntu-latest
needs:
- find-packages
- tabs
if: >-
${{
always() &&
!cancelled() &&
fromJson(needs.find-packages.outputs.devserver).changes &&
needs.find-packages.result == 'success' &&
(needs.find-packages.outputs.tabs == '[]' || needs.tabs.result == 'success')
}}
steps:
- name: Check out source code
uses: actions/checkout@v5
- name: Enable Corepack
run: corepack enable
- name: Install dependencies for other actions
run: yarn workspaces focus @sourceacademy/modules-github-actions
- name: Load/Build all tabs
uses: ./.github/actions/src/load-artifacts
- name: Initialize Devserver
uses: ./.github/actions/src/init
with:
package-name: '@sourceacademy/modules-devserver'
playwright: true
- name: Build Manifest
run: |
cd ./devserver
yarn buildtools manifest
- name: Run tests
run: |
cd ./devserver
yarn test --coverage
- name: Run Auxillary Tasks
run: |
cd ./devserver
yarn tsc
docserver:
name: Docs Server Tasks
runs-on: ubuntu-latest
needs:
- libraries
- find-packages
if: >-
${{
always() &&
!cancelled() &&
fromJson(needs.find-packages.outputs.docserver).changes &&
needs.find-packages.result == 'success' &&
(needs.find-packages.outputs.libs == '[]' || needs.libraries.result == 'success')
}}
steps:
- name: Check out source code
uses: actions/checkout@v5
- name: Initialize Docserver
uses: ./.github/actions/src/init
with:
package-name: '@sourceacademy/modules-docserver'
- name: Spellcheck
run: |
cd ./docs
yarn spellcheck
- name: Build Docs
run: |
cd ./docs
yarn build
repo-tasks:
name: Repo Wide Tasks
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v5
- name: Initialize Repo
uses: ./.github/actions/src/init
with:
package-name: '@sourceacademy/modules'
- name: Check constraints
run: yarn constraints
- name: Lint Everything
run: yarn lint:all
- name: Build Manifest
run: yarn buildtools manifest
# Not sure if we need to upload this as an artifact
# - name: Upload Manifest
# uses: actions/upload-artifact@v4
# with:
# name: manifest
# path: ./build/modules.json
test:
name: Verify all tests pass and build success
runs-on: ubuntu-latest
needs:
- libraries
- tabs
- bundles
- devserver
- docserver
- repo-tasks
steps:
- name: All done! 🎉
run: echo "All tasks completed successfully!"