Skip to content

Commit b11d9f0

Browse files
committed
feat: add codecov workflow
1 parent 6d654e0 commit b11d9f0

File tree

8 files changed

+57
-8
lines changed

8 files changed

+57
-8
lines changed

.github/workflows/codecov.yml

-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ jobs:
2020
run: npm run test:coverage
2121
- name: Upload coverage to Codecov
2222
uses: codecov/codecov-action@v2
23-
with:
24-
token: ${{ secrets.CODECOV_TOKEN }}

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"cSpell.words": ["camelize", "kebablize", "kebablized"]
2+
"cSpell.words": ["camelize", "codecov", "codeql", "kebablize", "kebablized"]
33
}

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ npx @allohamora/cli
3636
- [**release-workflow**](/src/categories/js/release-worflow) is script to initialize github release workflow what creates release from [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) CHANGELOG.md when you push tag like \*.\*.\*(1.1.0, 5.0.0, 0.0.0, etc).
3737
- [**standard-version**](/src/categories/js/standard-verstion) is a script to initialize [standard-version](https://github.com/conventional-changelog/standard-version) with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) config(with repository url if defined or "\<repository url\>" placeholder), custom options(like removed "v" tag prefix) and release scripts.
3838
- [**jest**](/src/categories/js/jest) is a script to initialize [jest](https://github.com/facebook/jest) with config and test scripts.
39+
- [**docker**](src/categories/js/docker/) is a script to initialize [docker](https://github.com/docker) with Dockerfile and .dockerignore files
3940
- [**test-workflow**](/src/categories/js/test-workflow.ts) is a script to initialize github test workflow what runs `npm run test` on each push to github.
4041
- [**build-workflow**](/src/categories/js/build-workflow) is a script to initialize github build workflow that runs `npm run build` on each push to github.
4142
- [**codeql-workflow**](/src/categories/js/codeql-workflow) is a script to initialize github codeql workflow what runs codeql with default options on each push to github.
43+
- [**codecov-workflow**](/src/categories/js/codecov-workflow/) is a script to initialize codecov workflow that collects code coverage and send it to codecov. Requires codecov token that contains in github actions secret with name: `CODECOV_TOKEN`
4244
- [**dependabot**](src/categories/js/dependabot/) is a script to initialize github dependabot what manages project dependencies vulnerabilities and opens pull requests with fixes.
43-
- [**docker**](src/categories/js/docker/) is a script to initialize [docker](https://github.com/docker) with Dockerfile and .dockerignore files
4445

4546
\*integrations runs only if package is installing or installed.
4647

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { jsCategoryState } from 'src/states/categories';
2+
import { defaultConfig } from './config/default.config';
3+
4+
export const [getConfig] = jsCategoryState.useConfigState({
5+
default: defaultConfig,
6+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const WORKFLOW_FILENAME = 'codeql.yml';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { addGithubWorkflow } from 'src/utils/github';
2+
import { getConfig } from './codecov-workflow.config';
3+
import { WORKFLOW_FILENAME } from './codecov-workflow.const';
4+
5+
export const codecovWorkflow = async () => {
6+
const { content } = getConfig();
7+
8+
await addGithubWorkflow(WORKFLOW_FILENAME, content);
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { readableMultilineString } from 'src/utils/string';
2+
3+
const content = readableMultilineString`
4+
name: codecov
5+
6+
on: [push]
7+
8+
jobs:
9+
codecov:
10+
runs-on: ubuntu-latest
11+
env:
12+
CI: true
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
- name: Install node
17+
uses: actions/setup-node@v2
18+
with:
19+
cache: "npm"
20+
- name: Install dependencies
21+
run: npm i
22+
- name: Collect coverage
23+
run: npm run test:coverage
24+
- name: Upload coverage to Codecov
25+
uses: codecov/codecov-action@v2
26+
with:
27+
token: \${{ secrets.CODECOV_TOKEN }}
28+
`;
29+
30+
export const defaultConfig = {
31+
content,
32+
};

src/categories/js/index.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import { lintStaged } from './lint-staged/lint-staged.entrypoint';
66
import { stylelint } from './stylelint/stylelint.entrypoint';
77
import { prettier } from './prettier/prettier.entrypoint';
88
import { standardVersion } from './standard-version/standard-version.entrypoint';
9-
import { releaseWorkflow } from './release-workflow/release-workflow.entrypoint';
109
import { jestEntrypoint } from './jest/jest.entrypoint';
10+
import { docker } from './docker/docker.entrypoint';
11+
import { releaseWorkflow } from './release-workflow/release-workflow.entrypoint';
1112
import { testWorkflow } from './test-workflow/test-workflow.entrypoint';
1213
import { codeqlWorkflow } from './codeql-workflow/codeql-workflow.entrypoint';
1314
import { buildWorkflow } from './build-workflow/build-workflow.entrypoint';
15+
import { codecovWorkflow } from './codecov-workflow/codecov-workflow.entrypoint';
1416
import { dependabot } from './dependabot/dependabot.entrypoint';
15-
import { docker } from './docker/docker.entrypoint';
1617

1718
// order have matter
1819
const options = {
@@ -23,14 +24,15 @@ const options = {
2324
eslint,
2425
lintStaged,
2526
stylelint,
26-
releaseWorkflow,
2727
// named jestEntrypoint because in test environment jest name is reserved
2828
jest: jestEntrypoint,
29+
docker,
30+
releaseWorkflow,
2931
testWorkflow,
3032
codeqlWorkflow,
3133
buildWorkflow,
34+
codecovWorkflow,
3235
dependabot,
33-
docker,
3436
};
3537

3638
export default {

0 commit comments

Comments
 (0)