Skip to content
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

Improve auto checker #146

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 27 additions & 11 deletions .github/src/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,37 @@ const chapter = concolor('b,yellow');
const fatal = concolor('b,white/red');
const fixup = concolor('b,black/yellow');

let exitCode = 0;

const TITLE = 'Software engineering self assessment';
const PARSING_TIMEOUT = 1000;
const EXECUTION_TIMEOUT = 5000;

const PATH = path.join(process.cwd(), '../..');

const OUT = cp.execSync('git config --get remote.origin.url').toString();
const REPO = metautil.between(OUT, ':', '.');
let REPO = process.env.GITHUB_REPOSITORY;
if (!REPO) {
const OUT = cp.execSync('git config --get remote.origin.url').toString();
REPO = metautil.between(OUT, ':', '.');
}
const LINK = 'https://github.com/' + REPO;

const BASE = 'https://img.shields.io/badge/Self_Assessment-skills-009933';
const BASE = 'https://img.shields.io/badge/Self_Assessment-skills';
const STYLE = `style=flat-square`;
const BADGE = `[![Skills](${BASE}?${STYLE})](${LINK})`;

let exitCode = 0;
const generateBadge = () => {
const color = exitCode === 0 ? '009933' : 'FF3300';
return `[![Skills](${BASE}-${color}?${STYLE})](${LINK})`;
};

const UNITS = [
'Programming',
'JavaScript',
'Async',
'NodeJS',
'Paradigms',
'Architecture',
];


const wrongFormat = (msg, file) => {
exitCode = 1;
Expand Down Expand Up @@ -246,10 +262,9 @@ const getTotal = (answered) => {
const roles = await loadDir('.github/src/Roles');

console.log(caption`Match profiles`);
const units = Object.keys(skills);
const todos = [];
const totals = ['## Assessment totals\n'];
for (const unit of units) {
for (const unit of UNITS) {
console.log(chapter` Unit: ${unit}`);
const expected = roles[unit];
const answered = skills[unit];
Expand All @@ -263,16 +278,17 @@ const getTotal = (answered) => {
totals.push(...total);
}

const badgeCode = codeBlock(BADGE);
const badge = generateBadge();
const badgeCode = codeBlock(badge);
const report = [
`## ${TITLE}\n\n${BADGE}\n\n${badgeCode}\n`,
`## ${TITLE}\n\n${badge}\n\n${badgeCode}\n`,
...totals,
...todos,
].join('\n') + '\n';
await fs.writeFile(`${PATH}/Profile/REPORT.md`, report);

const template = await loadFile(`${PATH}/.github/src/Templates/README.md`);
const readme = template.replace('$BADGE', BADGE);
const readme = template.replace('$BADGE', badge);
await fs.writeFile(`${PATH}/README.md`, readme);

console.log('');
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ jobs:
- run: node check.js
working-directory: .github/src
- name: Generate results
if: always()
run: |
git config --global user.name "Metarhia skill bot"
git config --global user.email "[email protected]"
git add ./Profile ./README.md ./Skills
git commit -m "Automated skill analysis"
git commit -m "Automated skill analysis and report"
git push
Loading