Skip to content

Commit 82cf7f8

Browse files
committed
Fix missing dependencies again
1 parent 9081a13 commit 82cf7f8

File tree

4 files changed

+142
-10
lines changed

4 files changed

+142
-10
lines changed

.github/actions/src/info/index.ts

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@ import pathlib from 'path';
33
import * as core from '@actions/core';
44
import { getExecOutput } from '@actions/exec';
55

6-
interface PackageRecord {
6+
interface BasePackageRecord {
77
directory: string
88
name: string
99
changes: boolean
1010
needsPlaywright: boolean
1111
}
1212

13+
interface BundlePackageRecord extends BasePackageRecord {
14+
bundleName: string;
15+
}
16+
17+
interface TabPackageRecord extends BasePackageRecord {
18+
tabName: string;
19+
}
20+
21+
type PackageRecord = BundlePackageRecord | TabPackageRecord | BasePackageRecord;
22+
1323
/**
1424
* Returns `true` if there are changes present in the given directory relative to
1525
* the master branch\
@@ -31,7 +41,9 @@ async function checkForChanges(directory: string) {
3141
* Recursively locates the packages present in a directory, up to an optional max depth
3242
*/
3343
async function findPackages(directory: string, maxDepth?: number) {
34-
const output: PackageRecord[] = [];
44+
const output: BasePackageRecord[] = [];
45+
const RE = /^@sourceacademy\/(.+?)-(.+)$/u;
46+
3547
async function* recurser(currentDir: string, currentDepth: number): AsyncGenerator<PackageRecord> {
3648
if (maxDepth !== undefined && currentDepth >= maxDepth) return;
3749

@@ -42,13 +54,46 @@ async function findPackages(directory: string, maxDepth?: number) {
4254
if (item.name === 'package.json') {
4355
try {
4456
const { default: { name, devDependencies } } = await import(fullPath, { with: { type: 'json' }});
57+
const match = RE.exec(name);
4558
const changes = await checkForChanges(currentDir);
46-
yield {
47-
directory: currentDir,
48-
changes,
49-
name,
50-
needsPlaywright: 'playwright' in devDependencies
51-
};
59+
60+
if (!match) {
61+
throw new Error(`Failed to match package name: ${name}`);
62+
}
63+
64+
const [,packageType, packageBaseName] = match;
65+
66+
switch (packageType) {
67+
case 'bundle': {
68+
yield {
69+
directory: currentDir,
70+
changes,
71+
name,
72+
needsPlaywright: false,
73+
bundleName: packageBaseName,
74+
};
75+
break;
76+
}
77+
case 'tab': {
78+
yield {
79+
directory: currentDir,
80+
changes,
81+
name,
82+
needsPlaywright: 'playwright' in devDependencies,
83+
tabName: packageBaseName,
84+
};
85+
break;
86+
}
87+
default: {
88+
yield {
89+
directory: currentDir,
90+
changes,
91+
name,
92+
needsPlaywright: 'playwright' in devDependencies
93+
};
94+
break;
95+
}
96+
}
5297
return;
5398
} catch {}
5499
}
@@ -77,7 +122,7 @@ async function main() {
77122
libs: pathlib.join(gitRoot, 'lib'),
78123
bundles: pathlib.join(gitRoot, 'src', 'bundles'),
79124
tabs: pathlib.join(gitRoot, 'src', 'tabs')
80-
}).map(async ([packageType, dirPath]): Promise<[string, PackageRecord[]]> => {
125+
}).map(async ([packageType, dirPath]): Promise<[string, BasePackageRecord[]]> => {
81126
const packages = await findPackages(dirPath);
82127
core.info(`Found ${packages.length} ${packageType} packages`);
83128
return [packageType, packages];

.github/workflows/workflow-again.yml

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,49 @@ jobs:
3737
tabs: ${{ steps.info.outputs.tabs }}
3838
libs: ${{ steps.info.outputs.libs }}
3939

40+
libraries:
41+
name: Libaries
42+
runs-on: ubuntu-latest
43+
needs: find-packages
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
lib: ${{ fromJson(needs.find-packages.outputs.libs) }}
48+
steps:
49+
- name: Check out source code
50+
uses: actions/checkout@v4
51+
52+
- name: Enable Corepack
53+
run: corepack enable
54+
55+
- name: Use Node.js 💻
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version-file: .node-version
59+
cache: yarn
60+
61+
- name: Install Dependencies
62+
run: yarn workspaces focus ${{ matrix.lib.name }}
63+
64+
- name: Install Playwright (if needed)
65+
if: matrix.lib.changes == 'true' && matrix.lib.needsPlaywright
66+
run: |
67+
cd ${{ matrix.lib.directory }}
68+
yarn playwright install --with-deps
69+
70+
- name: Run Tests
71+
if: matrix.lib.changes == 'true'
72+
run: |
73+
cd ${{ matrix.lib.directory }}
74+
yarn test
75+
76+
- name: Run Auxillary Tasks
77+
if: matrix.lib.changes == 'true'
78+
run: |
79+
cd ${{ matrix.lib.directory }}
80+
yarn tsc
81+
yarn lint
82+
4083
tabs:
4184
name: Tabs
4285
runs-on: ubuntu-latest
@@ -65,6 +108,12 @@ jobs:
65108
- name: Build Tab
66109
run: yarn workspaces foreach -A --include ${{ matrix.tabInfo.name }} run build
67110

111+
- name: Cache Tab
112+
uses: actions/cache/save@v4
113+
with:
114+
path: ./build/tabs/${{ matrix.tabInfo.tabName }}.js
115+
key: ${{ matrix.tabInfo.name }}
116+
68117
- name: Install Playwright (if needed)
69118
if: matrix.tabInfo.changes == 'true' && matrix.tabInfo.needsPlaywright
70119
run: |
@@ -115,6 +164,18 @@ jobs:
115164
yarn build
116165
yarn tsc
117166
167+
- name: Cache Buildtools Compiled Bundle
168+
uses: actions/cache/save@v4
169+
with:
170+
path: ./build/bundles/${{ matrix.bundleInfo.bundleName }}.js
171+
key: ${{ matrix.bundleInfo.name }}-buildtools
172+
173+
- name: Cache tsc Compiled Bundle
174+
uses: actions/cache/save@v4
175+
with:
176+
path: ${{ matrix.bundleInfo.directory }}/dist
177+
key: ${{ matrix.bundleInfo.name }}-tsc
178+
118179
- name: Run Tests
119180
if: matrix.bundleInfo.changes == 'true'
120181
run: |
@@ -127,4 +188,26 @@ jobs:
127188
cd ${{ matrix.bundleInfo.directory }}
128189
yarn tsc
129190
yarn lint
130-
191+
192+
devserver:
193+
name: Dev Server Tests
194+
runs-on: ubuntu-latest
195+
needs:
196+
- bundles
197+
- tabs
198+
199+
steps:
200+
- name: Check out source code
201+
uses: actions/checkout@v4
202+
203+
- name: Enable Corepack
204+
run: corepack enable
205+
206+
- name: Use Node.js 💻
207+
uses: actions/setup-node@v4
208+
with:
209+
node-version-file: .node-version
210+
cache: yarn
211+
212+
- name: Install Dependencies
213+
run: yarn workspaces focus @sourceacademy/modules-devserver

src/bundles/midi/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"@sourceacademy/modules-buildtools": "workspace:^",
77
"typescript": "^5.8.2"
88
},
9+
"dependencies": {
10+
"js-slang": "^1.0.81"
11+
},
912
"type": "module",
1013
"scripts": {
1114
"build": "buildtools build bundle .",

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,6 +3163,7 @@ __metadata:
31633163
resolution: "@sourceacademy/bundle-midi@workspace:src/bundles/midi"
31643164
dependencies:
31653165
"@sourceacademy/modules-buildtools": "workspace:^"
3166+
js-slang: "npm:^1.0.81"
31663167
typescript: "npm:^5.8.2"
31673168
languageName: unknown
31683169
linkType: soft

0 commit comments

Comments
 (0)