Skip to content

Commit

Permalink
Merge pull request #593 from rage/2-1-0
Browse files Browse the repository at this point in the history
Release 2.1.0
  • Loading branch information
sebazai authored Jul 5, 2021
2 parents 8c52f13 + 504d525 commit 317c1bf
Show file tree
Hide file tree
Showing 93 changed files with 3,020 additions and 2,200 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
dist
**/node_modules
out
test-artifacts/
test-resources/
submodules/
.vscode-test/
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ jobs:
npm run setup
chmod -R +x cli
cd ..
- name: Run tests
- name: Unit tests
uses: GabrielBB/[email protected]
with:
run: npm test
- name: Integration tests
uses: GabrielBB/[email protected]
with:
run: npm run test-integration-only integration
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Project files
.vscode-test/
node_modules/
test-artifacts/
test-resources/
.eslintcache
vscode.proposed.d.ts
Expand Down
14 changes: 13 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,19 @@
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/bin/testLoader"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "webpackBuild"
},
{
"name": "Integration tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/bin/integrationLoader"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "webpackBuild"
}
]
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"search.exclude": {
"**/out": true
},
"files.eol": "\n",
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"html.validate.scripts": false,
Expand Down
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ types/**
**/.gitmodules
**/.eslintignore
**/.eslintrc.json
**/dist/testBundle*
**dist/integration*
**/dist/test*
**/tsconfig.json
**/tsconfig.production.json
**/tslint.json
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## [2.1.0] - 2021-07-05

#### Added

- Exercise decorations: Show completed, expired, partially completed and missing in course workspace file tree.
- Automatically download old submission (disabled since version 2.0.0).

#### Changed
- Bumped TMC-langs to version 0.21.0-beta-4.
- Moved Extension Settings behind VSCode Settings API. [Read more...](https://code.visualstudio.com/docs/getstarted/settings)
- Moved TMC folder selection to My Courses page.

#### Removed
- Custom Settings webview.

#### Security
- Updated dependencies.
## [2.0.3] - 2021-06-28

#### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Students of its various organizations can download, complete and return course e

## Prerequisites

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

Expand Down
26 changes: 26 additions & 0 deletions backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ import {

const PORT = 4001;

interface DetailsForLangs {
exercises: Array<{
id: number;
checksum: string;
course_name: string;
exercise_name: string;
}>;
}

const testOrganization = createOrganization({
information: "This is a test organization from a local development server.",
name: "Test Organization",
Expand All @@ -53,6 +62,7 @@ const submissions = [
exerciseName: passingExercise.name,
id: 0,
passed: true,
timestamp: new Date(2000, 1, 1),
userId: 0,
}),
];
Expand Down Expand Up @@ -111,6 +121,21 @@ app.get(`/api/v8/core/courses/${pythonCourse.id}`, (req, res: Response<CourseDet
}),
);

// downloadExercises()
app.get("/api/v8/core/exercises/details", (req, res: Response<DetailsForLangs>) => {
const rawIds = req.query.ids;
const ids = Array.isArray(rawIds) ? rawIds : [rawIds];
const filtered = [passingExercise].filter((x) => ids.includes(x.id.toString()));
return res.json({
exercises: filtered.map((x) => ({
id: x.id,
checksum: x.checksum,
course_name: "python-course",
exercise_name: x.exercise_name,
})),
});
});

// getExerciseDetails(1)
app.get(`/api/v8/core/exercises/${passingExercise.id}`, (req, res: Response<ExerciseDetails>) =>
res.json({ ...passingExercise, course_id: pythonCourse.id, course_name: pythonCourse.name }),
Expand All @@ -134,6 +159,7 @@ app.post(
exerciseName: passingExercise.name,
id: passingExercise.id,
passed: true,
timestamp: new Date(),
userId: 0,
}),
);
Expand Down
2 changes: 1 addition & 1 deletion backend/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const copyTMCPythonModules = async (): Promise<void> => {
ncp(module, target, () => {});
});
console.log("Modules copied!");

