Skip to content

Commit 317c1bf

Browse files
authored
Merge pull request #593 from rage/2-1-0
Release 2.1.0
2 parents 8c52f13 + 504d525 commit 317c1bf

File tree

93 files changed

+3020
-2200
lines changed

Some content is hidden

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

93 files changed

+3020
-2200
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
dist
44
**/node_modules
55
out
6+
test-artifacts/
67
test-resources/
78
submodules/
89
.vscode-test/

.github/workflows/nodejs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ jobs:
3434
npm run setup
3535
chmod -R +x cli
3636
cd ..
37-
- name: Run tests
37+
- name: Unit tests
3838
uses: GabrielBB/[email protected]
3939
with:
4040
run: npm test
41+
- name: Integration tests
42+
uses: GabrielBB/[email protected]
43+
with:
44+
run: npm run test-integration-only integration

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Project files
22
.vscode-test/
33
node_modules/
4+
test-artifacts/
45
test-resources/
56
.eslintcache
67
vscode.proposed.d.ts

.vscode/launch.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,19 @@
2424
"--extensionDevelopmentPath=${workspaceFolder}",
2525
"--extensionTestsPath=${workspaceFolder}/bin/testLoader"
2626
],
27-
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
27+
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
28+
"preLaunchTask": "webpackBuild"
29+
},
30+
{
31+
"name": "Integration tests",
32+
"type": "extensionHost",
33+
"request": "launch",
34+
"runtimeExecutable": "${execPath}",
35+
"args": [
36+
"--extensionDevelopmentPath=${workspaceFolder}",
37+
"--extensionTestsPath=${workspaceFolder}/bin/integrationLoader"
38+
],
39+
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
2840
"preLaunchTask": "webpackBuild"
2941
}
3042
]

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"search.exclude": {
1111
"**/out": true
1212
},
13+
"files.eol": "\n",
1314
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
1415
"typescript.tsc.autoDetect": "off",
1516
"html.validate.scripts": false,

.vscodeignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ types/**
1818
**/.gitmodules
1919
**/.eslintignore
2020
**/.eslintrc.json
21-
**/dist/testBundle*
21+
**dist/integration*
22+
**/dist/test*
2223
**/tsconfig.json
2324
**/tsconfig.production.json
2425
**/tslint.json

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## [2.1.0] - 2021-07-05
4+
5+
#### Added
6+
7+
- Exercise decorations: Show completed, expired, partially completed and missing in course workspace file tree.
8+
- Automatically download old submission (disabled since version 2.0.0).
9+
10+
#### Changed
11+
- Bumped TMC-langs to version 0.21.0-beta-4.
12+
- Moved Extension Settings behind VSCode Settings API. [Read more...](https://code.visualstudio.com/docs/getstarted/settings)
13+
- Moved TMC folder selection to My Courses page.
14+
15+
#### Removed
16+
- Custom Settings webview.
17+
18+
#### Security
19+
- Updated dependencies.
320
## [2.0.3] - 2021-06-28
421

522
#### Fixed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Students of its various organizations can download, complete and return course e
1212

1313
## Prerequisites
1414

15-
* Visual Studio Code version 1.40.xx or above
15+
* Visual Studio Code version 1.52.xx or above
1616
* [TestMyCode](https://tmc.mooc.fi/) account
1717
* Course-specific system environment
1818

backend/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ import {
2727

2828
const PORT = 4001;
2929

30+
interface DetailsForLangs {
31+
exercises: Array<{
32+
id: number;
33+
checksum: string;
34+
course_name: string;
35+
exercise_name: string;
36+
}>;
37+
}
38+
3039
const testOrganization = createOrganization({
3140
information: "This is a test organization from a local development server.",
3241
name: "Test Organization",
@@ -53,6 +62,7 @@ const submissions = [
5362
exerciseName: passingExercise.name,
5463
id: 0,
5564
passed: true,
65+
timestamp: new Date(2000, 1, 1),
5666
userId: 0,
5767
}),
5868
];
@@ -111,6 +121,21 @@ app.get(`/api/v8/core/courses/${pythonCourse.id}`, (req, res: Response<CourseDet
111121
}),
112122
);
113123

124+
// downloadExercises()
125+
app.get("/api/v8/core/exercises/details", (req, res: Response<DetailsForLangs>) => {
126+
const rawIds = req.query.ids;
127+
const ids = Array.isArray(rawIds) ? rawIds : [rawIds];
128+
const filtered = [passingExercise].filter((x) => ids.includes(x.id.toString()));
129+
return res.json({
130+
exercises: filtered.map((x) => ({
131+
id: x.id,
132+
checksum: x.checksum,
133+
course_name: "python-course",
134+
exercise_name: x.exercise_name,
135+
})),
136+
});
137+
});
138+
114139
// getExerciseDetails(1)
115140
app.get(`/api/v8/core/exercises/${passingExercise.id}`, (req, res: Response<ExerciseDetails>) =>
116141
res.json({ ...passingExercise, course_id: pythonCourse.id, course_name: pythonCourse.name }),
@@ -134,6 +159,7 @@ app.post(
134159
exerciseName: passingExercise.name,
135160
id: passingExercise.id,
136161
passed: true,
162+
timestamp: new Date(),
137163
userId: 0,
138164
}),
139165
);

backend/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const copyTMCPythonModules = async (): Promise<void> => {
2323
ncp(module, target, () => {});
2424
});
2525
console.log("Modules copied!");
26-
26+
await new Promise((res) => setTimeout(res, 1000));
2727
await Promise.all(
2828
pythonExercises.map(async (exercise) => {
2929
console.log(`Creating download archive for ${exercise}`);

backend/utils.ts

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -155,35 +155,39 @@ interface CreateOldSubmissionParams {
155155
exerciseName: string;
156156
id: number;
157157
passed: boolean;
158+
timestamp: Date;
158159
userId: number;
159160
}
160161

161-
const createOldSubmission = (params: CreateOldSubmissionParams): OldSubmission => ({
162-
all_tests_passed: params.passed,
163-
course_id: params.courseId,
164-
created_at: "",
165-
exercise_name: params.exerciseName,
166-
id: params.id,
167-
message_for_paste: "",
168-
message_for_reviewer: "",
169-
newer_submission_reviewed: false,
170-
params_json: "",
171-
paste_available: false,
172-
paste_key: "",
173-
points: "",
174-
pretest_error: "",
175-
processed: true,
176-
processing_attempts_started_at: "",
177-
processing_began_at: "",
178-
processing_completed_at: "",
179-
processing_tried_at: "",
180-
requests_review: false,
181-
requires_review: false,
182-
review_dismissed: false,
183-
reviewed: false,
184-
times_sent_to_sandbox: 1,
185-
user_id: 0,
186-
});
162+
const createOldSubmission = (params: CreateOldSubmissionParams): OldSubmission => {
163+
const timestamp = params.timestamp.toISOString();
164+
return {
165+
all_tests_passed: params.passed,
166+
course_id: params.courseId,
167+
created_at: timestamp,
168+
exercise_name: params.exerciseName,
169+
id: params.id,
170+
message_for_paste: "",
171+
message_for_reviewer: "",
172+
newer_submission_reviewed: false,
173+
params_json: "",
174+
paste_available: false,
175+
paste_key: "",
176+
points: "",
177+
pretest_error: "",
178+
processed: true,
179+
processing_attempts_started_at: timestamp,
180+
processing_began_at: timestamp,
181+
processing_completed_at: timestamp,
182+
processing_tried_at: timestamp,
183+
requests_review: false,
184+
requires_review: false,
185+
review_dismissed: false,
186+
reviewed: false,
187+
times_sent_to_sandbox: 1,
188+
user_id: 0,
189+
};
190+
};
187191

188192
const respondWithFile = (res: Response, file: string): void =>
189193
res.sendFile(file, (error) => {

bin/integrationLoader.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//@ts-check
2+
3+
const Mocha = require("mocha");
4+
const path = require("path");
5+
6+
function run() {
7+
// Create the mocha test
8+
const mocha = new Mocha({
9+
ui: "tdd",
10+
color: true,
11+
});
12+
13+
return new Promise((c, e) => {
14+
mocha.addFile(path.resolve(__dirname, "..", "dist", "integration.spec.js"));
15+
16+
try {
17+
// Run the mocha test
18+
mocha.run((failures) => {
19+
if (failures > 0) {
20+
e(new Error(`${failures} tests failed.`));
21+
} else {
22+
c();
23+
}
24+
});
25+
} catch (err) {
26+
e(err);
27+
}
28+
});
29+
}
30+
31+
exports.run = run;

bin/runIntegration.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//@ts-check
2+
3+
const path = require("path");
4+
const runTests = require("vscode-test").runTests;
5+
6+
async function main() {
7+
let exitCode = 0;
8+
/**@type {import("child_process").ChildProcess} */
9+
try {
10+
const platform =
11+
process.platform === "win32" && process.arch === "x64"
12+
? "win32-x64-archive"
13+
: undefined;
14+
15+
// The folder containing the Extension Manifest package.json
16+
// Passed to `--extensionDevelopmentPath`
17+
const extensionDevelopmentPath = path.resolve(__dirname, "..");
18+
19+
// The path to test runner
20+
// Passed to --extensionTestsPath
21+
const extensionTestsPath = path.resolve(__dirname, "integrationLoader");
22+
23+
// Download VS Code, unzip it and run the integration test
24+
await runTests({ extensionDevelopmentPath, extensionTestsPath, platform });
25+
} catch (err) {
26+
console.error("Failed to run tests");
27+
exitCode = 1;
28+
}
29+
30+
process.exit(exitCode);
31+
}
32+
33+
main();

bin/runTests.js

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,12 @@
11
//@ts-check
22

3-
const cp = require("child_process");
43
const path = require("path");
5-
const kill = require("tree-kill");
64
const runTests = require("vscode-test").runTests;
75

8-
/**@returns {Promise<import("child_process").ChildProcess>} */
9-
async function startServer() {
10-
let ready = false;
11-
console.log(path.join(__dirname, "..", "backend"));
12-
const server = cp.spawn("npm", ["start"], {
13-
cwd: path.join(__dirname, "..", "backend"),
14-
shell: "bash",
15-
});
16-
server.stdout.on("data", (chunk) => {
17-
if (chunk.toString().startsWith("Server listening to")) {
18-
ready = true;
19-
}
20-
});
21-
22-
const timeout = setTimeout(() => {
23-
throw new Error("Failed to start server");
24-
}, 10000);
25-
26-
while (!ready) {
27-
await new Promise((resolve) => setTimeout(resolve, 1000));
28-
}
29-
30-
clearTimeout(timeout);
31-
return server;
32-
}
33-
346
async function main() {
357
let exitCode = 0;
368
/**@type {import("child_process").ChildProcess} */
37-
let backend;
389
try {
39-
backend = await startServer();
4010
const platform =
4111
process.platform === "win32" && process.arch === "x64"
4212
? "win32-x64-archive"
@@ -55,10 +25,9 @@ async function main() {
5525
} catch (err) {
5626
console.error("Failed to run tests");
5727
exitCode = 1;
58-
} finally {
59-
kill(backend.pid);
60-
process.exit(exitCode);
6128
}
29+
30+
process.exit(exitCode);
6231
}
6332

6433
main();

bin/testLoader.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ts-check
2+
13
const Mocha = require("mocha");
24
const path = require("path");
35

bin/validateRelease.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fi
2222
packageLockVersion=`grep -Eo '"version":.+$' package-lock.json`
2323
if [[ ! $packageLockVersion =~ '"version": "'$tagVersion'",' ]]
2424
then
25-
echo "Error: The version in package-lock.json doesn't match with the tag. Did you forget to run npm install?"
25+
echo "Error: The version in package-lock.json doesn't match with the tag."
2626
exitCode=1
2727
fi
2828

@@ -35,4 +35,12 @@ then
3535
exitCode=1
3636
fi
3737

38+
# All configured Langs versions should exist on the download server.
39+
node ./bin/verifyThatLangsBuildsExist.js
40+
if [ $? != 0 ]
41+
then
42+
echo "Error: Failed to verify that all Langs builds exist."
43+
exitCode=1
44+
fi
45+
3846
exit $exitCode

0 commit comments

Comments
 (0)