Skip to content

Commit 06c2d7b

Browse files
authored
update docs, add info about speculative branch execution, add info… (#9)
update docs, add info about speculative branch execution, add info ab…
2 parents b680bd0 + 3c3cb4e commit 06c2d7b

8 files changed

+68
-23
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Expect more docs soon...
3434
1. Testing checks
3535
1. [How to build X?](how-to-build-X.md)
3636
1. [Client API reference](client-api.md)
37-
1. [Localmode](localmode.md)
37+
1. [Local mode](local-mode.md)
38+
1. [Supported CI providers](supported-ci.md)
3839
1. [Debugging](debugging.md)
3940
1. [Badges](badges.md)
4041
1. [FAQ](faq.md)

configuration.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ checks:
1818
files:
1919
- path: "./dist/**/*.d.ts"
2020
- path: "./dist/**/*.js"
21+
settings:
22+
branches:
23+
- dev
24+
- master
2125
```
2226
2327
This is a preferable way of defining checks (plugins). It's fully declarative and using yml make it
@@ -26,6 +30,32 @@ very readable. It works only with external checks ie. checks that part of your p
2630
Resolution engine for check's names will first try to find: `@codechecks/NAME` and then NAME in node
2731
modules and pass options.
2832

33+
### Settings
34+
35+
Client will always try to load settings from `codechecks.yml/json` file
36+
37+
#### Speculative branch execution
38+
39+
This is a feature useful for CI systems that are not triggered by PR creation but rather commit
40+
push.
41+
42+
Imagine a situation you create a new branch and push some changes. You are happy with these changes
43+
so you create a PR. Most of CI providers by this time already run whole CI pipeline for pushed
44+
commit — CI was triggered by pushing new commit. That's why when codechecks ran we didn't know
45+
anything about PR because it didn't exist then. That's why we will try to "guess" base branch for
46+
you. This is currently useful only with Circle CI.
47+
48+
You can switch off this behaviour by specifying `speculativeBranchSelection: false` in yml.
49+
50+
By default we will always try to point speculative PRs to `master` branch. If you use more
51+
complicated branching model you can specify them as following:
52+
53+
```yml
54+
branches:
55+
- dev
56+
- master
57+
```
58+
2959
## codechecks.json
3060

3161
<!-- prettier-ignore -->

getting-started.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
Codechecks is a open source platform for code review automation. It allows to create reusable
44
plugins (aka. "codechecks") that can track any metric of your code (like build-size, or test
5-
coverage) and it integrates directly with GitHub PR flow. A `codecheck` be even more complicated and
6-
perform for example visual regression between screenshots of the frontend app.
5+
coverage) and it integrates directly with GitHub PR flow. A `codecheck` can be even more complicated
6+
and perform for example visual regression between screenshots of the frontend app.
77

88
If you want to use already created codecheck, you need to install our GitHub app, setup CI secret,
99
drop `codechecks.yml` file into your repository and you're done!
@@ -18,7 +18,8 @@ with CC.
1818
1. Log into our [web application](https://app.codechecks.io/) using Github.
1919
2. Click "Add new project" button
2020
3. You will be redirected back into Github interface where you need to select appropriate
21-
repositories.
21+
repositories. Note: support for private repositories is in closed beta. Please send as an email
22+
to [[email protected]](mailto:[email protected]) to enable them.
2223
4. Once done you should be able to see all repositories within our app (if not please refresh). Note
2324
that in the right top corner you can switch between orgs.
2425
5. Copy secret using "copy" button and paste it as secret environment inside your CI interface:
@@ -27,7 +28,7 @@ with CC.
2728
CC_SECRET=COPIED SECRET
2829
```
2930

30-
For now only CircleCI is supported.
31+
[List of supported CI providers](./supported-ci.md)
3132

3233
In this mini tutorial we assume that you develop frontend app so we want to watch how build size is
3334
changing between PRs. Already existing codecheck does exactly this:
@@ -66,11 +67,11 @@ We can dry run our config locally. Just type `yarn codechecks`. You should see s
6667

6768
Notice that each status of the file is "new" because this is the very first time we run codechecks.
6869

69-
We are almost done, last thing is to actually run codechecks as part of your CI pipeline. So far we
70-
support only CircleCI (travis support is coming soon). Important bit here is that you need to build
71-
app before running codechecks (so we can measure it's size). You can see sample here:
70+
We are almost done, last thing is to actually run codechecks as part of your CI pipeline. Important
71+
bit here is that you need to build app before running codechecks (so we can measure it's size). You
72+
can see sample here:
7273
https://github.com/OasisDEX/eth2dai/blob/4bc1606dfbe0f002261b24fefc0a5c47c0cd950c/.circleci/config.yml#L72
73-
To run codechecks simple do `yarn codechecks`.
74+
To run codechecks simple do `npx codechecks` or `yarn codechecks`.
7475

7576
Make sure that you added `CC_SECRET` environment variable to your CI secrets. That's it! Push your
7677
changes, create PR and see how we measure build size. Remember, this is one of the simplest

how-does-it-work.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ Another important task of API is communication with Github. Codechecks require i
1818
on repos that you're interested in. This allows us to provide feedback information using GitHub
1919
Checks API. Support for other services like BitBucket and GitLab is coming soon.
2020

21-
### JS Client aka @codechecks/client
21+
### JS Client aka `@codechecks/client`
2222

2323
Client (currently written in TypeScript) allows for easy communication with API. It provides
2424
execution context for plugins by parsing environment variables, getting more information about the
25-
project from API etc. In future there maybe another implementation, written in something other than
25+
project from API etc. In future there maybe another implementation, written in other language than
2626
TypeScript but it's out of scope for now and we threat JS client as the only official
2727
implementation.
2828

2929
### Particular checks ex. @codechecks/build-size-watcher
3030

31-
JS client enables to write reusable "plugins" (we call them codechecks) in JS and distribute them
32-
directly as NPM packages.
31+
JS client enables to write reusable "plugins" (we call them simply codechecks) in JS and distribute
32+
them directly as NPM packages.

how-to-build-X.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ In this section we will provide high level overview how to build useful stuff us
66

77
1. Measure size of files that you're interested in (just grab some lib from NPM or use `fs.stat` ).
88
We treat that value as an artifact.
9-
1. Save value to Storage API for **current** commit.
10-
1. Get previously saved value for **base** branch from Storage API.
9+
1. Save value to Storage API for **current** commit - `saveValue` method.
10+
1. Get previously saved value for **base** branch from Storage API - `getValue` method.
1111
1. Compare these values to get information how build size changed.
12-
1. Use our Report API to report back to github result of comparison.
12+
1. Use our Report API to report back to github result of comparison - `report` method.
1313

1414
This is a literally description of what
1515
[@codechcecks/build-size-watcher](https://github.com/codechecks/build-size-watcher) does.
@@ -18,12 +18,16 @@ This is a literally description of what
1818

1919
1. Obtain screenshots of the current state of the app. Use one of many libraries to make screenshots
2020
of storybook or make screenshots during E2E tests.
21-
1. Save collection of screenshots for **current** commit using Storage API.
22-
1. Retrieve previously saved screenshots for **base** branch from the Storage API.
21+
1. Save directory with screenshots for **current** commit using Storage API — `saveDirectory`
22+
method.
23+
1. Retrieve previously saved screenshots for **base** branch from the Storage API — `getDirectory`
24+
method.
2325
1. Compare screenshots using one of many libraries available on NPM and create HTML report
2426
describing all changes etc.
25-
1. Upload the HTML report as normal artifact — artifacts are browserable by default.
26-
1. Obtain the URL to the uploaded HTML report and attach it to Github PR by using Report API.
27+
1. Upload the HTML report as normal artifact — artifacts are browserable by default —
28+
`saveDirectory` method.
29+
1. Obtain the URL to the uploaded HTML report and attach it to Github PR by using Report API —
30+
`getArtifactLink` method.
2731

2832
Using similar logic you can implement code coverage tracking, performance tracking and basically
2933
whatever you want.
File renamed without changes.

roadmap.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ Not in any particular order.
55
- [x] Forks supports
66
- [x] Offline mode
77
- [x] Webapp for displaying secrets
8-
- [x] Private repos support (in closed beta)
9-
- [ ] Speculative base branch selection when PR doesnt exist yet
10-
- [ ] Awesome Codechecks repo
8+
- [x] Private repos support (in closed beta send email to
9+
10+
- [x] Speculative base branch selection when PR doesnt exist yet
11+
- [x] Travis CI support
12+
- [ ] Awesome Codechecks list
1113
- [ ] Codechecks ideas:
1214
- [ ] Visual Regression codecheck
1315
- [ ] Test coverage like codecov codecheck

supported-ci.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Supported CI providers
2+
3+
- Circle CI
4+
- Travis CI
5+
6+
Is your favorite CI provider missing? Just create an issue
7+
[here](https://github.com/codechecks/monorepo).

0 commit comments

Comments
 (0)