Skip to content

Commit

Permalink
chore: renames
Browse files Browse the repository at this point in the history
  • Loading branch information
agoldis committed Jul 10, 2024
1 parent 2b25624 commit ee507ac
Show file tree
Hide file tree
Showing 32 changed files with 85 additions and 72 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Currents reporter

A monorepo which contains the following packages:

- `@currents/jest-reporter` - a jest reporter that writes the test results to json files in a Currents friendly manner
- `@currents/reporter-cli` - exposes the `currents-reporter` command which is used to discover the full test suite and upload the test results into Currents Dashboard.
- `@currents/cmd` - exposes the `currents-reporter` command which is used to discover the full test suite and upload the test results into Currents Dashboard.
- `examples` - a private package used to test the implementation

## Testing locally

1. `npm i`

2. `npm run build`

3. (Optional) Link the packages:
Expand All @@ -20,15 +20,15 @@ cd ../jest-reporter &&
npm link &&
cd ../../examples &&
npm link @currents/jest-reporter &&
npm link @currents/reporter-cli &&
npm link @currents/cmd &&
cd ../
```

4. `cd ./examples`

### Creating the report

Run `npm run test` to run example spec files.
Run `npm run test` to run example spec files.

In order to test different scenarious, update the jest configuration by modifying the `jest.config.js` file or run the command with jest cli options.

Expand All @@ -53,4 +53,4 @@ Run `npm run report` or `CURRENTS_API_URL=http://localhost:1234 CURRENTS_PROJECT

To enable the debug mode, prefix the command with `DEBUG=currents,currents:*` or use the `--debug` option.

To provide a custom report dir path, use `CURRENTS_REPORT_DIR` env variable or `--report-dir` option.
To provide a custom report dir path, use `CURRENTS_REPORT_DIR` env variable or `--report-dir` option.
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@babel/preset-env": "^7.24.3",
"@babel/preset-typescript": "^7.24.1",
"@currents/jest-reporter": "*",
"@currents/reporter-cli": "*",
"@currents/cmd": "*",
"@types/jest": "^29.5.12",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
# @currents/reporter-cli
# @currents/cmd

