Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests #98

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
31 changes: 29 additions & 2 deletions .github/workflows/cdm-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,37 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "20.7.0"
- name: fail if javascript files are not formatted
node-version: "18"

- name: enforce javascript style standard
run: npx prettier **/*.js --check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: code coverage
uses: ArtiomTr/jest-coverage-report-action@v2
id: coverage
with:
output: report-markdown
working-directory: queries

# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: 3.9

# - name: install html to markdown converter
# run: pip install html2text

# - name: check unit tests
# run: npm test --prefix=queries --coverageDirectory=coverage

# - name: convert test coverage to markdown
# run: html2text --ignore-image --ignore-links -b 0 queries/coverage/lcov-report/index.html >> $GITHUB_STEP_SUMMARY

# - name: upload coverage html artifact
# uses: actions/upload-artifact@v3
# with:
# name: coverage
# path: queries/coverage
# if-no-files-found: error
21 changes: 0 additions & 21 deletions .github/workflows/crucible-ci.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/faux-crucible-ci.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vscode
coverage/
2 changes: 2 additions & 0 deletions queries/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
coverage/
File renamed without changes.
83 changes: 83 additions & 0 deletions queries/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Contributing

When contributing, apply this project's JavaScript standard style, otherwise it will fail in CI.

## Requirements

- Node 18.18.0
- NPM
- ElasticSearch 7.17

## Standardizing JavaScript Style

1. Clone this repository.

```shell
$ git clone https://github.com/perftool-incubator/CommonDataModel.git
```

2. Change your current working directory to the CDMQ directory.

```shell
$ cd CommonDataModel
```

3. Install this project's Node JS dependencies.

```shell
$ npm install --prefix queries
```

4. Check current code style if changes are required with [prettier](https://prettier.io/docs/en/cli.html) using [npx](https://docs.npmjs.com/cli/v7/commands/npx).

```shell
$ npx prettier --check "queries/**/*.js"
```

5. Apply code style changes.

```shell
$ npx prettier --write "queries/**/*.js"
```

## Unit Tests

1. Verify Node 18

```shell
$ node -v
v18.18.0
```

2. Install this project's Node JS dependencies.

```shell
$ npm install --prefix queries
```

3. Execute all JavaScript unit test files with code coverage.

```shell
$ npm test --prefix queries

> [email protected] test
> jest

PASS test/cdm.test.js
set(ish)-array behavior
✓ set(ish) difference (subtractTwoArrays) (6 ms)
✓ set(ish) intersection (intersectTwoArrays) (1 ms)
✓ intersect all arrays (1 ms)

----------|---------|----------|---------|---------|-------------------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------------------------------
All files | 10.63 | 100 | 4.61 | 10.63 |
cdm.js | 10.63 | 100 | 4.61 | 10.63 | ...720-1729,1744-2022,2026-2041,2057-2180
----------|---------|----------|---------|---------|-------------------------------------------
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 0.703 s, estimated 1 s
Ran all test suites.
```
File renamed without changes.
41 changes: 0 additions & 41 deletions queries/cdmq/CONTRIBUTING.md

This file was deleted.

Loading