Skip to content

Commit ec9a786

Browse files
authored
chore: initial QA (#16)
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent f160c4b commit ec9a786

File tree

17 files changed

+2622
-411
lines changed

17 files changed

+2622
-411
lines changed

.codacy.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Config for Codacy
2+
# See https://docs.codacy.com/repositories-configure/codacy-configuration-file/
3+
---
4+
engines:
5+
# engine `eslint-8` shall be disabled, since it fails due to incapability to load custom/own plugins
6+
# this engine is run via CI/CT anyway...
7+
exclude_paths:
8+
# ignore all non-shipped files
9+
- "docs/dev/**"
10+
- "examples/**"
11+
## tests
12+
- "tests/**"
13+
- "**/*.test.*"
14+
- "**/*.spec.*"
15+
## dot-files & dot-folders
16+
- ".*"
17+
- ".*/**"

.eslintignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# yarn stuff
2+
/.yarn/**
3+
/.pnp.cjs
4+
/.pnp.loader.mjs
5+
6+
# generated files: dist and docs
7+
/reports/**
8+
/bundles/**
9+
/docs/**
10+
11+
12+
!/sources/**

.eslintrc.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*!
2+
This file is part of CycloneDX SBOM plugin for yarn.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache-2.0
17+
Copyright (c) OWASP Foundation. All Rights Reserved.
18+
*/
19+
20+
/* eslint-disable jsdoc/valid-types */
21+
22+
/**
23+
* @type {import('eslint').Linter.Config}
24+
* @see https://eslint.org/
25+
*/
26+
module.exports = {
27+
root: true,
28+
plugins: [
29+
/* see https://github.com/lydell/eslint-plugin-simple-import-sort#readme */
30+
'simple-import-sort',
31+
/* see https://github.com/Stuk/eslint-plugin-header#readme */
32+
'header'
33+
],
34+
env: {
35+
commonjs: true,
36+
node: true
37+
},
38+
rules: {
39+
// region sort imports/exports
40+
/** disable other sorters in favour of `simple-import-sort` */
41+
'import/order': 0,
42+
'sort-imports': 0,
43+
/** @see https://github.com/lydell/eslint-plugin-simple-import-sort/ */
44+
'simple-import-sort/imports': 'error',
45+
'simple-import-sort/exports': 'error',
46+
// endregion sort imports/exports
47+
// region license-header
48+
/* see https://github.com/Stuk/eslint-plugin-header#readme */
49+
'header/header': ['error', '.license-header.js']
50+
// endregion license-header
51+
},
52+
overrides: [
53+
{
54+
files: ['*.spec.*', '*.test.*'],
55+
env: {
56+
mocha: true,
57+
commonjs: true,
58+
node: true
59+
}
60+
},
61+
{
62+
files: ['*.ts'],
63+
extends: [
64+
/** @see https://github.com/standard/ts-standard */
65+
'standard-with-typescript'
66+
],
67+
parserOptions: {
68+
project: './tsconfig.json'
69+
},
70+
rules: {
71+
/* @see https://typescript-eslint.io/rules/unbound-method/ */
72+
'@typescript-eslint/unbound-method': ['error', {
73+
ignoreStatic: true
74+
}]
75+
}
76+
},
77+
{
78+
files: ['*.js', '*.mjs', '*.cjs'],
79+
extends: [
80+
/* see https://www.npmjs.com/package/eslint-config-standard */
81+
'standard',
82+
/* see https://github.com/gajus/eslint-plugin-jsdoc */
83+
'plugin:jsdoc/recommended'
84+
],
85+
plugins: [
86+
/* see https://github.com/gajus/eslint-plugin-jsdoc/ */
87+
'jsdoc'
88+
],
89+
rules: {
90+
/* see https://github.com/gajus/eslint-plugin-jsdoc */
91+
'jsdoc/no-undefined-types': 'error',
92+
'jsdoc/check-tag-names': 0,
93+
'jsdoc/check-types': 'error',
94+
'jsdoc/require-hyphen-before-param-description': ['error', 'always'],
95+
'jsdoc/require-jsdoc': 0,
96+
'jsdoc/require-param': 0,
97+
'jsdoc/require-param-description': 0,
98+
'jsdoc/require-param-name': 'error',
99+
'jsdoc/require-param-type': 'error',
100+
'jsdoc/require-property': 0,
101+
'jsdoc/require-property-description': 0,
102+
'jsdoc/require-property-name': 'error',
103+
'jsdoc/require-property-type': 'error',
104+
'jsdoc/require-returns': 0,
105+
'jsdoc/require-returns-check': 'error',
106+
'jsdoc/require-returns-description': 0,
107+
'jsdoc/require-returns-type': 'error',
108+
'jsdoc/require-throws': 'error',
109+
'jsdoc/require-yields': 0,
110+
'jsdoc/require-yields-check': 'error',
111+
'jsdoc/sort-tags': 'warn'
112+
// region docs
113+
},
114+
settings: {
115+
jsdoc: {
116+
/* see https://github.com/gajus/eslint-plugin-jsdoc */
117+
mode: 'jsdoc'
118+
}
119+
}
120+
}
121+
]
122+
}

.github/workflows/test.yml renamed to .github/workflows/nodejs.yml

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# For details of what checks are run for PRs please refer below
22
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
33

4-
name: CI/CT
4+
name: Node CI
55

66
on:
77
push:
@@ -23,6 +23,7 @@ env:
2323
DIST_DIR: bundles
2424
REPORTS_DIR: "CI_reports"
2525
TESTS_REPORTS_ARTIFACT: tests-reports
26+
STANDARD_REPORTS_ARTIFACT: cs-reports
2627

2728
jobs:
2829
build:
@@ -46,7 +47,9 @@ jobs:
4647
- name: Setup subject
4748
run: yarn install --immutable
4849
- name: build
49-
run: yarn build --source-map
50+
run: yarn run build:gbtd
51+
- name: build
52+
run: yarn run build:bundle-dev
5053
- name: artifact build result
5154
# see https://github.com/actions/upload-artifact
5255
uses: actions/upload-artifact@v3
@@ -55,12 +58,78 @@ jobs:
5558
path: ${{ env.DIST_DIR }}
5659
if-no-files-found: error
5760

58-
# test-standards:
59-
# # TODO
61+
test-standard:
62+
name: test standard
63+
runs-on: ubuntu-latest
64+
timeout-minutes: 10
65+
steps:
66+
- name: Checkout
67+
# see https://github.com/actions/checkout
68+
uses: actions/checkout@v4
69+
- run: mkdir -p ${{ env.REPORTS_DIR }}
70+
- name: Setup Node.js ${{ matrix.node-version }}
71+
# see https://github.com/actions/setup-node
72+
uses: actions/setup-node@v4
73+
with:
74+
node-version: ${{ env.NODE_ACTIVE_LTS }}
75+
# cache: 'yarn'
76+
- name: Setup yarn ${{ env.YARN_VERSION }}
77+
run: |
78+
corepack enable yarn
79+
yarn set version ${{ env.YARN_VERSION }}
80+
- name: Setup subject
81+
run: yarn install --immutable
82+
- name: build
83+
run: yarn run build:gbtd
84+
- name: test
85+
run: >
86+
yarn run test:standard
87+
--format checkstyle
88+
--output-file "$REPORTS_DIR/eslint.xml"
89+
- name: Publish Checkstyle report
90+
# see https://github.com/Juuxel/publish-checkstyle-report
91+
uses: Juuxel/publish-checkstyle-report@v1
92+
if: ${{ failure() || success() }}
93+
with:
94+
reports: ${{ env.REPORTS_DIR }}/eslint.xml
95+
- name: artifact build result
96+
# see https://github.com/actions/upload-artifact
97+
uses: actions/upload-artifact@v3
98+
if: ${{ failure() }}
99+
with:
100+
name: ${{ env.STANDARD_REPORTS_ARTIFACT }}
101+
path: ${{ env.REPORTS_DIR }}
102+
if-no-files-found: error
103+
104+
test-lint:
105+
name: test standard
106+
runs-on: ubuntu-latest
107+
timeout-minutes: 10
108+
steps:
109+
- name: Checkout
110+
# see https://github.com/actions/checkout
111+
uses: actions/checkout@v4
112+
- run: mkdir -p ${{ env.REPORTS_DIR }}
113+
- name: Setup Node.js ${{ matrix.node-version }}
114+
# see https://github.com/actions/setup-node
115+
uses: actions/setup-node@v4
116+
with:
117+
node-version: ${{ env.NODE_ACTIVE_LTS }}
118+
# cache: 'yarn'
119+
- name: Setup yarn ${{ env.YARN_VERSION }}
120+
run: |
121+
corepack enable yarn
122+
yarn set version ${{ env.YARN_VERSION }}
123+
- name: Setup subject
124+
run: yarn install --immutable
125+
- name: build
126+
run: yarn run build:gbtd
127+
- name: test
128+
run: yarn run test:lint
60129

61130
test-node:
62131
needs: [ 'build' ]
63-
name: jest (node${{ matrix.node-version }} ${{ matrix.os }})
132+
name: test (node${{ matrix.node-version }} ${{ matrix.os }})
64133
runs-on: ${{ matrix.os }}
65134
strategy:
66135
fail-fast: false
@@ -93,19 +162,19 @@ jobs:
93162
- name: Setup subject
94163
run: yarn install --immutable
95164
- name: setup-tests
96-
run: yarn setup-tests
165+
run: yarn run setup-tests
97166
- name: fetch build artifact
98167
# see https://github.com/actions/download-artifact
99168
uses: actions/download-artifact@v3
100169
with:
101170
name: ${{ env.DIST_DIR }}
102171
path: ${{ env.DIST_DIR }}
103172
- name: run tests
104-
run: yarn test
173+
run: yarn run test:node
105174
- name: collect coverage
106175
if: ${{ failure() || success() }}
107176
run: >
108-
yarn c8 report
177+
yarn exec c8 report
109178
--reporter clover
110179
--reports-dir '${{ env.REPORTS_DIR }}/coverage/${{ matrix.os }}_node${{ matrix.node-version }}'
111180
- name: artifact test reports
@@ -155,7 +224,7 @@ jobs:
155224
path: ${{ env.DIST_DIR }}
156225
- name: dogfooding
157226
run: >
158-
yarn dogfooding
227+
yarn run dogfooding
159228
--production
160229
--output-file=${{ env.REPORTS_DIR }}/bom.json
161230
- name: artifact test reports

.gitignore

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1+
/.*.cache
2+
3+
/reports/
4+
/CI_reports/
5+
/bundles/
6+
/CI_bundles/
7+
8+
9+
110
# yarn stuff - for now, until setup is hardened
211
# see also: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
312
/.pnp.*
413
/.yarn/
514
/.yarnrc.yml
615

716

8-
# No bundles for now untils release process is clarified.
9-
/bundles/
10-
11-
1217
# Only used during production build.
1318
/sources/buildtime-dependencies.json
1419

1520

16-
/.*.cache
17-
1821
# Everything below here is from https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
1922
# Logs
2023
logs

CONTRIBUTING.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ Then add SDKs for you preferred editor as described on https://yarnpkg.com/getti
2020
Build bundle
2121

2222
```shell
23-
yarn build # options: --source-map --no-minify
23+
yarn run build
2424
```
2525

2626
## Testing
2727

2828
Set up the tests once, via:
2929

3030
```shell
31-
yarn setup-tests
31+
yarn run setup-tests
32+
```
33+
34+
Build with source-map for testing:
35+
36+
```shell
37+
yarn run build:bundle-dev
3238
```
3339

3440
Run to have a proper test suite pass:
@@ -42,7 +48,7 @@ yarn test
4248
Apply the coding style via:
4349

4450
```shell
45-
# .. TODO
51+
yarn run cs-fix
4652
```
4753

4854
## Sign off your commits

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CycloneDX JavaScript Library
1+
CycloneDX SBOM plugin for yarn
22
Copyright (c) OWASP Foundation. All Rights Reserved.
33

44
This product includes software developed by the

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Software-Bill-of-Materials(SBOM) in CycloneDX format.
8787
[yarn]: https://yarnpkg.com/
8888
[cyclonedx-library]: https://www.npmjs.com/package/@cyclonedx/cyclonedx-library
8989

90-
[shield_gh-workflow-test]: https://img.shields.io/github/actions/workflow/status/CycloneDX/cyclonedx-node-yarn/test.yml?branch=1.0-dev&logo=GitHub&logoColor=white "tests"
90+
[shield_gh-workflow-test]: https://img.shields.io/github/actions/workflow/status/CycloneDX/cyclonedx-node-yarn/nodejs.yml?branch=1.0-dev&logo=GitHub&logoColor=white "tests"
9191
[shield_coverage]: https://img.shields.io/codacy/coverage/b0af77db5c7b4ab7a36eab255c7f9ede?logo=Codacy&logoColor=white "test coverage"
9292
[shield_license]: https://img.shields.io/github/license/CycloneDX/cyclonedx-node-yarn?logo=open%20source%20initiative&logoColor=white "license"
9393
[shield_website]: https://img.shields.io/badge/https://-cyclonedx.org-blue.svg "homepage"
@@ -96,7 +96,7 @@ Software-Bill-of-Materials(SBOM) in CycloneDX format.
9696
[shield_twitter-follow]: https://img.shields.io/badge/Twitter-follow-blue?logo=Twitter&logoColor=white "twitter follow"
9797

9898
[link_website]: https://cyclonedx.org/
99-
[link_gh-workflow-test]: https://github.com/CycloneDX/cyclonedx-node-yarn/actions/workflows/test.yml?query=branch%3Amain
99+
[link_gh-workflow-test]: https://github.com/CycloneDX/cyclonedx-node-yarn/actions/workflows/nodejs.yml?query=branch%3A1.0-dev
100100
[link_codacy]: https://app.codacy.com/gh/CycloneDX/cyclonedx-node-yarn/dashboard
101101
[link_slack]: https://cyclonedx.org/slack/invite
102102
[link_discussion]: https://groups.io/g/CycloneDX

0 commit comments

Comments
 (0)