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

fix(CI/CD): AG-45 added set -e parameter to workflow #38

Merged
merged 7 commits into from
Apr 17, 2024
Merged
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
2 changes: 1 addition & 1 deletion .jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"reporters": ["console"],
"languages": ["javascript", "typescript"],
"gitignore": true,
"failOnDuplication": false
"failOnDuplication": true
}

9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ Remember to follow this convention for commit messages: `AG-<jira id> <descripti

Smart contracts code coverage documentation [here](https://www.npmjs.com/package/solidity-coverage).

CI/CD workflow fails if the unit test code coverage threshold (**80% of lines of code**) for scripts is not met.
### Quality gates

| step | library used | theshold | is error blocking |
|------|--------------|----------|-------------------|
| Code Linting | [eslint](https://www.npmjs.com/package/eslint) | No thesholds | yes |
| Code duplication | [jscpd](https://www.npmjs.com/package/jscpd) | 10% | yes |
| Smart contracts unit tests | [jest](https://www.npmjs.com/package/jest) | all tests must pass | yes |
| TypeScript files unit tests | [jest](https://www.npmjs.com/package/jest) | all tests must pass; 80% code coverage | yes |

## Run the localhost development network

Expand Down
38 changes: 32 additions & 6 deletions ci/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,44 @@ const execSyncOptions = { stdio: "inherit" };

const functions = {
installDeps: function () {
return execSync("npm install", execSyncOptions);
try {
execSync("npm install", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
lint: function () {
return execSync("npm run lint", execSyncOptions);
try {
execSync("npm run lint", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
checksDuplications: function () {
return execSync("npm run duplicated", execSyncOptions);
try {
execSync("npm run duplicated", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
smartContractsUnitTest: function () {
return execSync("npm run test-contracts", execSyncOptions);
try {
execSync("npm run test-contracts", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
scriptsUnitTest: function () {
return execSync("npm run test-scripts", execSyncOptions);
try {
execSync("npm run test-scripts", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
tagRelease: function () {
try {
Expand All @@ -39,7 +64,8 @@ const functions = {
);
execSync("git push origin --tags", execSyncOptions);
} catch (e) {
throw new Error(e);
console.log(e);
process.exit(1);
}
},
};
Expand Down
Loading