Skip to content

Commit

Permalink
Merge pull request #65 from OperationSpark/auto-grading-FSD
Browse files Browse the repository at this point in the history
Auto grading fsd
  • Loading branch information
gregthompson27 authored Aug 5, 2022
2 parents 340e0ae + a025de8 commit cc35fc7
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "16"
- run: npm ci
- run: npm test
4 changes: 2 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "16"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm publish --dry-run
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
# https://javascript.plainenglish.io/publish-update-npm-packages-with-github-actions-e4d786ffd62a
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ files.json
project-lock.json
test/files/environment/projects
.secrets

user
auth
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion controller/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ function grabLocalLogin() {
if (!git) {
throw new Error(`There is no file at ${userFilePath}.`);
}
return git.login;
// Failover to `login` for backward-compatibility
return git.username || git.login;
}

module.exports.grabLocalLogin = grabLocalLogin;
Expand Down
2 changes: 1 addition & 1 deletion controller/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function report(testDir) {

const runner = mocha.run(() => {
process.stdout.write = stdoutWriteCopy;
res(runner.testResults);
});
res(runner.testResults);
});
}

Expand Down
4 changes: 3 additions & 1 deletion controller/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function createGist({ project, stats }) {
type: 'PROJECT',
tests: stats.tests,
passes: stats.passes,
failures: stats.failures
failures: stats.failures,
grade: Math.round(100 * (stats.passes / stats.tests))
};

let content = {
Expand All @@ -91,6 +92,7 @@ function createGist({ project, stats }) {
content = JSON.stringify(content);
return new Promise(function (res, rej) {
console.log(clc.yellow('Creating gist. . .'));

const cmd = createGistHelper(
github.grabLocalLogin(),
github.grabLocalAuthToken(),
Expand Down
11 changes: 2 additions & 9 deletions controller/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,8 @@ function displayResults({ testResults }) {
//part divided by the whole 3/4 = 75%
//use math.round to round to the nearest whole percent
let grade = Math.round(100 * (testResults.stats.passes / testResults.stats.tests))
if(grade > 75) {
console.log(
clc.yellow(`You have passed ${grade}% of the test.`)
)
} else {
console.log(
clc.red(`You have passed ${grade}% of the test.`)
)
}
const clcMethod = grade > 75 ? clc.yellow : clc.red;
console.log(clcMethod(`You have passed ${grade}% of the test.`));

return { pass: false, grade: grade };
}
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cc35fc7

Please sign in to comment.