Skip to content

Commit ed773a3

Browse files
committed
Try out a new composite action
1 parent 82cf7f8 commit ed773a3

File tree

7 files changed

+141
-82
lines changed

7 files changed

+141
-82
lines changed

.github/actions/build.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-check
12
import getBuildCommand from '@sourceacademy/modules-repotools/builder';
23

34
const buildCommand = getBuildCommand({
@@ -10,7 +11,7 @@ const buildCommand = getBuildCommand({
1011
outdir: 'dist',
1112
packages: 'external',
1213
platform: 'node',
13-
target: 'node20'
14+
target: 'node20',
1415
});
1516

1617
await buildCommand.parseAsync();
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Initialize Environment
2+
description: Checks out code and installs Yarn
3+
4+
branding:
5+
icon: play
6+
color: green
7+
8+
inputs:
9+
workspace-name:
10+
required: false
11+
default: null
12+
description: Name of the workspace you're initializing
13+
14+
install-deps:
15+
required: false
16+
default: true
17+
description: "Should dependencies be installed? (default: true)"
18+
19+
playwright:
20+
required: false
21+
default: false
22+
description: Should run the Playwright installation command
23+
24+
runs:
25+
using: composite
26+
steps:
27+
- name: Check out source code
28+
uses: actions/checkout@v4
29+
30+
- name: Enable Corepack
31+
run: corepack enable
32+
33+
- name: Use Node.js 💻
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version-file: .node-version
37+
cache: yarn
38+
39+
- name: Install Dependencies (Focused)
40+
if: inputs.workspace-name != null && inputs.install-deps
41+
run: yarn workspaces focus ${{ inputs.workspace-name }}
42+
43+
- name: Install Dependencies (General)
44+
if: inputs.workspace-name == null && inputs.install-deps
45+
run: yarn install --immutable
46+
47+
- name: Install Playwright
48+
if: inputs.playwright == 'true' && inputs.install-deps
49+
run: yarn playwright install --with-deps

.github/workflows/workflow-again.yml

Lines changed: 56 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- name: Check out source code
18-
uses: actions/checkout@v4
19-
20-
- name: Enable corepack
21-
run: corepack enable
22-
23-
- name: Install action packages
24-
run: yarn workspaces focus @sourceacademy/modules-github-actions
17+
- name: Initialize Repo
18+
uses: ./.github/actions/src/init
19+
with:
20+
package-name: '@sourceacademy/modules-github-actions'
2521

2622
- name: Build actions
2723
run: |
@@ -46,26 +42,11 @@ jobs:
4642
matrix:
4743
lib: ${{ fromJson(needs.find-packages.outputs.libs) }}
4844
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
45+
- name: Initialize Repo
46+
uses: ./.github/actions/src/init
5747
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
48+
package-name: ${{ matrix.lib.name }}
49+
playwright: ${{ matrix.lib.changes && matrix.lib.needsPlaywright }}
6950

7051
- name: Run Tests
7152
if: matrix.lib.changes == 'true'
@@ -90,17 +71,11 @@ jobs:
9071
tabInfo: ${{ fromJson(needs.find-packages.outputs.tabs) }}
9172

9273
steps:
93-
- name: Check out source code
94-
uses: actions/checkout@v4
95-
96-
- name: Enable Corepack
97-
run: corepack enable
98-
99-
- name: Use Node.js 💻
100-
uses: actions/setup-node@v4
74+
- name: Initialize Repo
75+
uses: ./.github/actions/src/init
10176
with:
102-
node-version-file: .node-version
103-
cache: yarn
77+
package-name: ${{ matrix.tabInfo.name }}
78+
playwright: ${{ matrix.tabInfo.needsPlaywright && matrix.tabInfo.changes }}
10479

10580
- name: Install Dependencies
10681
run: yarn workspaces focus ${{ matrix.tabInfo.name }}
@@ -114,20 +89,14 @@ jobs:
11489
path: ./build/tabs/${{ matrix.tabInfo.tabName }}.js
11590
key: ${{ matrix.tabInfo.name }}
11691

117-
- name: Install Playwright (if needed)
118-
if: matrix.tabInfo.changes == 'true' && matrix.tabInfo.needsPlaywright
119-
run: |
120-
cd ${{ matrix.tabInfo.directory }}
121-
yarn playwright install --with-deps
122-
12392
- name: Run Tests
124-
if: matrix.tabInfo.changes == 'true'
93+
if: matrix.tabInfo.changes
12594
run: |
12695
cd ${{ matrix.tabInfo.directory }}
12796
yarn test
12897
12998
- name: Run Auxillary Tasks
130-
if: matrix.tabInfo.changes == 'true'
99+
if: matrix.tabInfo.changes
131100
run: |
132101
cd ${{ matrix.tabInfo.directory }}
133102
yarn tsc
@@ -143,20 +112,10 @@ jobs:
143112
bundleInfo: ${{ fromJson(needs.find-packages.outputs.bundles) }}
144113

145114
steps:
146-
- name: Check out source code
147-
uses: actions/checkout@v4
148-
149-
- name: Enable Corepack
150-
run: corepack enable
151-
152-
- name: Use Node.js 💻
153-
uses: actions/setup-node@v4
115+
- name: Initialize Repo
116+
uses: ./.github/actions/src/init
154117
with:
155-
node-version-file: .node-version
156-
cache: yarn
157-
158-
- name: Install Dependencies
159-
run: yarn workspaces focus ${{ matrix.bundleInfo.name }}
118+
package-name: ${{ matrix.bundleInfo.name }}
160119

161120
- name: Build Bundle
162121
run: |
@@ -197,17 +156,46 @@ jobs:
197156
- tabs
198157

199158
steps:
200-
- name: Check out source code
201-
uses: actions/checkout@v4
159+
- name: Initialize Repo
160+
uses: ./.github/actions/src/init
161+
with:
162+
package-name: '@sourceacademy/modules-devserver'
163+
playwright: true
202164

203-
- name: Enable Corepack
204-
run: corepack enable
165+
- name: Run tests
166+
run: |
167+
cd ./devserver
168+
yarn test
169+
170+
- name: Run Auxillary Tasks
171+
run: |
172+
cd ./devserver
173+
yarn tsc
205174
206-
- name: Use Node.js 💻
207-
uses: actions/setup-node@v4
175+
docserver:
176+
name: Docs Server Tests
177+
runs-on: ubuntu-latest
178+
needs: libraries
179+
steps:
180+
- name: Initialize Repo
181+
uses: ./.github/actions/src/init
208182
with:
209-
node-version-file: .node-version
210-
cache: yarn
183+
package-name: '@sourceacademy/modules-docserver'
211184

212-
- name: Install Dependencies
213-
run: yarn workspaces focus @sourceacademy/modules-devserver
185+
- name: Build Docs
186+
run: |
187+
cd ./docs
188+
yarn build
189+
190+
repo-tasks:
191+
name: Repo Wide Tasks
192+
runs-on: ubuntu-latest
193+
194+
steps:
195+
- name: Initialize Repo
196+
uses: ./.github/actions/src/init
197+
with:
198+
package-name: '@sourceacademy/modules'
199+
200+
- name: Lint Everything
201+
run: yarn lint:all

src/bundles/nbody/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
"version": "1.0.0",
44
"private": true,
55
"dependencies": {
6-
"nbody": "^0.2.0"
6+
"nbody": "^0.2.0",
7+
"plotly.js-dist": "^2.17.1",
8+
"three": "^0.175.0"
79
},
810
"devDependencies": {
911
"@sourceacademy/modules-buildtools": "workspace:^",
10-
"typescript": "^5.8.2"
11-
},
12-
"peerDependencies": {
1312
"@types/plotly.js": "^2.35.4",
1413
"@types/three": "^0.175.0",
15-
"plotly.js-dist": "^2.17.1",
16-
"three": "^0.175.0"
14+
"typescript": "^5.8.2"
1715
},
1816
"type": "module",
1917
"exports": {

src/bundles/robot_simulation/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"three": "^0.175.0"
88
},
99
"devDependencies": {
10+
"@dimforge/rapier3d-compat": "^0.11.2",
1011
"@sourceacademy/modules-buildtools": "workspace:^",
1112
"@types/three": "^0.175.0",
1213
"typescript": "^5.8.2"

src/tabs/Nbody/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
"dependencies": {
66
"@sourceacademy/modules-lib": "workspace:^",
77
"nbody": "^0.2.0",
8+
"plotly.js-dist": "^2.17.1",
89
"react": "^18.3.1",
9-
"react-dom": "^18.3.1"
10+
"react-dom": "^18.3.1",
11+
"three": "^0.175.0"
1012
},
1113
"devDependencies": {
1214
"@sourceacademy/modules-buildtools": "workspace:^",
13-
"@types/react": "^18.3.1"
15+
"@types/plotly.js": "^2.35.4",
16+
"@types/react": "^18.3.1",
17+
"@types/three": "^0.175.0"
1418
},
1519
"scripts": {
1620
"build": "buildtools build tab .",

yarn.lock

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,13 +3173,12 @@ __metadata:
31733173
resolution: "@sourceacademy/bundle-nbody@workspace:src/bundles/nbody"
31743174
dependencies:
31753175
"@sourceacademy/modules-buildtools": "workspace:^"
3176+
"@types/plotly.js": "npm:^2.35.4"
3177+
"@types/three": "npm:^0.175.0"
31763178
nbody: "npm:^0.2.0"
3179+
plotly.js-dist: "npm:^2.17.1"
3180+
three: "npm:^0.175.0"
31773181
typescript: "npm:^5.8.2"
3178-
peerDependencies:
3179-
"@types/plotly.js": ^2.35.4
3180-
"@types/three": ^0.175.0
3181-
plotly.js-dist: ^2.17.1
3182-
three: ^0.175.0
31833182
languageName: unknown
31843183
linkType: soft
31853184

@@ -3262,6 +3261,7 @@ __metadata:
32623261
version: 0.0.0-use.local
32633262
resolution: "@sourceacademy/bundle-robot_simulation@workspace:src/bundles/robot_simulation"
32643263
dependencies:
3264+
"@dimforge/rapier3d-compat": "npm:^0.11.2"
32653265
"@sourceacademy/modules-buildtools": "workspace:^"
32663266
"@sourceacademy/modules-lib": "workspace:^"
32673267
"@types/three": "npm:^0.175.0"
@@ -3694,10 +3694,14 @@ __metadata:
36943694
dependencies:
36953695
"@sourceacademy/modules-buildtools": "workspace:^"
36963696
"@sourceacademy/modules-lib": "workspace:^"
3697+
"@types/plotly.js": "npm:^2.35.4"
36973698
"@types/react": "npm:^18.3.1"
3699+
"@types/three": "npm:^0.175.0"
36983700
nbody: "npm:^0.2.0"
3701+
plotly.js-dist: "npm:^2.17.1"
36993702
react: "npm:^18.3.1"
37003703
react-dom: "npm:^18.3.1"
3704+
three: "npm:^0.175.0"
37013705
languageName: unknown
37023706
linkType: soft
37033707

@@ -4463,6 +4467,13 @@ __metadata:
44634467
languageName: node
44644468
linkType: hard
44654469

4470+
"@types/plotly.js@npm:^2.35.4":
4471+
version: 2.35.8
4472+
resolution: "@types/plotly.js@npm:2.35.8"
4473+
checksum: 10c0/9b59a56fdef4c383aab03cf3e2597393140ed743ca1682e5512f95583787ae2f75dd3f980a56eed0eaa2f088ad0475fc915cb5d37875b08f499168966bc92e22
4474+
languageName: node
4475+
linkType: hard
4476+
44664477
"@types/plotly.js@npm:^3.0.0":
44674478
version: 3.0.0
44684479
resolution: "@types/plotly.js@npm:3.0.0"
@@ -12381,6 +12392,13 @@ __metadata:
1238112392
languageName: node
1238212393
linkType: hard
1238312394

12395+
"plotly.js-dist@npm:^2.17.1":
12396+
version: 2.35.3
12397+
resolution: "plotly.js-dist@npm:2.35.3"
12398+
checksum: 10c0/cbdcfaaf72244e22a4311408f7bbad43e4462bc8dc5c7ea831f3dee3a2dc09bae6e390fc1eca92cc2b29f4cbae9507749b52fb3d7000a4115c666b6295e81a84
12399+
languageName: node
12400+
linkType: hard
12401+
1238412402
"plotly.js-dist@npm:^3.0.0":
1238512403
version: 3.0.1
1238612404
resolution: "plotly.js-dist@npm:3.0.1"

0 commit comments

Comments
 (0)