await new Promise((res) => setTimeout(res, 1000));
await Promise.all(
pythonExercises.map(async (exercise) => {
console.log(`Creating download archive for ${exercise}`);
Expand Down
56 changes: 30 additions & 26 deletions backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,35 +155,39 @@ interface CreateOldSubmissionParams {
exerciseName: string;
id: number;
passed: boolean;
timestamp: Date;
userId: number;
}

const createOldSubmission = (params: CreateOldSubmissionParams): OldSubmission => ({
all_tests_passed: params.passed,
course_id: params.courseId,
created_at: "",
exercise_name: params.exerciseName,
id: params.id,
message_for_paste: "",
message_for_reviewer: "",
newer_submission_reviewed: false,
params_json: "",
paste_available: false,
paste_key: "",
points: "",
pretest_error: "",
processed: true,
processing_attempts_started_at: "",
processing_began_at: "",
processing_completed_at: "",
processing_tried_at: "",
requests_review: false,
requires_review: false,
review_dismissed: false,
reviewed: false,
times_sent_to_sandbox: 1,
user_id: 0,
});
const createOldSubmission = (params: CreateOldSubmissionParams): OldSubmission => {
const timestamp = params.timestamp.toISOString();
return {
all_tests_passed: params.passed,
course_id: params.courseId,
created_at: timestamp,
exercise_name: params.exerciseName,
id: params.id,
message_for_paste: "",
message_for_reviewer: "",
newer_submission_reviewed: false,
params_json: "",
paste_available: false,
paste_key: "",
points: "",
pretest_error: "",
processed: true,
processing_attempts_started_at: timestamp,
processing_began_at: timestamp,
processing_completed_at: timestamp,
processing_tried_at: timestamp,
requests_review: false,
requires_review: false,
review_dismissed: false,
reviewed: false,
times_sent_to_sandbox: 1,
user_id: 0,
};
};

const respondWithFile = (res: Response, file: string): void =>
res.sendFile(file, (error) => {
Expand Down
31 changes: 31 additions & 0 deletions bin/integrationLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//@ts-check

const Mocha = require("mocha");
const path = require("path");

function run() {
// Create the mocha test
const mocha = new Mocha({
ui: "tdd",
color: true,
});

return new Promise((c, e) => {
mocha.addFile(path.resolve(__dirname, "..", "dist", "integration.spec.js"));

try {
// Run the mocha test
mocha.run((failures) => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
e(err);
}
});
}

exports.run = run;
33 changes: 33 additions & 0 deletions bin/runIntegration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//@ts-check

const path = require("path");
const runTests = require("vscode-test").runTests;

async function main() {
let exitCode = 0;
/**@type {import("child_process").ChildProcess} */
try {
const platform =
process.platform === "win32" && process.arch === "x64"
? "win32-x64-archive"
: undefined;

// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, "..");

// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, "integrationLoader");

// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath, platform });
} catch (err) {
console.error("Failed to run tests");
exitCode = 1;
}

process.exit(exitCode);
}

main();
35 changes: 2 additions & 33 deletions bin/runTests.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
//@ts-check

const cp = require("child_process");
const path = require("path");
const kill = require("tree-kill");
const runTests = require("vscode-test").runTests;

/**@returns {Promise<import("child_process").ChildProcess>} */
async function startServer() {
let ready = false;
console.log(path.join(__dirname, "..", "backend"));
const server = cp.spawn("npm", ["start"], {
cwd: path.join(__dirname, "..", "backend"),
shell: "bash",
});
server.stdout.on("data", (chunk) => {
if (chunk.toString().startsWith("Server listening to")) {
ready = true;
}
});

const timeout = setTimeout(() => {
throw new Error("Failed to start server");
}, 10000);

while (!ready) {
await new Promise((resolve) => setTimeout(resolve, 1000));
}

clearTimeout(timeout);
return server;
}

async function main() {
let exitCode = 0;
/**@type {import("child_process").ChildProcess} */
let backend;
try {
backend = await startServer();
const platform =
process.platform === "win32" && process.arch === "x64"
? "win32-x64-archive"
Expand All @@ -55,10 +25,9 @@ async function main() {
} catch (err) {
console.error("Failed to run tests");
exitCode = 1;
} finally {
kill(backend.pid);
process.exit(exitCode);
}

process.exit(exitCode);
}

main();
2 changes: 2 additions & 0 deletions bin/testLoader.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ts-check

const Mocha = require("mocha");
const path = require("path");

Expand Down
10 changes: 9 additions & 1 deletion bin/validateRelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi
packageLockVersion=`grep -Eo '"version":.+$' package-lock.json`
if [[ ! $packageLockVersion =~ '"version": "'$tagVersion'",' ]]
then
echo "Error: The version in package-lock.json doesn't match with the tag. Did you forget to run npm install?"
echo "Error: The version in package-lock.json doesn't match with the tag."
exitCode=1
fi

Expand All @@ -35,4 +35,12 @@ then
exitCode=1
fi

# All configured Langs versions should exist on the download server.
node ./bin/verifyThatLangsBuildsExist.js
if [ $? != 0 ]
then
echo "Error: Failed to verify that all Langs builds exist."
exitCode=1
fi

exit $exitCode
Loading

0 comments on commit 317c1bf

Please sign in to comment.