Skip to content

Commit

Permalink
feat(mode): add "mode" support (#126)
Browse files Browse the repository at this point in the history
* feat(mode): add "mode" support

* chore: use pnpm v9

* chore: upgrade deps

* chore: fix Node.js version

* chore: mark pnpm v9
  • Loading branch information
gregberge committed May 4, 2024
1 parent a7020e9 commit 91a53b6
Show file tree
Hide file tree
Showing 9 changed files with 8,316 additions and 6,363 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
name: Install pnpm
id: pnpm-install
with:
version: 8
version: 9
run_install: false

- name: Install Node.js
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:

- name: Setup deps
uses: ./.github/actions/setup-deps
with:
node-version: 20

- name: Lint
run: npm run lint
Expand All @@ -33,6 +35,8 @@ jobs:

- name: Setup deps
uses: ./.github/actions/setup-deps
with:
node-version: 20

- name: Build
run: npm run build
Expand Down Expand Up @@ -91,7 +95,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18, 20, current]
node-version: [18, 20, 22]

runs-on: ubuntu-latest

Expand Down Expand Up @@ -131,7 +135,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18, 20, current]
node-version: [18, 20, 22]
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-swc": "^0.3.0",
"@rollup/plugin-typescript": "^11.1.6",
"@swc/core": "^1.4.12",
"@swc/core": "^1.4.17",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"lerna": "^8.1.2",
"prettier": "^3.2.5",
"rollup": "^4.14.0",
"rollup-plugin-swc3": "^0.11.0",
"rollup": "^4.17.2",
"rollup-plugin-swc3": "^0.11.1",
"rollup-plugin-ts": "^3.4.5",
"typedoc": "^0.25.12",
"typescript": "^5.4.4",
"vitest": "^1.4.0"
"typedoc": "^0.25.13",
"typescript": "^5.4.5",
"vitest": "^1.6.0"
},
"scripts": {
"build": "pnpm run -r prebuild && cross-env NODE_ENV=production pnpm -r run build",
Expand All @@ -29,6 +29,8 @@
"release-canary": "npm run build && lerna publish --canary --dist-tag canary"
},
"engines": {
"node": ">=18.0.0"
}
"node": "20",
"pnpm": "9"
},
"packageManager": "pnpm@9.1.0-0+sha512.568e95e38592215a03fa2cb02a58b67c6452e51b176d9941d546a59a471c42e2b4c2428bf286addcbe4e2dec98e682e2df0fa93a5082cf3493afc496affd8ffb"
}
62 changes: 46 additions & 16 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { resolve } from "node:path";
import { program } from "commander";
import { Option, program } from "commander";
import { upload } from "@argos-ci/core";
import ora from "ora";

Expand Down Expand Up @@ -30,24 +30,53 @@ program
"-i, --ignore <patterns...>",
'One or more globs matching image file paths to ignore (ex: "**/*.png **/diff.jpg")',
)
.option("--token <token>", "Repository token")
.option(
"--build-name <string>",
"Name of the build, in case you want to run multiple Argos builds in a single CI job",
.addOption(
new Option("--token <token>", "Repository token").env("ARGOS_TOKEN"),
)
.option(
"--parallel",
"Enable parallel mode. Run multiple Argos builds and combine them at the end",
.addOption(
new Option(
"--build-name <string>",
"Name of the build, in case you want to run multiple Argos builds in a single CI job",
).env("ARGOS_BUILD_NAME"),
)
.option("--parallel-total <number>", "The number of parallel nodes being ran")
.option("--parallel-nonce <string>", "A unique ID for this parallel build")
.option(
"--reference-branch <string>",
"Branch used as baseline for screenshot comparison",
.addOption(
new Option(
"--mode <string>",
"Mode of comparison applied. CI for visual regression testing, monitoring for visual monitoring.",
)
.default("ci")
.choices(["ci", "monitoring"])
.env("ARGOS_MODE"),
)
.option(
"--reference-commit <string>",
"Commit used as baseline for screenshot comparison",
.addOption(
new Option(
"--parallel",
"Enable parallel mode. Run multiple Argos builds and combine them at the end",
).env("ARGOS_PARALLEL"),
)
.addOption(
new Option(
"--parallel-total <number>",
"The number of parallel nodes being ran",
).env("ARGOS_PARALLEL_TOTAL"),
)
.addOption(
new Option(
"--parallel-nonce <string>",
"A unique ID for this parallel build",
).env("ARGOS_PARALLEL_NONCE"),
)
.addOption(
new Option(
"--reference-branch <string>",
"Branch used as baseline for screenshot comparison",
).env("ARGOS_REFERENCE_BRANCH"),
)
.addOption(
new Option(
"--reference-commit <string>",
"Commit used as baseline for screenshot comparison",
).env("ARGOS_REFERENCE_COMMIT"),
)
.action(async (directory, options) => {
const spinner = ora("Uploading screenshots").start();
Expand All @@ -64,6 +93,7 @@ program
: false,
referenceBranch: options.referenceBranch,
referenceCommit: options.referenceCommit,
mode: options.mode,
});
spinner.succeed(`Build created: ${result.build.url}`);
} catch (error: any) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface CreateBuildInput {
prHeadCommit?: string | null;
referenceBranch?: string | null;
referenceCommit?: string | null;
mode?: "ci" | "monitoring" | null;
}

export interface CreateBuildOutput {
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ const schema = {
format: String,
nullable: true,
},
mode: {
env: "ARGOS_MODE",
format: ["ci", "monitoring"],
default: null,
nullable: true,
},
prNumber: {
env: "ARGOS_PR_NUMBER",
format: Number,
Expand Down Expand Up @@ -140,6 +146,7 @@ export interface Config {
runId: string | null;
prNumber: number | null;
prHeadCommit: string | null;
mode: "ci" | "monitoring" | null;
}

const createConfig = () => {
Expand Down Expand Up @@ -178,6 +185,7 @@ export async function readConfig(options: Partial<Config> = {}) {
ciEnv?.nonce ||
null,
parallelTotal: options.parallelTotal || config.get("parallelTotal") || null,
mode: options.mode || config.get("mode") || null,
});

config.validate();
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export interface UploadParameters {
prNumber?: number;
/** Name of the build used to trigger multiple Argos builds on one commit */
buildName?: string;
/** Mode of comparison applied */
mode?: "ci" | "monitoring";
/** Parallel test suite mode */
parallel?:
| {
Expand Down Expand Up @@ -159,6 +161,7 @@ export async function upload(params: UploadParameters) {
commit: config.commit,
branch: config.branch,
name: config.buildName,
mode: config.mode,
parallel: config.parallel,
parallelNonce: config.parallelNonce,
screenshotKeys,
Expand Down

0 comments on commit 91a53b6

Please sign in to comment.