Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
555 commits
Select commit Hold shift + click to select a range
cc44e75
Fix the command not running properly
leeyi45 Aug 9, 2025
0fb9836
Combine all the windows things into a single step
leeyi45 Aug 9, 2025
f2130a2
Maybe yarn was installed globally?
leeyi45 Aug 9, 2025
dc5f09d
Fix folder already exists
RichDom2185 Aug 9, 2025
02abd79
Does this work?
leeyi45 Aug 9, 2025
0870811
Make a windows version of the directory paths available
leeyi45 Aug 9, 2025
848be2d
Add a cwd check
leeyi45 Aug 9, 2025
c719288
Fix more TypeDoc
RichDom2185 Aug 9, 2025
1cd4346
Update docs about corepack
leeyi45 Aug 9, 2025
a20bd59
Update installation docs
leeyi45 Aug 9, 2025
643c342
Continue to try fixing the workflow
leeyi45 Aug 9, 2025
72e6c0e
Check working directory
leeyi45 Aug 9, 2025
8b06cf8
I have no idea why one evaluates to true and the other evalutes to false
leeyi45 Aug 9, 2025
fa85736
Check cwd
leeyi45 Aug 9, 2025
3841105
Remove all the windows directory stuff and just use yarn workspaces i…
leeyi45 Aug 9, 2025
f378383
Update test configs
leeyi45 Aug 9, 2025
cdf70e0
Try adding a new matcher for resolving paths
leeyi45 Aug 9, 2025
2bcf0dc
Update the buildtools tests for windows compatibility
leeyi45 Aug 10, 2025
a9f2d80
Add a "same path" comparer
leeyi45 Aug 10, 2025
e583162
Continue fixing tests to make them work on windows
leeyi45 Aug 10, 2025
f6847ad
Still fixing tests....
leeyi45 Aug 10, 2025
f11b4c4
Add some logging
leeyi45 Aug 10, 2025
773cd4c
Try and fix the markdown tree tests
leeyi45 Aug 10, 2025
ac00019
Fix the tsc thing
leeyi45 Aug 10, 2025
a2b03d9
Re-enable the full workflow
leeyi45 Aug 10, 2025
a08edba
Continue to try fix the doc server not building
leeyi45 Aug 10, 2025
21a0d30
Still trying to figure the docserver out
leeyi45 Aug 10, 2025
985d58a
Echo the changes value for docserver
leeyi45 Aug 10, 2025
388f14f
Use fromJSON
leeyi45 Aug 10, 2025
759a012
Returning a mapping doesn't work
leeyi45 Aug 10, 2025
90229db
Disable everything except for docserver
leeyi45 Aug 10, 2025
84a3c8f
Try using fromJSON in a different place
leeyi45 Aug 10, 2025
e1593c7
As a whole workflow, this should now work
leeyi45 Aug 10, 2025
6110d5c
Update deploy workflow
leeyi45 Aug 10, 2025
7e27aef
Update docs
leeyi45 Aug 10, 2025
e316080
Add the memory space option to lint:all
leeyi45 Aug 10, 2025
7117b7c
Remove unnecessary patch
leeyi45 Aug 10, 2025
ede60f0
Update lib/repotools/src/manifest.ts
RichDom2185 Aug 10, 2025
315a49e
Revert "Remove unnecessary patch"
RichDom2185 Aug 10, 2025
3e5b9b2
Reformat some Markdown files for readability
RichDom2185 Aug 10, 2025
d2ed1a5
Reformat more Markdown files
RichDom2185 Aug 10, 2025
0c8edb2
Reformat even more Markdown files
RichDom2185 Aug 10, 2025
b8b5ab2
Reformat remaining Markdown files
RichDom2185 Aug 10, 2025
25fe416
Update doc server and remove yarnhook
leeyi45 Aug 11, 2025
c0a6137
Add http server command to buildtools
leeyi45 Aug 11, 2025
e8b7ea1
Update libs and docs about focused installations
leeyi45 Aug 12, 2025
29e3198
Fix lint issue
leeyi45 Aug 12, 2025
dc62eba
Finally got linting code blocks in markdown files to work
leeyi45 Aug 12, 2025
16e46be
Fix dead links
leeyi45 Aug 12, 2025
c7e8765
Enable lint global to output stats too
leeyi45 Aug 12, 2025
e39dc33
Add a CSV formatter for ESLint statistics
leeyi45 Aug 12, 2025
1f1f9a4
Fix some docs
leeyi45 Aug 12, 2025
b30801a
Hide pathname from mqtt pic
leeyi45 Aug 12, 2025
b5e8328
Fix some flaws with the devserver
leeyi45 Aug 12, 2025
615f7b4
Update unittest bundle and tab to allow multiple and nested calls to …
leeyi45 Aug 12, 2025
4560af3
Reformat Markdown files
RichDom2185 Aug 12, 2025
5583e18
Fix AR bundle
RichDom2185 Aug 13, 2025
838ef37
Add a new action that rebuilds the tabs for the devserver if necessary
leeyi45 Aug 13, 2025
3833f37
Fix action always rebuilding artifact
leeyi45 Aug 13, 2025
b863da9
Will changing the order work?
leeyi45 Aug 13, 2025
0c50c75
Forgot to enable corepack
leeyi45 Aug 13, 2025
b518abd
Add manifest building
leeyi45 Aug 13, 2025
9c42e37
Cleanup
RichDom2185 Aug 13, 2025
c52eec3
Fix devserver workflow not working and modules-lib install taking for…
leeyi45 Aug 18, 2025
6a436b6
Add description to github actions package
leeyi45 Aug 18, 2025
11abc90
Time to figure out why playwright detection isn't working
leeyi45 Aug 18, 2025
a4e264a
Turns out I am just dumb and left playwright out of the curve tab's d…
leeyi45 Aug 18, 2025
ef48e95
Use headless install of playwright instead
leeyi45 Aug 18, 2025
78d3781
Miscellanous changes
leeyi45 Aug 18, 2025
51c5fb4
Update docs and lint configuration for quotes
leeyi45 Aug 19, 2025
1315c90
Fix the inconsistent semicolon delimiting in typescript types and int…
leeyi45 Aug 19, 2025
e61e287
Remove useless workspaces and modify templates to include all scripts
leeyi45 Aug 19, 2025
cd8845f
Test playwright caching
leeyi45 Aug 19, 2025
1d66fd2
Try another way to parse json
leeyi45 Aug 19, 2025
1960a43
Try installing the tab package
leeyi45 Aug 19, 2025
2e13ce2
Try focusing everything at once
leeyi45 Aug 19, 2025
4f04d86
Check if the playwright directory is found
leeyi45 Aug 19, 2025
2b96862
Fix error handling not working
leeyi45 Aug 19, 2025
df25d9b
Maybe this will work
leeyi45 Aug 19, 2025
9122f93
Try playwright tool caching
leeyi45 Aug 19, 2025
cc4a4ff
Use the workspace command instead
leeyi45 Aug 19, 2025
c937fa4
Fix using the wrong playwright option
leeyi45 Aug 19, 2025
086281d
Does adding the mkdirP call work?
leeyi45 Aug 19, 2025
a822167
Use cache instead of tool-cache
leeyi45 Aug 19, 2025
a638335
Remove tool-cache
leeyi45 Aug 19, 2025
b43125c
Restore everything else and stop using caching for playwright
leeyi45 Aug 19, 2025
138f19f
Add missing repotools tests
leeyi45 Aug 25, 2025
464d99c
Remove testing related tests since we can't really mock vite
leeyi45 Aug 25, 2025
6e28860
Update some dependencies
leeyi45 Aug 29, 2025
18b9db6
Fix it and test being able to be called recursively
leeyi45 Aug 29, 2025
75057b2
Add doc info on describe function titles
leeyi45 Aug 29, 2025
16a1834
Format the summary produced by the info action to be better
leeyi45 Sep 1, 2025
0eb51a9
Fix base url not working correctly
leeyi45 Sep 1, 2025
ace06f2
Fix the url not working again
leeyi45 Sep 1, 2025
286b1ff
Fix url handling again
leeyi45 Sep 1, 2025
b833da5
Add tests for rune bundle and tab
leeyi45 Sep 2, 2025
3861c2c
Update test coverage configuration
leeyi45 Sep 2, 2025
a52469e
Merge remote-tracking branch 'origin/tab-cleanup' into yarn-workspaces
leeyi45 Sep 2, 2025
ccbd65f
Add tests for plotly and painter tabs
leeyi45 Sep 2, 2025
b247e12
Fix issue with configs not being cloned properly
leeyi45 Sep 2, 2025
5e04913
Fix curve bundle functions and tests
leeyi45 Sep 2, 2025
db01b2e
Add anaglyph rune test
leeyi45 Sep 2, 2025
59babe6
Fix tests not working correctly
leeyi45 Sep 2, 2025
a903cc8
Add tests for sound and stereo_sound bundles
leeyi45 Sep 2, 2025
c7b3f09
Add tests to repl
leeyi45 Sep 2, 2025
641c8d7
Update some documentation
leeyi45 Sep 2, 2025
be6ae5f
Try adding a github actions reporter
leeyi45 Sep 3, 2025
b79c08b
Fix incorrect build
leeyi45 Sep 3, 2025
786aef1
Remove the requirement to build the reporter
leeyi45 Sep 3, 2025
f083a29
Try a version with actions/core bundled
leeyi45 Sep 3, 2025
6d3f074
Add the uncovered lines information
leeyi45 Sep 3, 2025
790805c
Fix linting and some other things
leeyi45 Sep 3, 2025
fa6982f
Sort test coverage output
leeyi45 Sep 3, 2025
dfcae9f
Try adding some colors
leeyi45 Sep 3, 2025
50731d6
More formatting
leeyi45 Sep 3, 2025
e53d0a1
Fix nested td in html
leeyi45 Sep 3, 2025
2ab4b64
Reformat uncovered lines list
leeyi45 Sep 3, 2025
4152dad
Hide uncovered lines in a summary
leeyi45 Sep 3, 2025
57914a5
Final modifications
leeyi45 Sep 3, 2025
43e69a4
Update documenation for the vitest coverage reporter
leeyi45 Sep 3, 2025
2e6738e
Remove the dependency on actions/core
leeyi45 Sep 3, 2025
59d59b1
Use fs directly since istanbul context writer doesn't support appending
leeyi45 Sep 3, 2025
feb1bd4
Add a summary reporter for tests
leeyi45 Sep 3, 2025
7981a8f
Fix broken paths
leeyi45 Sep 3, 2025
e40606d
Fix an undefined check?
leeyi45 Sep 3, 2025
a580b8f
Try another reporter implementation
leeyi45 Sep 3, 2025
3f74088
Fix continue to fix formatting
leeyi45 Sep 3, 2025
48952f4
Fix formatting again
leeyi45 Sep 3, 2025
90cf4d3
Fix test formatter
leeyi45 Sep 3, 2025
84d50f9
More formatting fixes
leeyi45 Sep 3, 2025
83f3c55
Found the way to get the file name
leeyi45 Sep 3, 2025
e5e1ff3
Fix filepath
leeyi45 Sep 3, 2025
48706cf
Add start time for test modules
leeyi45 Sep 3, 2025
0f693c4
Try to fix the start times
leeyi45 Sep 3, 2025
56839f4
Add slow indicator
leeyi45 Sep 3, 2025
a5280f5
Add docs about test coverage
leeyi45 Sep 3, 2025
718f769
Change defineTab type to be generic
leeyi45 Sep 4, 2025
c939817
Fix stereo sound tab not retrieving the correct module state
leeyi45 Sep 4, 2025
1f7206b
Update test reporter to follow the summary format
leeyi45 Sep 4, 2025
f9beead
Add the silent option to tests
leeyi45 Sep 4, 2025
fcc0332
Fix tests for curve and rune tabs and unittest
leeyi45 Sep 5, 2025
6888a81
Fix some oversight in eslint styles
leeyi45 Sep 6, 2025
d562ab0
Add tests for the unittest bundle mocking functions
leeyi45 Sep 6, 2025
95586c2
Add a constraint to prevent js-slang from being resolved to something…
leeyi45 Sep 6, 2025
192a99f
Add a paragraph on test file naming
leeyi45 Sep 6, 2025
a09707a
Fix the vitest reporter being written in cjs and tests
leeyi45 Sep 12, 2025
4873bfb
Use instanceof for type guards
leeyi45 Sep 12, 2025
9140a00
Try using a default import for the coverage reporter
leeyi45 Sep 12, 2025
4be62a4
Try using named imports
leeyi45 Sep 12, 2025
dd49bec
Try using ESM
leeyi45 Sep 12, 2025
10c2591
Revert to old coverage reporter
leeyi45 Sep 12, 2025
b0cb71b
Merge branch 'yarn-workspaces' of github.com:source-academy/modules i…
leeyi45 Sep 12, 2025
8b96204
Try this combination of ESM and CJS to see if it works
leeyi45 Sep 12, 2025
758ff97
FIx incorrect path to coverage reporter
leeyi45 Sep 12, 2025
52e1a67
FIx the typescript errors with the coverage reporter
leeyi45 Sep 13, 2025
6d794a7
Disable import/no-cycle rule to save linting time
leeyi45 Sep 13, 2025
53a621f
Update eslint to make use of the new concurrent option
leeyi45 Sep 13, 2025
bec27ff
Add rule to redirect imports to extra typings for commander
leeyi45 Sep 13, 2025
fada712
Fix tsc error
leeyi45 Sep 14, 2025
eca9e09
Use the minified version of the reporter
leeyi45 Sep 14, 2025
09e3a05
Update test configuration
leeyi45 Sep 15, 2025
62b34f5
Add more tests for actions
leeyi45 Sep 15, 2025
52314a8
Add tests and fix linting
leeyi45 Sep 15, 2025
67ca88c
FIx skipped tests displaying empty duration strings
leeyi45 Sep 15, 2025
14db79b
Try to fix the duration string again
leeyi45 Sep 15, 2025
840f23a
Try to fix the duration string again
leeyi45 Sep 15, 2025
079de28
Manually check the state of the test instead
leeyi45 Sep 15, 2025
54a5659
Separate the lint check into two different steps
leeyi45 Sep 15, 2025
2934fa3
Move linting step into the matrix
leeyi45 Sep 15, 2025
98a56b8
Revert "Move linting step into the matrix"
leeyi45 Sep 15, 2025
d192b0d
Revert "Separate the lint check into two different steps"
leeyi45 Sep 15, 2025
6ddcd6a
Update inaccurate test counts
leeyi45 Sep 15, 2025
fca8a69
Update documentation further
leeyi45 Sep 23, 2025
4528e57
Improve binary tree typing and add tests
leeyi45 Sep 23, 2025
1f13f92
Fix incorrect command test name
leeyi45 Sep 17, 2025
5b1a4e5
Fix types and tests for binary tree bundle
leeyi45 Sep 23, 2025
8d29a68
Fix documentation inconsistencies
leeyi45 Sep 24, 2025
dba9049
Add more documentation regarding errors and type-checking
leeyi45 Sep 25, 2025
197ba12
Remove unnecessary type assertions from code
leeyi45 Sep 25, 2025
9217498
Add two logging commands to the lint command
leeyi45 Sep 25, 2025
938f908
Fix wrong prefix for lint command
leeyi45 Sep 26, 2025
72e6c6a
Disable no unnecessary type assertions since it's not working properly
leeyi45 Sep 26, 2025
d0940bb
Add tests for pix_n_flix
leeyi45 Sep 26, 2025
402bc02
Fix incorrect react type package
leeyi45 Sep 26, 2025
ae77abd
Update docs to add description about versioning and writing documenta…
leeyi45 Sep 27, 2025
60f3ef9
Continue to fix linting and documentation issues
leeyi45 Sep 27, 2025
33a6466
Correct documentation errors
leeyi45 Oct 10, 2025
da5f3e5
Improve type-checking for sound bundle
leeyi45 Oct 10, 2025
bdb0a8f
Remove unnecessary calls to get_duration and get_wave
leeyi45 Oct 10, 2025
856855a
Update stereo_sound and sound bundle functions to include better type…
leeyi45 Oct 10, 2025
917dffe
Rename unittest test file
leeyi45 Oct 10, 2025
c1b21a8
Rename test files to include .test.
leeyi45 Oct 10, 2025
9c8bd1d
Update snapshots
leeyi45 Oct 10, 2025
d87b95c
Add developer documentation for bundles
leeyi45 Oct 10, 2025
22bbf6d
Modify the bundle specific documentations
leeyi45 Oct 12, 2025
208fb28
Fix broken links
leeyi45 Oct 12, 2025
9dc79fc
Add tests to sound
leeyi45 Oct 14, 2025
877fc54
Add tests to sound bundle
leeyi45 Oct 14, 2025
2dc93f2
minor fixes
leeyi45 Oct 14, 2025
bc31c25
Remove @vitest/browser package
leeyi45 Oct 14, 2025
2e46951
Add spell checking to documentation
leeyi45 Oct 15, 2025
0383b38
Update spellcheck configuration to exclude modules-lib
leeyi45 Oct 16, 2025
dc932c4
Fix dead link
leeyi45 Oct 16, 2025
c9540be
Update documentations
leeyi45 Oct 20, 2025
89b0fa9
Add a section documenting spell checking
leeyi45 Oct 20, 2025
1d73ed9
Fix the numbering
leeyi45 Oct 20, 2025
4b93345
Continue removing @vitest/browser
leeyi45 Oct 20, 2025
ff831b3
Fix incorrect path in tab template command
leeyi45 Oct 22, 2025
31ceecb
Fix tab template command adding version to bundle manifest
leeyi45 Oct 22, 2025
ebf5871
Use the direct import instead of the barrel lodash import
leeyi45 Oct 22, 2025
8ada78a
Try updating all of the testing packages
leeyi45 Oct 22, 2025
75546f0
Continue fixing broken tests
leeyi45 Oct 22, 2025
e693cf2
Fix tests for robot_simulation
leeyi45 Oct 24, 2025
3c75a52
Fix sound bundle tests
leeyi45 Oct 24, 2025
95fe02e
Fix repo tools tests
leeyi45 Oct 24, 2025
51ad799
Update tsconfigs to include noEmit true
leeyi45 Oct 24, 2025
aeeb356
Make manifest errors more informative
leeyi45 Oct 24, 2025
f8db3bf
Add eols to tsconfigs
leeyi45 Oct 24, 2025
a41708c
Split the list command into two
leeyi45 Oct 25, 2025
63a9c8c
Separate tests for list and validate command
leeyi45 Oct 25, 2025
9ced56f
Update documentation to reflect the new browser mode API
leeyi45 Oct 25, 2025
69bd79d
Improve documentation about testing
leeyi45 Oct 27, 2025
f9afb61
Update buildtools docs
leeyi45 Oct 27, 2025
2d0ba84
Update vitest to the version that doesn't need the path and fs module…
leeyi45 Oct 27, 2025
fd42523
Update coverage configuration
leeyi45 Oct 27, 2025
e4936a5
Merge branch 'yarn-workspaces' of github.com:source-academy/modules i…
leeyi45 Oct 27, 2025
ce0ded6
Fix coverage exclusion pattern excluding buildtools
leeyi45 Oct 27, 2025
9f2fbd3
Make sure to await render calls in tests
leeyi45 Oct 28, 2025
c90b94b
Use vi.stubGlobal instead Object.defineProperty
leeyi45 Oct 28, 2025
24e9a1e
Remove the need for noEmit on a per bundle basis
leeyi45 Oct 28, 2025
5151e50
Update some documentation
leeyi45 Oct 28, 2025
ae1721d
FIx broken test
leeyi45 Oct 28, 2025
425fa19
Minor fix to MultItemDisplay
leeyi45 Oct 29, 2025
2a6f2ce
Standardize Markdown formatting
RichDom2185 Oct 31, 2025
22d98c0
Fix SASS warnings
RichDom2185 Oct 31, 2025
6f8564e
Remove unused styles from devserver
RichDom2185 Oct 31, 2025
a26b645
Reformat all markdown files
RichDom2185 Oct 31, 2025
819b492
Bump node version
RichDom2185 Oct 31, 2025
4a91356
Update actions versions
RichDom2185 Oct 31, 2025
40b2670
Update editor settings and add recommended extensions
RichDom2185 Oct 31, 2025
5a968ef
Revert change to plotly functions.ts
leeyi45 Oct 31, 2025
d13f1dd
Merge branch 'yarn-workspaces' of github.com:source-academy/modules i…
leeyi45 Oct 31, 2025
d068fc9
Move vitest to ts files
leeyi45 Oct 31, 2025
e6aecba
Update testing configuration and documentation related to testing
leeyi45 Oct 31, 2025
bfe6c6a
Update an incorrect linting configuration
leeyi45 Oct 31, 2025
888e0c9
Update workflows to use node24
leeyi45 Oct 31, 2025
c9aa42d
Fix incorreect tsconfig for modules lib
leeyi45 Oct 31, 2025
3d977ac
Fix ESLint not correctly detecting tsconfig for vitest files
leeyi45 Oct 31, 2025
806aca4
Fix broken buildtools test
leeyi45 Oct 31, 2025
44647cc
Make the test include pattern a posix path instead of a windows path
leeyi45 Nov 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 17 additions & 0 deletions .github/actions/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @ts-check
import getBuildCommand from '@sourceacademy/modules-repotools/builder';

