Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit dde8125

Browse files
Merge pull request #2 from codiga/feat/more-tests
feat/more tests
2 parents c318eee + b2eae6e commit dde8125

File tree

13 files changed

+221
-36
lines changed

13 files changed

+221
-36
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
coverage
2+
coverage
3+
.vscode
4+
codiga-cli*.tgz

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
DEVELOPMENT.md
2+
tests
3+
coverage
4+
babel.config.js
5+
jest.config.js
6+
.github
7+
.vscode
8+
codiga-cli*.tgz

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

DEVELOPMENT.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,32 @@
2222

2323
### Running the tests
2424

25-
```bash
26-
npm run test
27-
```
25+
- Install and symlink the package as described in the Getting Started
26+
27+
```bash
28+
npm i
29+
npm link
30+
```
31+
32+
- Run the test script
33+
34+
```bash
35+
npm run test
36+
```
37+
38+
> We'll automatically run the tests on `push` and `merge-request` actions. You can see past workflow runs [here](https://github.com/codiga/codiga-cli/actions/workflows/main.yml).
39+
40+
### Release a new version
41+
42+
- Open a MR with your new changes
43+
- Bump the version in `package.json` and `package-lock.json` and commit it as well
44+
- Once that's merged, go to [releases](https://github.com/codiga/codiga-cli/releases) and draft a new release
45+
- Choose a tag > Create a new tag > `vX.X.X` (should match your new version above)
46+
- Generate release notes
47+
- Publish release
48+
- Verify the following:
49+
- The [Release Github Action](https://github.com/codiga/codiga-cli/actions/workflows/release.yml) is successful
50+
- The [NPM package](https://www.npmjs.com/package/@codiga/cli) was updated
2851

2952
### Notes
3053

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codiga/cli",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "A Codiga CLI used to integrate Codiga easily in your projects",
55
"homepage": "https://github.com/codiga/codiga-cli",
66
"repository": {

src/checkPush.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ export async function checkPush(remoteShaArg, localShaArg) {
145145
if (violations.length === 0 && errors.length === 0) {
146146
process.exit(0);
147147
} else {
148+
printEmptyLine();
149+
printInfo("Do you consider these violations as false positives?");
150+
printSuggestion(
151+
" ↳ You can add the following flag to your `git push` to bypass this check:",
152+
"--no-verify"
153+
);
154+
printSuggestion(
155+
" ↳ Consider commenting on those rules in the Codiga Hub, so the maintainer can improve them:",
156+
"https://app.codiga.io/hub/rulesets"
157+
);
158+
printEmptyLine();
148159
process.exit(1);
149160
}
150161
}

tests/check-push.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ACTION_GIT_PUSH_HOOK, BLANK_SHA } from "../utils/constants";
2-
import { setToken } from "../utils/store";
3-
import { executeCommand, SAMPLE_TOKEN } from "./test-utils";
2+
import { executeCommand } from "./test-utils";
43

54
describe("codiga git-push-hook", () => {
65
test("check for same SHAs", async () => {

tests/fixtures/rulesetsMock.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export function getRulesetsWithRulesMock(rulesets) {
2+
return mockedRulesets.filter((ruleset) => rulesets.includes(ruleset.name));
3+
}
4+
5+
export const mockedRulesets = [
6+
{
7+
id: 1,
8+
name: "testing-ruleset-1",
9+
rules: [
10+
{
11+
id: 11,
12+
name: "testing-rule-11",
13+
content: "ZnVuY3Rpb24gdmlzaXQobm9kZSl7CiAgaWYoIW5vZGUpIHJldHVybiAKfQ==",
14+
ruleType: "Ast",
15+
language: "Javascript",
16+
pattern: null,
17+
elementChecked: "HtmlElement",
18+
},
19+
],
20+
},
21+
{
22+
id: 2,
23+
name: "testing-ruleset-2",
24+
rules: [
25+
{
26+
id: 12,
27+
name: "testing-rule-22",
28+
content: "ZnVuY3Rpb24gdmlzaXQobm9kZSl7CiAgaWYoIW5vZGUpIHJldHVybiAKfQ==",
29+
ruleType: "Ast",
30+
language: "Javascript",
31+
pattern: null,
32+
elementChecked: "Assignment",
33+
},
34+
],
35+
},
36+
{
37+
id: 3,
38+
name: "testing-ruleset-3",
39+
rules: [],
40+
},
41+
];

tests/language-support.test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {
2+
LANGUAGE_JAVASCRIPT,
3+
LANGUAGE_PYTHON,
4+
LANGUAGE_TYPESCRIPT,
5+
} from "../utils/constants";
6+
import { managePathsBySupportAndLanguage } from "../utils/rosie";
7+
8+
const notSupportedPaths = [
9+
"config.json",
10+
"README.md",
11+
"LICENSE",
12+
"index.html",
13+
"picture.png",
14+
];
15+
16+
const pythonPaths = [
17+
"index.py3",
18+
"/python.py3",
19+
"/some-folder/nested/index.py",
20+
];
21+
22+
const javascriptPaths = [
23+
"index.js",
24+
"/javascript.jsx",
25+
"/some-folder/nested/index.js",
26+
];
27+
28+
const typescriptPaths = [
29+
"index.ts",
30+
"/typescript.tsx",
31+
"/some-folder/nested/index.ts",
32+
];
33+
34+
test("path files are split correctly", async () => {
35+
const files = managePathsBySupportAndLanguage([
36+
...notSupportedPaths,
37+
...pythonPaths,
38+
...javascriptPaths,
39+
...typescriptPaths,
40+
]);
41+
42+
expect(files.notSupported.length).toBe(5);
43+
expect(files[LANGUAGE_PYTHON].length).toBe(3);
44+
expect(files[LANGUAGE_JAVASCRIPT].length).toBe(3);
45+
expect(files[LANGUAGE_TYPESCRIPT].length).toBe(3);
46+
});

0 commit comments

Comments
 (0)