Skip to content

Commit 4f5d137

Browse files
committed
Try something interesting....
1 parent 7242ea8 commit 4f5d137

File tree

12 files changed

+98
-89
lines changed

12 files changed

+98
-89
lines changed

.github/actions/info/build.js renamed to .github/actions/build.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import getBuildCommand from '@sourceacademy/modules-repotools/builder';
22

33
const buildCommand = getBuildCommand({
44
bundle: true,
5-
entryPoints: ['./index.ts'],
5+
entryPoints: [
6+
{ in: './src/info/index.ts', out: 'info' },
7+
{ in: './src/install-deps/index.ts', out: 'install-deps' },
8+
],
69
format: 'esm',
7-
outfile: './dist.js',
10+
outdir: 'dist',
811
packages: 'external',
912
target: 'node20'
1013
});

.github/actions/info/dist.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/actions/info/package.json renamed to .github/actions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@sourceacademy/modules-info-action",
2+
"name": "@sourceacademy/modules-github-actions",
33
"private": true,
44
"type": "module",
55
"devDependencies": {

.github/actions/info/action.yml renamed to .github/actions/src/info/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ outputs:
1212

1313
runs:
1414
using: node20
15-
main: ./dist.js
15+
main: ../dist/info.js
File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Install Dependencies
2+
description: Install the dependencies for the given package
3+
4+
inputs:
5+
package:
6+
description: The name of the package
7+
required: true
8+
9+
directory:
10+
description: The directory of the package
11+
required: true
12+
13+
testRequired:
14+
description: Should tests be run for this package
15+
required: true
16+
17+
runs:
18+
using: node20
19+
main: ../dist/install-deps.js
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as core from '@actions/core';
2+
import { exec } from '@actions/exec';
3+
4+
async function main() {
5+
const packageName = core.getInput('packageName');
6+
const directory = core.getInput('directory');
7+
const testRequired = core.getBooleanInput('testRequired');
8+
9+
const args = ['workspaces', 'focus', packageName];
10+
if (!testRequired) {
11+
args.push('--production');
12+
}
13+
14+
await exec('yarn', args);
15+
16+
const { default: packageJson } = await import(`${directory}/package.json`, { with: { type: 'json' }});
17+
if (testRequired && packageJson.devDependecies) {
18+
core.info(`Playwright is necessary for ${packageName}, installing`);
19+
await exec('yarn', ['playwright', 'install', '--with-deps']);
20+
}
21+
}
22+
23+
await main();

.github/actions/info/tsconfig.json renamed to .github/actions/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": ["./index.ts"],
2+
"include": ["src"],
33
"compilerOptions": {
44
"forceConsistentCasingInFileNames": true,
55
"lib": ["ES2020"],

.github/workflows/new-workflow.yml

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,32 @@ on:
99
- master
1010

1111
jobs:
12+
build-actions:
13+
name: Builds the github actions that will be used
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out source code
17+
uses: actions/checkout@v4
18+
19+
- name: Enable Corepack
20+
run: corepack enable
21+
22+
- name: Use Node.js 💻
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version-file: .node-version
26+
cache: yarn
27+
28+
- name: Install dependencies
29+
run: yarn workspaces focus @sourceacademy/modules-github-actions --production
30+
31+
- name: Build
32+
run: |
33+
yarn workspaces foreach -A --include @sourceacademy/modules-github-actions run build
34+
1235
load-packages:
1336
name: Determine the packages present in the repo for the given type
37+
needs: build-actions
1438
runs-on: ubuntu-latest
1539
strategy:
1640
matrix:
@@ -34,12 +58,9 @@ jobs:
3458
node-version-file: .node-version
3559
cache: yarn
3660

37-
- name: Install dependencies
38-
run: yarn workspaces focus @sourceacademy/modules-info-action --production
39-
4061
- name: Find Packages
4162
id: find
42-
uses: ./.github/actions/info
63+
uses: ./.github/actions/src/info
4364
with:
4465
type: ${{ matrix.type }}
4566

@@ -49,7 +70,7 @@ jobs:
4970
needs: load-packages
5071
strategy:
5172
matrix:
52-
package: ${{ fromJson(needs.load-packages.outputs.libs) }}
73+
package: ${{ fromJson(needs.load-packages.outputs.tabs) }}
5374

5475
steps:
5576
- name: Check out source code
@@ -78,6 +99,7 @@ jobs:
7899
runs-on: ubuntu-latest
79100
needs: load-packages
80101
strategy:
102+
fail-fast: false
81103
matrix:
82104
package: ${{ fromJson(needs.load-packages.outputs.tabs) }}
83105

@@ -94,15 +116,27 @@ jobs:
94116
node-version-file: .node-version
95117
cache: yarn
96118

97-
- name: Install dependencies
98-
run: yarn workspaces focus ${{ matrix.package.name }}
119+
- name: Filter paths
120+
uses: dorny/paths-filter@v3
121+
id: filter
122+
with:
123+
filters: |
124+
changed:
125+
${{ matrix.package.directory }}/**
99126
100-
- name: Install playwright
101-
run: yarn playwright install --with-deps
127+
- name: Change into directory
128+
run: cd ${{ matrix.package.directory }}
102129

130+
- name: Install dependencies
131+
uses: ./.github/actions/src/install-deps
132+
with:
133+
directory: ${{ matrix.package.directory }}
134+
packageName: ${{ matrix.package.name }}
135+
testRequired: ${{ steps.filter.outputs.changed == 'true' }}
136+
103137
- name: tsc and test
138+
if: steps.filter.outputs.changed == 'true'
104139
run: |
105-
cd ${{ matrix.package.directory }}
106140
yarn tsc
107141
yarn test
108142

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export default tseslint.config(
338338
files: [
339339
'lib/buildtools/**/*.ts',
340340
'lib/repotools/**/*.ts',
341-
'.github.actions/**/*.ts',
341+
'.github/actions/**/*.ts',
342342
'**/vitest.config.js'
343343
],
344344
rules: {

0 commit comments

Comments
 (0)