const buildCommand = getBuildCommand({
bundle: true,
entryPoints: [
{ in: './src/info/index.ts', out: 'info' },
{ in: './src/load-artifacts/index.ts', out: 'load' }
],
format: 'esm',
outdir: 'dist',
packages: 'external',
platform: 'node',
target: 'node20',
});

await buildCommand.parseAsync();
24 changes: 24 additions & 0 deletions .github/actions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@sourceacademy/modules-github-actions",
"description": "Github Actions for the modules repository",
"private": true,
"type": "module",
"devDependencies": {
"@sourceacademy/modules-repotools": "workspace:^",
"@types/node": "^22.15.30",
"typescript": "^5.8.2",
"vitest": "^4.0.4"
},
"dependencies": {
"@actions/artifact": "^2.3.2",
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"lodash": "^4.17.21"
},
"scripts": {
"build": "node ./build.js",
"postinstall": "yarn build",
"test": "vitest",
"tsc": "tsc --project ./tsconfig.json"
}
}
92 changes: 92 additions & 0 deletions .github/actions/src/__tests__/commons.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import * as exec from '@actions/exec';
import { describe, expect, it, test, vi } from 'vitest';
import * as commons from '../commons.js';

vi.mock(import('lodash/memoize.js'), () => ({
default: (x: any) => x
}) as any);

