Skip to content

Commit

Permalink
feat: update push and push-status commands (#1481)
Browse files Browse the repository at this point in the history
* feat(bh): make 'project' and 'domain' required for push command (CMS)

* chore: add OutputFormat type for 'format' parameter for push-status command

* feat: add 'format' parameter for 'push-status'
command

* feat: add 'markdown' to OutputFormat type

* feat: make domain not required for push-status

* refactor: simplify `handlePushStatus` function

* feat: add json format for push-status command

* feat: remove `async` from printPushStatus

* feat: improve printing json summary and exit with error

* feat: add 'format' option to cli push command

* feat: add push metadata to json output

* feat: add return data for push and pushStatus commands

* feat: update push status command

* tests: add new unit tests for push status

* refactor: remove json format for "push" and "push-status" commands

* feat: add "ignore-deployment-failures" option

* chore: replace "satisfies" with "as"

* chore: add changeset

* feat: add onTimeOutExceeded callback

* Apply suggestions from code review

Co-authored-by: Lorna Jane Mitchell <[email protected]>

* Apply suggestions from code review

Co-authored-by: Andrew Tatomyr <[email protected]>
Co-authored-by: Roman Sainchuk <[email protected]>

* chore: update return type for commandHandler

* tests: use expect.rejects instead of catching errors

* feat: rename 'ignore-deployment-failures' to 'continue-on-deployment-failures'

* feat: add onConditionNotMet callback

* tests: add unit tests

* chore: add comments

* refactor: rename "wait" to "pause" and move to utils

* refactor: change import type

* refactor: add explicit array length check

* fix: add correct wrapper type for argv params

* feat: update types for push status API

* chore: add "unit:watch" script to package.json

* test: fix unit tests

* tests: add tests for "onRetry" and "max-execution-time" parameters

* chore: restore museum.yaml

* feat: update API types for PushResponse

* refactor: rename "continue-on-deployment-failures" to "continue-on-deploy-failures"

* feat: update interface for `onRetry` function

* feat: remove "instanceof Promise" check

* refactor: reorder imports

* feat: increase maxExecutionTime to 20 min

---------

Co-authored-by: Lorna Jane Mitchell <[email protected]>
Co-authored-by: Andrew Tatomyr <[email protected]>
Co-authored-by: Roman Sainchuk <[email protected]>
  • Loading branch information
4 people authored Apr 25, 2024
1 parent 89af9c6 commit 4cf08db
Show file tree
Hide file tree
Showing 15 changed files with 945 additions and 191 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-swans-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@redocly/cli": minor
---

Added return values for the `push` and `push-status` commands.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ Run unit tests with this command: `npm run test`.
Unit tests in the **cli** package are sensitive to top-level configuration file (**redocly.yaml**).

To run a specific test, use this command: `npm run unit -- -t 'Test name'`.
To run tests in watch mode, run: `npm run unit:watch`
To run single file in watch mode, run: `npm run unit:watch -- <path/to/your/file.test.ts>`
To update snapshots, run `npm run unit -- -u`.

To get coverage per package run `npm run coverage:cli` or `npm run coverage:core`.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test": "npm run typecheck && npm run unit",
"jest": "REDOCLY_TELEMETRY=off jest ./packages",
"unit": "npm run jest -- --coverage --coverageReporters lcov text-summary",
"unit:watch": "REDOCLY_TELEMETRY=off jest --watch",
"coverage:cli": "npm run jest -- --roots packages/cli/src --coverage",
"coverage:core": "npm run jest -- --roots packages/core/src --coverage",
"typecheck": "tsc --noEmit --skipLibCheck",
Expand Down
31 changes: 19 additions & 12 deletions packages/cli/src/cms/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,42 @@ export type Remote = {
export type PushResponse = {
id: string;
remoteId: string;
isMainBranch: boolean;
isOutdated: boolean;
hasChanges: boolean;
replace: boolean;
scoutJobId: string | null;
uploadedFiles: Array<{ path: string; mimeType: string }>;
commit: {
message: string;
branchName: string;
sha: string | null;
url: string | null;
message: string;
createdAt: string | null;
namespace: string | null;
repository: string | null;
namespaceId: string | null;
repositoryId: string | null;
url: string | null;
sha: string | null;
author: {
name: string;
email: string;
image: string | null;
};
statuses: Array<{
name: string;
description: string;
status: 'pending' | 'running' | 'success' | 'failed';
url: string | null;
}>;
};
remote: {
commits: {
branchName: string;
sha: string;
branchName: string;
}[];
};
hasChanges: boolean;
isOutdated: boolean;
isMainBranch: boolean;
status: PushStatusResponse;
};

type DeploymentStatusResponse = {
export type DeploymentStatusResponse = {
deploy: {
url: string | null;
status: DeploymentStatus;
Expand All @@ -96,6 +105,4 @@ export type ScorecardItem = {

export type PushStatusBase = 'pending' | 'success' | 'running' | 'failed';

// export type BuildStatus = PushStatusBase | 'NOT_STARTED' | 'QUEUED';

export type DeploymentStatus = 'skipped' | PushStatusBase;
Loading

1 comment on commit 4cf08db

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 77.05% 4451/5777
🟡 Branches 67.48% 2447/3626
🟡 Functions 70.73% 742/1049
🟡 Lines 77.24% 4185/5418

Test suite run success

734 tests passing in 102 suites.

Report generated by 🧪jest coverage report action from 4cf08db

Please sign in to comment.