Skip to content

Commit

Permalink
[CSR-1547] feat: Implementation for api and cache commands (#12)
Browse files Browse the repository at this point in the history
* refactor: support multiple commands

* feat: add cache command

* feat: cache command implementation

* fix: make projectId mandatory for the api command

* feat: add last-run preset handler

* feat: add matrixIndex and matrixTotal options

* fix: show user a friendlier message when the cache for ID was not found

* chore: update README files [skip ci]

---------

Co-authored-by: DJ Mountney <[email protected]>
  • Loading branch information
vCaisim and twk3 authored Oct 1, 2024
1 parent 71552d5 commit 1831a0a
Show file tree
Hide file tree
Showing 78 changed files with 2,942 additions and 621 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
A monorepo which contains the following packages:

- `@currents/jest` - a jest reporter that writes the test results to json files in a Currents friendly manner
- `@currents/cmd` - exposes `currents` command which is used to discover the full test suite and upload the test results into Currents Dashboard.
- `@currents/cmd` - exposes the `currents` command which is used to interact with Currents APIs. It includes the following commands:
- `upload` command - used to discover the full test suite and upload the test results into the Currents Dashboard
- `api` command - retrieves information about Currents entities
- `cache` command - provides a convenient way to store and receive test artifacts
- `examples` - a private package used to test the implementation

## Testing locally
Expand Down Expand Up @@ -33,14 +36,33 @@ For a custom path for the report directory, set an absolute path to the `reportD

### Uploading the results

Set the `projectId`, `recordKey` and optionlly the `ciBuildId`. Run `npx currents --help` for details.
Set the `projectId`, `recordKey` and optionlly the `ciBuildId`. Run `npx currents upload --help` for details.

Run `npm run report` or `CURRENTS_API_URL=http://localhost:1234 CURRENTS_PROJECT_ID=xxx CURRENTS_RECORD_KEY=yyy npx currents upload`

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.

### Obtaining run information

Run `CURRENTS_REST_API_URL=http://localhost:4000 CURRENTS_PROJECT_ID=xxx npx currents api get-run --api-key <api-key> --ci-build-id <ci-build-id> --output run.json`

Run `npx currents api --help` to see all available api commands.

To explore additional examples and filtering options for receiving runs, you can utilize the `npx currents api get-run --help` command.


### Caching artifacts

The `currents cache` command allows you to archive files from specified locations and save them under an ID in Currents storage. It also stores a meta file with configuration data. You can provide the ID manually or it can be generated based on CI environment variables (only GitHub and GitLab are supported). The files to archive can be defined using the `paths <path-1,path2,...,path-n>` CLI option or predefined using a `preset`.

To cache files, run `npx currents cache set --key <record-key> --id <id> --paths <path-1,path-2,...path-n>`.

To download files, run `npx currents cache set --key <record-key> --preset last-run`.

For more examples and usage options, run `npx currents cache --help`.

## Release

```sh
Expand Down
Loading

0 comments on commit 1831a0a

Please sign in to comment.