const mockedExecOutput = vi.spyOn(exec, 'getExecOutput');

describe(commons.checkForChanges, () => {
function mockChanges(value: boolean) {
mockedExecOutput.mockResolvedValueOnce({
exitCode: value ? 1 : 0, stdout: '', stderr: ''
});
}

it('should return true if git diff exits with non zero code', async () => {
mockChanges(true);
await expect(commons.checkForChanges('/')).resolves.toEqual(true);
expect(mockedExecOutput).toHaveBeenCalledOnce();
});

it('should return false if git diff exits with 0', async () => {
mockChanges(false);

await expect(commons.checkForChanges('/')).resolves.toEqual(false);
expect(mockedExecOutput).toHaveBeenCalledOnce();
});
});

describe(commons.isPackageRecord, () => {
test('no bundleName or tabName property is ok', () => {
expect(commons.isPackageRecord({
directory: '',
name: '',
changes: false,
needsPlaywright: false
})).toEqual(true);
});

test('string bundleName property is ok', () => {
expect(commons.isPackageRecord({
directory: '',
name: '',
changes: false,
needsPlaywright: false,
bundleName: ''
})).toEqual(true);
});

test('non-string bundleName property is not ok', () => {
expect(commons.isPackageRecord({
directory: '',
name: '',
changes: false,
needsPlaywright: false,
bundleName: 0
})).toEqual(false);
});

test('string tabName property is ok', () => {
expect(commons.isPackageRecord({
directory: '',
name: '',
changes: false,
needsPlaywright: false,
tabName: ''
})).toEqual(true);
});

test('non-string tabName property is not ok', () => {
expect(commons.isPackageRecord({
directory: '',
name: '',
changes: false,
needsPlaywright: false,
tabName: 0
})).toEqual(false);
});

test('having both bundleName and tabName property is not ok', () => {
expect(commons.isPackageRecord({
directory: '',
name: '',
changes: false,
needsPlaywright: false,
tabName: '',
bundleName: ''
})).toEqual(false);
});
});
85 changes: 85 additions & 0 deletions .github/actions/src/commons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { getExecOutput } from '@actions/exec';
import memoize from 'lodash/memoize.js';

