Transition to Yarn Workspaces #1675
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v4 | |
- name: Initialize Repo | |
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: | |
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 | |
if: matrix.lib.changes | |
uses: actions/checkout@v4 | |
- name: Initialize Repo | |
if: matrix.lib.changes | |
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.lib.changes && matrix.os == 'windows-latest' | |
run: yarn workspaces foreach -A --include ${{ matrix.lib.name }} run test | |
- name: Run Tests (Ubuntu) | |
if: matrix.lib.changes && matrix.os == 'ubuntu-latest' | |
run: yarn workspaces foreach -A --include ${{ matrix.lib.name }} run test --coverage | |
- name: Run Auxillary Tasks | |
if: matrix.lib.changes && matrix.os == 'ubuntu-latest' | |
run: yarn workspaces foreach -A --include ${{ matrix.lib.name }} run tsc | |
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 | |
if: matrix.tabInfo.changes | |
uses: actions/checkout@v4 | |
- name: Initialize Repo | |
if: matrix.tabInfo.changes | |
uses: ./.github/actions/src/init | |
with: | |
package-name: ${{ matrix.tabInfo.name }} | |
playwright: ${{ matrix.tabInfo.needsPlaywright && matrix.tabInfo.changes }} | |
- name: Build Tab | |
if: matrix.tabInfo.changes | |
run: | | |
cd ${{ matrix.tabInfo.directory }} | |
yarn build | |
- name: Upload Tab Artifact | |
if: matrix.tabInfo.changes | |
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 | |
if: matrix.tabInfo.changes | |
run: | | |
cd ${{ matrix.tabInfo.directory }} | |
yarn test | |
- name: Run Auxillary Tasks | |
if: matrix.tabInfo.changes | |
run: | | |
cd ${{ matrix.tabInfo.directory }} | |
yarn tsc | |
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 | |
if: matrix.bundleInfo.changes | |
uses: actions/checkout@v4 | |
- name: Initialize Repo | |
if: matrix.bundleInfo.changes | |
uses: ./.github/actions/src/init | |
with: | |
package-name: ${{ matrix.bundleInfo.name }} | |
playwright: ${{ matrix.bundleInfo.needsPlaywright }} | |
- name: Build Bundle | |
if: matrix.bundleInfo.changes | |
run: | | |
cd ${{ matrix.bundleInfo.directory }} | |
yarn build | |
yarn tsc | |
- name: Build Bundle Docs | |
if: matrix.bundleInfo.changes | |
run: | | |
cd ${{ matrix.bundleInfo.directory }} | |
yarn buildtools build docs | |
- name: Run Tests | |
if: matrix.bundleInfo.changes | |
run: | | |
cd ${{ matrix.bundleInfo.directory }} | |
yarn test --coverage | |
devserver: | |
name: Dev Server Tasks | |
runs-on: ubuntu-latest | |
needs: | |
- find-packages | |
- tabs | |
if: ${{ fromJson(needs.find-packages.outputs.devserver).changes }} | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v4 | |
- 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 Repo | |
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: ${{ fromJson(needs.find-packages.outputs.docserver).changes }} | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v4 | |
- name: Initialize Repo | |
uses: ./.github/actions/src/init | |
with: | |
package-name: '@sourceacademy/modules-docserver' | |
- 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@v4 | |
- 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 |