A CLI tool designed to process and upload test results to [Currents](https://currents.dev), a cloud dashboard for debugging, troubleshooting, and analyzing parallel CI tests.
CLI tools for [Currents](https://currents.dev) - a cloud platform for debugging, troubleshooting, and analyzing parallel CI tests.

## Installation

```
$ npm install @currents/reporter-cli --save-dev
```sh
npm install @currents/cmd --save-dev
```

## Usage

Run the CLI command:

```
$ npx currents-reporter --project-id=xxx --key=yyy
```sh
npx currents upload --project-id=xxx --key=yyy
```

The CLI command will:
The command will:

1. Read the configuration.

The report directory is determined from `process.env.CURRENTS_REPORT_DIR`, `--reportDir`, or the most recent directory named using the pattern ".currents-report-[timestamp]-[uuidv4()]" in the current working directory.
The report directory is determined from `process.env.CURRENTS_REPORT_DIR` or `--reportDir`, or the most recently created directory named using the pattern `.currents-report-[timestamp]-[uuidv4()]` in the current working directory.

The report directory contains test results grouped by spec file and the configuration information used to obtain them.

2. Optionally run a full test suite "discovery" process, which will try to find all tests (required for the Currents dashboard).
2. Optionally run a full test suite "discovery" process, which will try to find all tests (required for the Currents platform).

The full test suite includes the tests that should be part of the same run but executed across different machines.

3. Upload the test results to the Currents dashboard.
3. Upload the test results to the Currents

The `--project-id` and [--key](https://docs.currents.dev/guides/record-key) are used to identify the project and associate the results with the organization in the Currents dashboard.

## Configuration

Please note that all options apart from `--project-id` and `--key` are optional.
Please note that all options apart from `--project-id` and `--key` are optional.

| Property | Type | Description | Environment variable | Default |
| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------- | --------------------------------------- |
| `-k, --key` | `STRING` | The record key to be used to record the results on the remote dashboard. Read more: https://currents.dev/readme/guides/record-key | `CURRENTS_RECORD_KEY` | - |
| `-p, --project-id` | `STRING` | The id of the project to record the test run. | `CURRENTS_PROJECT_ID` | - |
| `--machine-id` | `STRING` | Unique identifier of the machine running the tests. If not provided, it will be generated automatically. See: https://currents.dev/readme/readme?q=machineId | `CURRENTS_MACHINE_ID` | `[random-string]` |
| `--report-dir` | `STRING` | The path from where the CLI command will read the Currents report | `CURRENTS_REPORT_DIR` | `.currents-report-[timestamp]-[uuidv4]` |
| `--ci-build-id` | `STRING` | The id of the build to record the test run. Read more: https://currents.dev/readme/guides/ci-build-id | `CURRENTS_CI_BUILD_ID` | `auto:[random-string]` |
| `--debug` | `BOOLEAN` | Enable debug logs | `DEBUG="currents,currents:*"` | `falseu` |
| `-t, --tag` | `STRING` | Comma-separated tag(s) for recorded runs in Currents | `CURRENTS_TAG` | - |
| `--disable-title-tags` | `BOOLEAN` | Disable extracting tags from test title, e.g. `Test name @smoke` would not be tagged with `smoke` | `CURRENTS_DISABLE_TITLE_TAGS` | `false` |
| `--remove-title-tags` | `BOOLEAN` | Remove tags from test names in Currents, e.g. `Test name @smoke` becomes `Test name` in the dashboard | `CURRENTS_REMOVE_TITLE_TAGS` | `false` |
| `-k, --key` | `string` | The record key to be used to record the results on the remote dashboard. Read more: https://currents.dev/readme/guides/record-key | `CURRENTS_RECORD_KEY` | - |
| `-p, --project-id` | `string` | The id of the project to record the test run. | `CURRENTS_PROJECT_ID` | - |
| `--machine-id` | `string` | Unique identifier of the machine running the tests. If not provided, it will be generated automatically. See: https://currents.dev/readme/readme?q=machineId | `CURRENTS_MACHINE_ID` | `[random-string]` |
| `--report-dir` | `string` | The path from where the CLI command will read the Currents report | `CURRENTS_REPORT_DIR` | `.currents-report-[timestamp]-[uuidv4]` |
| `--ci-build-id` | `string` | The id of the build to record the test run. Read more: https://currents.dev/readme/guides/ci-build-id | `CURRENTS_CI_BUILD_ID` | `auto:[random-string]` |
| `--debug` | `boolean` | Enable debug logs | `DEBUG="currents,currents:*"` | `falseu` |
| `-t, --tag` | `string` | Comma-separated tag(s) for recorded runs in Currents | `CURRENTS_TAG` | - |
| `--disable-title-tags` | `boolean` | Disable extracting tags from test title, e.g. `Test name @smoke` would not be tagged with `smoke` | `CURRENTS_DISABLE_TITLE_TAGS` | `false` |
| `--remove-title-tags` | `boolean` | Remove tags from test names in Currents, e.g. `Test name @smoke` becomes `Test name` in the dashboard | `CURRENTS_REMOVE_TITLE_TAGS` | `false` |

The configuration is also available by running the CLI command with the `--help` argument.

**Note:**

The `CI Build ID` and `Machine ID` will be generated automatically if not set. It is **important** to set the `CI Build ID` explicitly when the results from different machines are part of the same test run. Read more - [here](https://currents.dev/readme/guides/ci-build-id).
The `CI Build ID` and `Machine ID` will be generated automatically if not set. It is **important** to set the `CI Build ID` explicitly when the results from different machines are part of the same test run. Read more - [here](https://docs.currents.dev/guides/ci-build-id).

## Troubleshooting

Expand Down
14 changes: 8 additions & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@currents/reporter-cli",
"version": "0.0.0",
"name": "@currents/sdk",
"version": "1.0.0",
"main": "./dist/index.js",
"author": "Currents Software Inc",
"license": "GPL-3.0-or-later",
Expand Down Expand Up @@ -55,18 +55,20 @@
"ts-pattern": "^5.2.0"
},
"bin": {
"currents-reporter": "./dist/bin/index.js"
"currents": "./dist/bin/index.js",
"currents-cli": "./dist/bin/index.js"
},
"files": [
"dist",
"!**/*.map",
"!**/*/*.map"
],
"keywords": [
"cloud dashboard",
"reporter",
"cloud test dashboard",
"test reporter",
"test results",
"currents",
"tests reporter",
"currents dashboard",
"ci"
],
"exports": {
Expand Down
13 changes: 9 additions & 4 deletions packages/cli/src/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
#! /usr/bin/env node

import "source-map-support/register";

import("dotenv/config");

import { CommanderError } from "commander";
import { getCurrentsConfig, setCurrentsConfig } from "../config";
import { debug as _debug } from "../debug";
import { currentsReporter } from "../index";
import { error, info, success } from "../logger";
import { CLIManager } from "./cli-config";

require("dotenv").config();

function runScript() {
const cliManager = new CLIManager();
setCurrentsConfig(cliManager.parsedConfig);
info("Currents config: %o", getCurrentsConfig());
const config = getCurrentsConfig();

info("Currents config: %o", {
...config,
recordKey: config?.recordKey ? "*****" : undefined,
});
return currentsReporter();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/bin/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getEnvironmentVariableName } from "../config";

export const ciBuildIdOption = new Option(
"--ci-build-id <id>",
"the unique identifier for a run"
"the unique identifier for the recorded build (run)"
).env(getEnvironmentVariableName("ciBuildId"));

export const recordKeyOption = new Option(
Expand Down
25 changes: 14 additions & 11 deletions packages/cli/src/bin/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type CurrentsReporterCommand = Partial<
ReturnType<ReturnType<typeof getCurrentsReporterCommand>["opts"]>
>;

const NAME = "currents";
export const getProgram = (
command: Command<[], CurrentsReporterCommand> = getCurrentsReporterCommand()
) => command.version(reporterVersion);
Expand All @@ -31,28 +32,28 @@ const currentsReporterExample = `
${chalk.bold("Examples")}
Upload report to currents dashboard:
${dim("currents-reporter --key <record-key> --project-id <id> --ci-build-id <build-id>")}
Upload test results to Currents:
${dim(`${NAME} upload --key <record-key> --project-id <id> --ci-build-id <build-id>`)}
Upload report to currents dashboard add tags "tagA", "tagB" to the recorded run:
Upload test results to Currents, add tags "tagA", "tagB" to the recorded run:
${dim(
"currents-reporter --key <record-key> --project-id <id> --ci-build-id <build-id> --tag tagA --tag tagB"
`${NAME} upload --key <record-key> --project-id <id> --ci-build-id <build-id> --tag tagA --tag tagB`
)}
Provide a custom path to the report directory:
Provide a custom path to the reports directory:
${dim(
"currents-reporter --key <record-key> --project-id <id> --ci-build-id <build-id> --report-dir <report-dir>"
`${NAME} upload --key <record-key> --project-id <id> --ci-build-id <build-id> --report-dir <report-dir>`
)}
`;

export const getCurrentsReporterCommand = () => {
return new Command()
.name("currents-reporter")
.usage("[options]")
.allowUnknownOption()
const command = new Command()
.name(NAME)
.command("upload")
.showHelpAfterError("(add --help for additional information)")
.allowUnknownOption()
.description(
`Report upload utility for https://currents.dev
`Upload test results generated by Currents reporters to https://currents.dev
${currentsReporterExample}`
)
.addOption(ciBuildIdOption)
Expand All @@ -64,4 +65,6 @@ ${currentsReporterExample}`
.addOption(machineIdOption)
.addOption(debugOption)
.addOption(reportDirOption);

return command;
};
6 changes: 3 additions & 3 deletions packages/cli/src/discovery/jest/args/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { argvToString, getDiscoveryOptions } from "./args";
import { getConfigFilePath } from "./config";
import { isEmpty } from "lodash";
import { CLIArgs } from "../../../types";
import { argvToString, getDiscoveryOptions } from "./args";
import { getConfigFilePath } from "./config";

export async function getCLIArgs(
cliArgsFromConfig: CLIArgs
Expand All @@ -19,7 +19,7 @@ export async function getCLIArgs(
"--testNamePattern",
testNamePattern,
"--reporters",
"@currents/reporter-cli/discovery/jest",
"@currents/cmd/discovery/jest",
"--shard=1/1",
configFilePath ? `--config=${configFilePath}` : "",
...(cliArgsFromConfig.args as string[]),
Expand Down
29 changes: 16 additions & 13 deletions packages/jest-reporter/README.md → packages/jest/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# @currents/jest-reporter
# @currents/jest

A [Jest](https://github.com/facebook/jest) test results processor for generating reports for [Currents](https://currents.dev) - a cloud dashboard for debugging, troubleshooting and analysing parallel CI tests.
A [Jest](https://github.com/facebook/jest) reporter for [Currents](https://currents.dev) - a cloud platform for debugging, troubleshooting and analysing CI test results.

## Installation
## Setup

```
$ npm install @currents/jest-reporter --save-dev
```sh
npm install @currents/jest --save-dev
```

## Usage

Add the reporter to the Jest configuration:
Add the reporter to Jest configuration:

```ts
import type { Config } from "jest";

```JSON
"reporters": [
"default",
["@currents/jest-reporter", {}]
]
const config: Config = {
reporters: ["default", ["@currents/jest"]],
};

export default config;
```

or set the `--reporters` option when running the Jest CLI

```
$ npx jest --reporters=@currents/jest-reporter
```sh
npx jest --reporters=@currents/jest
```

When the Jest command is executed in the terminal, a folder named using the pattern ".currents-report-[timestamp]-[uuidv4()]" will be created in your root directory. This folder will contain information about your tests and the configuration used to generate it.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@currents/jest-reporter",
"version": "0.0.0",
"name": "@currents/jest",
"version": "1.0.0",
"main": "./dist/index.js",
"author": "Currents Software Inc",
"license": "GPL-3.0-or-later",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const warnWithNoTrace = (...args: unknown[]) => {

export const errorWithNoTrace = (...args: unknown[]) => {
const msg = util.format(...args);
debug("ERRRO: ", msg);
debug("ERROR: ", msg);
return log(chalk.bgRed.white(" ERROR "), msg);
};

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ee507ac

Please sign in to comment.