Skip to content

Commit ed1fe71

Browse files
leeyi45RichDom2185
andauthored
Transition to Yarn Workspaces (#459)
* Check working directory * I have no idea why one evaluates to true and the other evalutes to false * Check cwd * Remove all the windows directory stuff and just use yarn workspaces instead * Update test configs * Try adding a new matcher for resolving paths * Update the buildtools tests for windows compatibility * Add a "same path" comparer * Continue fixing tests to make them work on windows * Still fixing tests.... * Add some logging * Try and fix the markdown tree tests * Fix the tsc thing * Re-enable the full workflow * Continue to try fix the doc server not building * Still trying to figure the docserver out * Echo the changes value for docserver * Use fromJSON * Returning a mapping doesn't work * Disable everything except for docserver * Try using fromJSON in a different place * As a whole workflow, this should now work * Update deploy workflow * Update docs * Add the memory space option to lint:all * Remove unnecessary patch * Update lib/repotools/src/manifest.ts Co-authored-by: Copilot <[email protected]> * Revert "Remove unnecessary patch" This reverts commit 7117b7c. * Reformat some Markdown files for readability * Reformat more Markdown files * Reformat even more Markdown files * Reformat remaining Markdown files * Update doc server and remove yarnhook * Add http server command to buildtools * Update libs and docs about focused installations * Fix lint issue * Finally got linting code blocks in markdown files to work * Fix dead links * Enable lint global to output stats too * Add a CSV formatter for ESLint statistics * Fix some docs * Hide pathname from mqtt pic * Fix some flaws with the devserver * Update unittest bundle and tab to allow multiple and nested calls to describe * Reformat Markdown files * Fix AR bundle * Add a new action that rebuilds the tabs for the devserver if necessary * Fix action always rebuilding artifact * Will changing the order work? * Forgot to enable corepack * Add manifest building * Cleanup * Fix devserver workflow not working and modules-lib install taking forever * Add description to github actions package * Time to figure out why playwright detection isn't working * Turns out I am just dumb and left playwright out of the curve tab's dependencies * Use headless install of playwright instead * Miscellanous changes * Update docs and lint configuration for quotes * Fix the inconsistent semicolon delimiting in typescript types and interfaces * Remove useless workspaces and modify templates to include all scripts * Test playwright caching * Try another way to parse json * Try installing the tab package * Try focusing everything at once * Check if the playwright directory is found * Fix error handling not working * Maybe this will work * Try playwright tool caching * Use the workspace command instead * Fix using the wrong playwright option * Does adding the mkdirP call work? * Use cache instead of tool-cache * Remove tool-cache * Restore everything else and stop using caching for playwright * Add missing repotools tests * Remove testing related tests since we can't really mock vite * Update some dependencies * Fix it and test being able to be called recursively * Add doc info on describe function titles * Format the summary produced by the info action to be better * Fix base url not working correctly * Fix the url not working again * Fix url handling again * Add tests for rune bundle and tab * Update test coverage configuration * Add tests for plotly and painter tabs * Fix issue with configs not being cloned properly * Fix curve bundle functions and tests * Add anaglyph rune test * Fix tests not working correctly * Add tests for sound and stereo_sound bundles * Add tests to repl * Update some documentation * Try adding a github actions reporter * Fix incorrect build * Remove the requirement to build the reporter * Try a version with actions/core bundled * Add the uncovered lines information * Fix linting and some other things * Sort test coverage output * Try adding some colors * More formatting * Fix nested td in html * Reformat uncovered lines list * Hide uncovered lines in a summary * Final modifications * Update documenation for the vitest coverage reporter * Remove the dependency on actions/core * Use fs directly since istanbul context writer doesn't support appending * Add a summary reporter for tests * Fix broken paths * Fix an undefined check? * Try another reporter implementation * Fix continue to fix formatting * Fix formatting again * Fix test formatter * More formatting fixes * Found the way to get the file name * Fix filepath * Add start time for test modules * Try to fix the start times * Add slow indicator * Add docs about test coverage * Change defineTab type to be generic * Fix stereo sound tab not retrieving the correct module state * Update test reporter to follow the summary format * Add the silent option to tests * Fix tests for curve and rune tabs and unittest * Fix some oversight in eslint styles * Add tests for the unittest bundle mocking functions * Add a constraint to prevent js-slang from being resolved to something weird * Add a paragraph on test file naming * Fix the vitest reporter being written in cjs and tests * Use instanceof for type guards * Try using a default import for the coverage reporter * Try using named imports * Try using ESM * Revert to old coverage reporter * Try this combination of ESM and CJS to see if it works * FIx incorrect path to coverage reporter * FIx the typescript errors with the coverage reporter * Disable import/no-cycle rule to save linting time * Update eslint to make use of the new concurrent option * Add rule to redirect imports to extra typings for commander * Fix tsc error * Use the minified version of the reporter * Update test configuration * Add more tests for actions * Add tests and fix linting * FIx skipped tests displaying empty duration strings * Try to fix the duration string again * Try to fix the duration string again * Manually check the state of the test instead * Separate the lint check into two different steps * Move linting step into the matrix * Revert "Move linting step into the matrix" This reverts commit 2934fa3. * Revert "Separate the lint check into two different steps" This reverts commit 54a5659. * Update inaccurate test counts * Update documentation further * Improve binary tree typing and add tests * Fix incorrect command test name * Fix types and tests for binary tree bundle * Fix documentation inconsistencies * Add more documentation regarding errors and type-checking * Remove unnecessary type assertions from code * Add two logging commands to the lint command * Fix wrong prefix for lint command * Disable no unnecessary type assertions since it's not working properly * Add tests for pix_n_flix * Fix incorrect react type package * Update docs to add description about versioning and writing documentation * Continue to fix linting and documentation issues * Correct documentation errors * Improve type-checking for sound bundle * Remove unnecessary calls to get_duration and get_wave * Update stereo_sound and sound bundle functions to include better type-checking * Rename unittest test file * Rename test files to include .test. * Update snapshots * Add developer documentation for bundles * Modify the bundle specific documentations * Fix broken links * Add tests to sound * Add tests to sound bundle * minor fixes * Remove @vitest/browser package * Add spell checking to documentation * Update spellcheck configuration to exclude modules-lib * Fix dead link * Update documentations * Add a section documenting spell checking * Fix the numbering * Continue removing @vitest/browser * Fix incorrect path in tab template command * Fix tab template command adding version to bundle manifest * Use the direct import instead of the barrel lodash import * Try updating all of the testing packages * Continue fixing broken tests * Fix tests for robot_simulation * Fix sound bundle tests * Fix repo tools tests * Update tsconfigs to include noEmit true * Make manifest errors more informative * Add eols to tsconfigs * Split the list command into two * Separate tests for list and validate command * Update documentation to reflect the new browser mode API * Improve documentation about testing * Update buildtools docs * Update vitest to the version that doesn't need the path and fs module aliases * Update coverage configuration * Fix coverage exclusion pattern excluding buildtools * Make sure to await render calls in tests * Use vi.stubGlobal instead Object.defineProperty * Remove the need for noEmit on a per bundle basis * Update some documentation * FIx broken test * Minor fix to MultItemDisplay * Standardize Markdown formatting * Fix SASS warnings * Remove unused styles from devserver * Reformat all markdown files * Bump node version * Update actions versions * Update editor settings and add recommended extensions * Revert change to plotly functions.ts * Move vitest to ts files * Update testing configuration and documentation related to testing * Update an incorrect linting configuration * Update workflows to use node24 * Fix incorreect tsconfig for modules lib * Fix ESLint not correctly detecting tsconfig for vitest files * Fix broken buildtools test * Make the test include pattern a posix path instead of a windows path * Move test configuration utiliites from buildtools to repotools and fix browser mode not getting merged correctly * Update some tests * Update devserver vite configuration to include missing optimizeDeps * Update docs to reflect that bundles can also use browser mode for testing * Reformat markdown * Fix tsconfig * Fix plotly breaking changes * Remove extraneous newline * Remove unused snapshots * Remove old Jest snapshot * Add termination workflow for easy branch protections --------- Co-authored-by: Richard Dominick <[email protected]>
1 parent 73beb14 commit ed1fe71

File tree

826 files changed

+216396
-189894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

826 files changed

+216396
-189894
lines changed

.github/actions/build.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// @ts-check
2+
import getBuildCommand from '@sourceacademy/modules-repotools/builder';
3+
4+
const buildCommand = getBuildCommand({
5+
bundle: true,
6+
entryPoints: [
7+
{ in: './src/info/index.ts', out: 'info' },
8+
{ in: './src/load-artifacts/index.ts', out: 'load' }
9+
],
10+
format: 'esm',
11+
outdir: 'dist',
12+
packages: 'external',
13+
platform: 'node',
14+
target: 'node20',
15+
});
16+
17+
await buildCommand.parseAsync();

.github/actions/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "@sourceacademy/modules-github-actions",
3+
"description": "Github Actions for the modules repository",
4+
"private": true,
5+
"type": "module",
6+
"devDependencies": {
7+
"@sourceacademy/modules-repotools": "workspace:^",
8+
"@types/node": "^22.15.30",
9+
"typescript": "^5.8.2",
10+
"vitest": "^4.0.4"
11+
},
12+
"dependencies": {
13+
"@actions/artifact": "^2.3.2",
14+
"@actions/core": "^1.11.1",
15+
"@actions/exec": "^1.1.1",
16+
"lodash": "^4.17.21"
17+
},
18+
"scripts": {
19+
"build": "node ./build.js",
20+
"postinstall": "yarn build",
21+
"test": "vitest",
22+
"tsc": "tsc --project ./tsconfig.json"
23+
}
24+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import * as exec from '@actions/exec';
2+
import { describe, expect, it, test, vi } from 'vitest';
3+
import * as commons from '../commons.js';
4+
5+
vi.mock(import('lodash/memoize.js'), () => ({
6+
default: (x: any) => x
7+
}) as any);
8+
9+
const mockedExecOutput = vi.spyOn(exec, 'getExecOutput');
10+
11+
describe(commons.checkForChanges, () => {
12+
function mockChanges(value: boolean) {
13+
mockedExecOutput.mockResolvedValueOnce({
14+
exitCode: value ? 1 : 0, stdout: '', stderr: ''
15+
});
16+
}
17+
18+
it('should return true if git diff exits with non zero code', async () => {
19+
mockChanges(true);
20+
await expect(commons.checkForChanges('/')).resolves.toEqual(true);
21+
expect(mockedExecOutput).toHaveBeenCalledOnce();
22+
});
23+
24+
it('should return false if git diff exits with 0', async () => {
25+
mockChanges(false);
26+
27+
await expect(commons.checkForChanges('/')).resolves.toEqual(false);
28+
expect(mockedExecOutput).toHaveBeenCalledOnce();
29+
});
30+
});
31+
32+
describe(commons.isPackageRecord, () => {
33+
test('no bundleName or tabName property is ok', () => {
34+
expect(commons.isPackageRecord({
35+
directory: '',
36+
name: '',
37+
changes: false,
38+
needsPlaywright: false
39+
})).toEqual(true);
40+
});
41+
42+
test('string bundleName property is ok', () => {
43+
expect(commons.isPackageRecord({
44+
directory: '',
45+
name: '',
46+
changes: false,
47+
needsPlaywright: false,
48+
bundleName: ''
49+
})).toEqual(true);
50+
});
51+
52+
test('non-string bundleName property is not ok', () => {
53+
expect(commons.isPackageRecord({
54+
directory: '',
55+
name: '',
56+
changes: false,
57+
needsPlaywright: false,
58+
bundleName: 0
59+
})).toEqual(false);
60+
});
61+
62+
test('string tabName property is ok', () => {
63+
expect(commons.isPackageRecord({
64+
directory: '',
65+
name: '',
66+
changes: false,
67+
needsPlaywright: false,
68+
tabName: ''
69+
})).toEqual(true);
70+
});
71+
72+
test('non-string tabName property is not ok', () => {
73+
expect(commons.isPackageRecord({
74+
directory: '',
75+
name: '',
76+
changes: false,
77+
needsPlaywright: false,
78+
tabName: 0
79+
})).toEqual(false);
80+
});
81+
82+
test('having both bundleName and tabName property is not ok', () => {
83+
expect(commons.isPackageRecord({
84+
directory: '',
85+
name: '',
86+
changes: false,
87+
needsPlaywright: false,
88+
tabName: '',
89+
bundleName: ''
90+
})).toEqual(false);
91+
});
92+
});

.github/actions/src/commons.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { getExecOutput } from '@actions/exec';
2+
import memoize from 'lodash/memoize.js';
3+
4+
export interface RawPackageRecord {
5+
directory: string;
6+
hasChanges: boolean;
7+
package: {
8+
name: string;
9+
devDependencies: Record<string, string>;
10+
dependencies: Record<string, string>;
11+
};
12+
}
13+
14+
interface BasePackageRecord {
15+
/**
16+
* Directory within which the `package.json` file was found
17+
*/
18+
directory: string;
19+
20+
/**
21+
* Full scoped package name
22+
*/
23+
name: string;
24+
/**
25+
* `true` if git detected changes from within the package's subdirectories,
26+
* `false` otherwise
27+
*/
28+
changes: boolean;
29+
/**
30+
* `true` if playwright is present under devDependencies. This means that the package
31+
* might need playwright for its tests
32+
*/
33+
needsPlaywright: boolean;
34+
}
35+
36+
export interface BundlePackageRecord extends BasePackageRecord {
37+
bundleName: string;
38+
}
39+
40+
export interface TabPackageRecord extends BasePackageRecord {
41+
tabName: string;
42+
}
43+
44+
export type PackageRecord = BundlePackageRecord | TabPackageRecord | BasePackageRecord;
45+
46+
export function isPackageRecord(obj: unknown): obj is PackageRecord {
47+
if (typeof obj !== 'object' || obj === null) return false;
48+
49+
if (!('directory' in obj) || typeof obj.directory !== 'string') return false;
50+
if (!('name' in obj) || typeof obj.name !== 'string') return false;
51+
if (!('changes' in obj) || typeof obj.changes !== 'boolean') return false;
52+
if (!('needsPlaywright' in obj) || typeof obj.needsPlaywright !== 'boolean') return false;
53+
54+
if ('bundleName' in obj) {
55+
if ('tabName' in obj || typeof obj.bundleName !== 'string') return false;
56+
} else if ('tabName' in obj) {
57+
if (typeof obj.tabName !== 'string') return false;
58+
}
59+
60+
return true;
61+
}
62+
63+
// Not using the repotools version since this uses @action/exec instead of
64+
// calling execFile from child_process
65+
export async function getGitRoot() {
66+
const { stdout } = await getExecOutput('git rev-parse --show-toplevel');
67+
return stdout.trim();
68+
}
69+
70+
/**
71+
* Returns `true` if there are changes present in the given directory relative to
72+
* the master branch\
73+
* Used to determine, particularly for libraries, if running tests and tsc are necessary
74+
*/
75+
export const checkForChanges = memoize(async (directory: string) => {
76+
const { exitCode } = await getExecOutput(
77+
'git',
78+
['--no-pager', 'diff', '--quiet', 'origin/master', '--', directory],
79+
{
80+
failOnStdErr: false,
81+
ignoreReturnCode: true
82+
}
83+
);
84+
return exitCode !== 0;
85+
});

0 commit comments

Comments
 (0)