Skip to content

Feature/validate #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
validate progress
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jun 13, 2020
commit 5b1a6dd4723f44649d6db1cdb34fcf3844bb7f52
67 changes: 37 additions & 30 deletions src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as yamlParser from "js-yaml";
import { getArg } from "./utils/args";
import gitP, { SimpleGit } from "simple-git/promise";
import { getCommits, CommitLogObject } from "./utils/commits";
import simplegit from "simple-git/promise";

const mkdir = util.promisify(fs.mkdir);
const exists = util.promisify(fs.exists);
Expand All @@ -24,52 +25,58 @@ async function validate(args: string[]) {
const _yaml = await read(path.join(localDir, options.yaml), "utf8");

// parse yaml config
let config;
let skeleton;
try {
config = yamlParser.load(_yaml);
skeleton = yamlParser.load(_yaml);

console.log("config", skeleton);
// TODO: validate yaml
if (!config || !config.length) {
if (!skeleton) {
throw new Error("Invalid yaml file contents");
}
} catch (e) {
console.error("Error parsing yaml");
console.error(e.message);
}

const codeBranch: string = config.config.repo.branch;

// VALIDATE SKELETON WITH COMMITS
const commits = getCommits({ localDir, codeBranch });
const codeBranch: string = skeleton.config.repo.branch;

// parse tutorial skeleton for order and commands
// validate commits
const commits = await getCommits({ localDir, codeBranch });

// on error, warn missing level/step
// setup tmp dir
const tmpDir = path.join(localDir, ".tmp");

// VALIDATE COMMIT ORDER
// list all commits in order
// validate that a level number doesn't come before another level
// validate that a step falls within a level
// validate that steps are in order
try {
if (!(await exists(tmpDir))) {
await mkdir(tmpDir);
}
const tempGit: SimpleGit = gitP(tmpDir);
await tempGit.init();

// on error, show level/step out of order
// VALIDATE TUTORIAL TESTS

// VALIDATE TUTORIAL TESTS
// load INIT commit(s)
// run test runner setup command(s)
// loop over commits:
// - load level commit
// - run level setup command(s)
// - load step setup commit(s)
// - run step setup command(s)
// - if next solution:
// - run test - expect fail
// - if solution
// - run test - expect pass
// run test runner setup command(s)
// loop over commits:
// - load level commit
// - run level setup command(s)
// - load step setup commit(s)
// - run step setup command(s)
// - if next solution:
// - run test - expect fail
// - if solution
// - run test - expect pass

// log level/step
// on error, show level/step & error message
// log level/step
// on error, show level/step & error message

// CLEANUP
// load INIT commit(s)
} catch (e) {
console.error(e.message);
} finally {
// cleanup
await rmdir(tmpDir);
}
}

export default validate;
File renamed without changes.