Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 35 additions & 73 deletions packages/api-client/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface paths {
path?: never;
cookie?: never;
};
get: operations["getBuild"];
get?: never;
put: operations["updateBuild"];
post?: never;
delete?: never;
Expand All @@ -52,14 +52,14 @@ export interface paths {
patch?: never;
trace?: never;
};
"/builds/{buildId}/diffs": {
"/project": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["getBuildDiffs"];
get: operations["getAuthProject"];
put?: never;
post?: never;
delete?: never;
Expand All @@ -68,14 +68,14 @@ export interface paths {
patch?: never;
trace?: never;
};
"/project": {
"/projects/{owner}/{project}/builds": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["getAuthProject"];
get: operations["getProjectBuilds"];
put?: never;
post?: never;
delete?: never;
Expand All @@ -84,14 +84,14 @@ export interface paths {
patch?: never;
trace?: never;
};
"/project/builds": {
"/projects/{owner}/{project}/builds/{buildNumber}": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["getAuthProjectBuilds"];
get: operations["getBuildByNumber"];
put?: never;
post?: never;
delete?: never;
Expand All @@ -100,14 +100,14 @@ export interface paths {
patch?: never;
trace?: never;
};
"/project/builds/{buildNumber}": {
"/projects/{owner}/{project}/builds/{buildNumber}/diffs": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["getAuthBuildByNumber"];
get: operations["getBuildDiffs"];
put?: never;
post?: never;
delete?: never;
Expand Down Expand Up @@ -589,6 +589,12 @@ export interface components {
/** @description Project */
Project: {
id: string;
/** @description Account that owns the project */
account: {
id: string;
slug: string;
};
name: string;
defaultBaseBranch: string;
hasRemoteContentAccess: boolean;
};
Expand Down Expand Up @@ -801,65 +807,6 @@ export interface operations {
};
};
};
getBuild: {
parameters: {
query?: never;
header?: never;
path: {
/** @description A unique identifier for the build */
buildId: components["schemas"]["BuildId"];
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Build */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Build"];
};
};
/** @description Invalid parameters */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
/** @description Unauthorized */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
/** @description Not found */
404: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
/** @description Server error */
500: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
};
};
updateBuild: {
parameters: {
query?: never;
Expand Down Expand Up @@ -956,11 +903,17 @@ export interface operations {
perPage?: string;
/** @description Page number */
page?: string;
/** @description Only include diffs that need review */
needsReview?: boolean;
};
header?: never;
path: {
/** @description A unique identifier for the build */
buildId: components["schemas"]["BuildId"];
/** @description The account slug (owner) */
owner: string;
/** @description The project name */
project: string;
/** @description The build number */
buildNumber: number;
};
cookie?: never;
};
Expand Down Expand Up @@ -1054,7 +1007,7 @@ export interface operations {
};
};
};
getAuthProjectBuilds: {
getProjectBuilds: {
parameters: {
query?: {
/** @description Number of items per page (max 100) */
Expand All @@ -1067,7 +1020,12 @@ export interface operations {
distinctName?: string;
};
header?: never;
path?: never;
path: {
/** @description The account slug (owner) */
owner: string;
/** @description The project name */
project: string;
};
cookie?: never;
};
requestBody?: never;
Expand Down Expand Up @@ -1113,11 +1071,15 @@ export interface operations {
};
};
};
getAuthBuildByNumber: {
getBuildByNumber: {
parameters: {
query?: never;
header?: never;
path: {
/** @description The account slug (owner) */
owner: string;
/** @description The project name */
project: string;
/** @description The build number */
buildNumber: number;
};
Expand Down
48 changes: 22 additions & 26 deletions packages/cli/e2e/builds.js → packages/cli/e2e/build.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* E2E tests for `argos builds` commands.
* E2E tests for `argos build` commands.
* Requires ARGOS_TOKEN env var.
* Optional: ARGOS_API_BASE_URL env var.
*
* Usage:
* ARGOS_TOKEN=xxx node e2e/builds.js
* ARGOS_TOKEN=xxx ARGOS_API_BASE_URL=https://api.argos-ci.dev:4001/v2 NODE_OPTIONS=--use-system-ca pnpm -C packages/cli exec node e2e/builds.js
* ARGOS_TOKEN=xxx node e2e/build.js
* ARGOS_TOKEN=xxx ARGOS_API_BASE_URL=https://api.argos-ci.dev:4001/v2 NODE_OPTIONS=--use-system-ca pnpm -C packages/cli exec node e2e/build.js
*/

import { assert, run } from "./utils.js";
Expand All @@ -16,7 +16,7 @@ const buildNumber = process.env.ARGOS_BUILD_NUMBER || "28022";

if (!token) {
console.error(
"Usage: ARGOS_TOKEN=xxx [ARGOS_API_BASE_URL=<url>] node e2e/builds.js",
"Usage: ARGOS_TOKEN=xxx [ARGOS_API_BASE_URL=<url>] node e2e/build.js",
);
process.exit(1);
}
Expand All @@ -29,10 +29,10 @@ const baseEnv = apiBaseURL
? envWith({ ARGOS_API_BASE_URL: apiBaseURL })
: process.env;

console.log("\n`builds get` failing commands:");
console.log("\n`build get` failing commands:");

try {
run(["builds", "get", "1"], { ...baseEnv, ARGOS_TOKEN: "" });
run(["build", "get", "1"], { ...baseEnv, ARGOS_TOKEN: "" });
assert(false, "Missing token with build number should exit with code 1");
} catch (err) {
assert(err.status !== 0, "Exit code 1 when no token for build number");
Expand All @@ -45,7 +45,7 @@ try {
try {
run(
[
"builds",
"build",
"get",
"https://app.argos-ci.com/argos-ci/argos-javascript/builds/1",
],
Expand All @@ -61,7 +61,7 @@ try {
}

try {
run(["builds", "get", "999999"], {
run(["build", "get", "999999"], {
...baseEnv,
ARGOS_TOKEN: token,
});
Expand All @@ -75,7 +75,7 @@ try {
}

try {
run(["builds", "get", "not-a-number"], {
run(["build", "get", "not-a-number"], {
...baseEnv,
ARGOS_TOKEN: token,
});
Expand All @@ -88,15 +88,15 @@ try {
);
}

console.log("\n`builds get` successful commands:");
const buildByNumberJsonOutput = run(["builds", "get", buildNumber, "--json"], {
console.log("\n`build get` successful commands:");
const buildByNumberJsonOutput = run(["build", "get", buildNumber, "--json"], {
...baseEnv,
ARGOS_TOKEN: token,
});
const buildByNumberJson = JSON.parse(buildByNumberJsonOutput.stdout);
const buildUrl = buildByNumberJson.url;

const buildByNumberHumanOutput = run(["builds", "get", buildNumber], {
const buildByNumberHumanOutput = run(["build", "get", buildNumber], {
...baseEnv,
ARGOS_TOKEN: token,
});
Expand All @@ -119,7 +119,7 @@ assert(
"Returns the requested build number",
);

const buildByUrlJsonOutput = run(["builds", "get", "--json", buildUrl], {
const buildByUrlJsonOutput = run(["build", "get", "--json", buildUrl], {
...baseEnv,
ARGOS_TOKEN: token,
});
Expand All @@ -129,10 +129,10 @@ assert(
"accepts an Argos build URL",
);

console.log("\n`builds snapshots` failing commands:");
console.log("\n`build snapshots` failing commands:");

try {
run(["builds", "snapshots", "1"], { ...baseEnv, ARGOS_TOKEN: "" });
run(["build", "snapshots", "1"], { ...baseEnv, ARGOS_TOKEN: "" });
assert(
false,
"Missing token for snapshots with build number should exit with code 1",
Expand All @@ -148,8 +148,8 @@ try {
);
}

console.log("\n`builds snapshots` successful commands:");
const buildSnapshots = run(["builds", "snapshots", buildNumber], {
console.log("\n`build snapshots` successful commands:");
const buildSnapshots = run(["build", "snapshots", buildNumber], {
...baseEnv,
ARGOS_TOKEN: token,
});
Expand All @@ -160,21 +160,18 @@ assert(
assert(buildSnapshots.stdout.includes("Summary:"), "Prints the build Summary");

const buildSnapshotsJsonOutput = run(
["builds", "snapshots", buildNumber, "--json"],
["build", "snapshots", buildNumber, "--json"],
{
...baseEnv,
ARGOS_TOKEN: token,
},
);
const buildSnapshotsJson = JSON.parse(buildSnapshotsJsonOutput.stdout);
assert(Array.isArray(buildSnapshotsJson), "Returns an array in JSON mode");
assert(
Boolean(buildSnapshotsJson[0].base.id),
"Returns structured snapshot data",
);
assert(Boolean(buildSnapshotsJson[0].id), "Returns structured snapshot data");

const snapshotsNeedsReviewJsonOutput = run(
["builds", "snapshots", buildNumber, "--needs-review", "--json"],
["build", "snapshots", buildNumber, "--needs-review", "--json"],
{
...baseEnv,
ARGOS_TOKEN: token,
Expand All @@ -183,8 +180,7 @@ const snapshotsNeedsReviewJsonOutput = run(
const snapshotsNeedingReview = JSON.parse(
snapshotsNeedsReviewJsonOutput.stdout,
);
assert(Array.isArray(snapshotsNeedingReview), "Returns an array in JSON mode");
assert(
snapshotsNeedingReview.length === 0,
"Returns an empty array when there are no snapshots to review",
Array.isArray(snapshotsNeedingReview),
"Returns an array in JSON mode for needs-review filter",
);
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"scripts": {
"build": "tsdown",
"e2e": "node e2e/upload.js && node e2e/skip.js && node e2e/builds.js",
"e2e": "node e2e/upload.js && node e2e/skip.js && node e2e/build.js",
"check-types": "tsc",
"check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
"lint": "eslint ."
Expand Down
Loading
Loading