Skip to content

Commit 091ac3f

Browse files
committed
docs on adding new ci provider
1 parent 06c2d7b commit 091ac3f

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Expect more docs soon...
3636
1. [Client API reference](client-api.md)
3737
1. [Local mode](local-mode.md)
3838
1. [Supported CI providers](supported-ci.md)
39+
1. [Adding new CI](adding-new-ci.md)
3940
1. [Debugging](debugging.md)
4041
1. [Badges](badges.md)
4142
1. [FAQ](faq.md)

adding-new-ci.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Adding new CI
2+
3+
This is a mini-guide on adding new CI provider to
4+
[JavaScript client](https://github.com/codechecks/monorepo).
5+
6+
1. Create new file in `packages/client/src/ci-providers`. You can copy `Circle.ts` and use it as
7+
scaffolding.
8+
2. If your CI creates explicit CI run on PR creation then set `supportsSpeculativeBranchSelection`
9+
to false. Otherwise return true. For example: CircleCI always runs your code on push. That's why
10+
we sometimes need to "guess" base branch (only before PR is really created by the user).
11+
[Read more](https://github.com/codechecks/docs/blob/master/configuration.md#speculative-branch-execution)
12+
13+
3. Implement rest of the class
14+
4. Don't forget to add tests. Currently we test new CI providers by adding raw environment dump (you
15+
can use `printenv`) and asserting correct data.
16+
[Example](https://github.com/codechecks/monorepo/blob/master/packages/client/src/ci-providers/__tests__/Circle.test.ts)

developing-checks.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ In this tutorial we are gonna build simplified version of
55
watch size of a single file and doesn't support gzip. We are gonna use yarn in this tutorial but you
66
can pick npm as well. Lets' start!
77

8+
## Scaffolding
9+
810
We want our check to be fully reusable so we are gonna create new npm package just for it.
911

1012
```sh
1113
mkdir simple-build-size-watcher
1214
cd simple-build-size-watcher
15+
# creates package.json
1316
yarn init -y
1417
```
1518

@@ -19,17 +22,24 @@ Let's install codechecks client.
1922
yarn add --dev @codechecks/client
2023
```
2124

22-
Let's start developing index.js file. Our check is just a function that takes a path to a file that
23-
we want to observe and it a default export of a module.
25+
Let's start developing `index.js` file. Our check is just a function that takes options object, in
26+
this example it's a path to a file that we want to observe. The function is a default export of a
27+
module.
2428

2529
```js
2630
const { codechecks } = require("@codechecks/client");
2731

28-
module.exports = function(path) {
29-
// it's alive!
32+
module.exports = function({ path }) {
33+
// just print out the path
34+
codechecks.success({ name: "Simple build size", shortDescription: path });
3035
};
3136
```
3237

38+
At this point we have already something very simple that should work. To test it we need to create a
39+
`codechecks.yml` file that actually uses this file.
40+
41+
## Getting real
42+
3343
Lets calculate size of a file pointed by a path. After quick visit at stackoverflow we can come up
3444
with a function getSize:
3545

@@ -105,7 +115,7 @@ function getSize(path) {
105115

106116
That's it. Whole code is placed in `/example` directory of this repo.
107117

108-
## Testing
118+
# Testing
109119

110120
Because codechecks client is an external dependency that is supposed to be imported by your modules
111121
this makes testing a little bit harder. We recommend to use jest mocking super powers. Tests for
@@ -114,7 +124,7 @@ this project are part of `/example` dir.
114124
You can find more complicated example here:
115125
https://github.com/codechecks/build-size-watcher/tree/master/src/__tests__
116126

117-
## Debugging
127+
# Debugging
118128

119129
For compatibility with codechecks client, to provide debug logs use `debug` package with
120130
`codechecks:YOUR_CHECK_NAME` namespace.

roadmap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Not in any particular order.
99
1010
- [x] Speculative base branch selection when PR doesnt exist yet
1111
- [x] Travis CI support
12-
- [ ] Awesome Codechecks list
12+
- [x] Awesome Codechecks list
1313
- [ ] Codechecks ideas:
14-
- [ ] Visual Regression codecheck
14+
- [x] Visual Regression codecheck
1515
- [ ] Test coverage like codecov codecheck

supported-ci.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
- Travis CI
55

66
Is your favorite CI provider missing? Just create an issue
7-
[here](https://github.com/codechecks/monorepo).
7+
[here](https://github.com/codechecks/monorepo). You can implement it on your own, read this
8+
[quick guide](adding-new-ci.md)

0 commit comments

Comments
 (0)