export interface RawPackageRecord {
directory: string;
hasChanges: boolean;
package: {
name: string;
devDependencies: Record<string, string>;
dependencies: Record<string, string>;
};
}

interface BasePackageRecord {
/**
* Directory within which the `package.json` file was found
*/
directory: string;

/**
* Full scoped package name
*/
name: string;
/**
* `true` if git detected changes from within the package's subdirectories,
* `false` otherwise
*/
changes: boolean;
/**
* `true` if playwright is present under devDependencies. This means that the package
* might need playwright for its tests
*/
needsPlaywright: boolean;
}

export interface BundlePackageRecord extends BasePackageRecord {
bundleName: string;
}

export interface TabPackageRecord extends BasePackageRecord {
tabName: string;
}

export type PackageRecord = BundlePackageRecord | TabPackageRecord | BasePackageRecord;

export function isPackageRecord(obj: unknown): obj is PackageRecord {
if (typeof obj !== 'object' || obj === null) return false;

if (!('directory' in obj) || typeof obj.directory !== 'string') return false;
if (!('name' in obj) || typeof obj.name !== 'string') return false;
if (!('changes' in obj) || typeof obj.changes !== 'boolean') return false;
if (!('needsPlaywright' in obj) || typeof obj.needsPlaywright !== 'boolean') return false;

if ('bundleName' in obj) {
if ('tabName' in obj || typeof obj.bundleName !== 'string') return false;
} else if ('tabName' in obj) {
if (typeof obj.tabName !== 'string') return false;
}

return true;
}

// Not using the repotools version since this uses @action/exec instead of
// calling execFile from child_process
export async function getGitRoot() {
const { stdout } = await getExecOutput('git rev-parse --show-toplevel');
return stdout.trim();
}

/**
* Returns `true` if there are changes present in the given directory relative to
* the master branch\
* Used to determine, particularly for libraries, if running tests and tsc are necessary
*/
export const checkForChanges = memoize(async (directory: string) => {
const { exitCode } = await getExecOutput(
'git',
['--no-pager', 'diff', '--quiet', 'origin/master', '--', directory],
{
failOnStdErr: false,
ignoreReturnCode: true
}
);
return exitCode !== 0;
});
Loading
Loading