Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add cli test to validate multiple manifest generation paths result in comparable output #1642

Merged
merged 55 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
5593109
wip: initial
btlghrants Jan 9, 2025
d40f43e
wip: update eslint config
btlghrants Jan 9, 2025
d775061
wip: saving progress
btlghrants Jan 9, 2025
7a9577d
wip: saving progress
btlghrants Jan 10, 2025
106d4f0
wip: saving progress
btlghrants Jan 10, 2025
bbc0a4f
wip: saving progress
btlghrants Jan 10, 2025
5ac8379
wip: refactor f/ eslint warnings
btlghrants Jan 10, 2025
ff7df21
wip: saving progress
btlghrants Jan 10, 2025
cb674cb
wip: somethings changing root package.json, ugh, so I'm changing appr…
btlghrants Jan 10, 2025
d573a85
wip: new approach (with NPM_CONFIG_CACHE) working much better
btlghrants Jan 10, 2025
191fe0a
wip: saving proress
btlghrants Jan 11, 2025
8c9ca06
wip: saving proress
btlghrants Jan 11, 2025
ddebf48
wip: saving progress
btlghrants Jan 11, 2025
f4ecb21
wip: saving progress
btlghrants Jan 11, 2025
99c3623
wip: saving progress
btlghrants Jan 11, 2025
d4ef914
wip: saving progress
btlghrants Jan 11, 2025
f9dd5f6
wip: saving progress
btlghrants Jan 13, 2025
f00f448
wip: saving progress
btlghrants Jan 13, 2025
ea0c589
wip: saving progress
btlghrants Jan 13, 2025
7a162bd
wip: saving progress
btlghrants Jan 13, 2025
0a3fc9f
wip: saving progress
btlghrants Jan 13, 2025
eef5cd0
wip: saving progress
btlghrants Jan 13, 2025
7b9d80a
wip: saving progress
btlghrants Jan 13, 2025
dfa0eae
wip: saving progress
btlghrants Jan 13, 2025
738a09c
wip: saving progress
btlghrants Jan 13, 2025
09d2ad5
wip: saving progress
btlghrants Jan 13, 2025
4d7990e
wip: saving progress
btlghrants Jan 13, 2025
cfd756d
wip: saving progress
btlghrants Jan 13, 2025
f80d312
wip: saving progress
btlghrants Jan 13, 2025
704a349
wip: parallelize them tests!
btlghrants Jan 14, 2025
4e3ef6e
wip: merge main
btlghrants Jan 14, 2025
9709182
wip: rm redundant CI test file
btlghrants Jan 14, 2025
eab67ae
wip: PR feedback - swap 'testModule' for 'mod'
btlghrants Jan 14, 2025
76d6510
wip: PR feedback - swap 'test:integration' for 'test:int'
btlghrants Jan 14, 2025
8245518
wip: PR feedback - swap 'test:integration' for 'test:int'
btlghrants Jan 14, 2025
ff9ca16
wip: PR feedback - swap 'result' for 'res'
btlghrants Jan 14, 2025
a6abee2
wip: PR feedback - swap 'result' for 'res'
btlghrants Jan 14, 2025
b8b84a6
wip: PR feedback - remove 'TODO' comments
btlghrants Jan 14, 2025
a1995fe
wip: PR feedback - remove intermediate local var
btlghrants Jan 14, 2025
07a02c9
Merge branch 'main' into 1640_helm_templates_correspond
btlghrants Jan 14, 2025
1dbaca5
wip: PR feedback - expand filter func args
btlghrants Jan 14, 2025
544150a
wip: PR feedback - expand map func args
btlghrants Jan 14, 2025
cec588b
wip: PR feedback - remove placeholder comment
btlghrants Jan 14, 2025
9cabc5b
wip: PR feedback - remove flag precedence comment-question
btlghrants Jan 14, 2025
84e9314
wip: PR feedback - expand short variable name
btlghrants Jan 14, 2025
d802fe3
wip: PR feedback - use fs.existsSync instead of file helper
btlghrants Jan 14, 2025
3f824f0
wip: PR feedback - rm unneeded pepr.copyModule helper
btlghrants Jan 14, 2025
b72960a
wip: PR feedback - use fs.existsSync in Workdir helper
btlghrants Jan 14, 2025
18e833a
Update integration/prep.sh
btlghrants Jan 14, 2025
c9c0c28
wip: rm dead import
btlghrants Jan 14, 2025
fe536eb
wip: rm dead import
btlghrants Jan 14, 2025
92ec7c3
chore: consolidate file parsing implementation (#1663)
samayer12 Jan 15, 2025
5196e7b
chore: Mac support / module func name simplification
btlghrants Jan 15, 2025
2ce46b2
chore: merge main
btlghrants Jan 15, 2025
26706f6
Merge branch 'main' into 1640_helm_templates_correspond
btlghrants Jan 15, 2025
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
11 changes: 9 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["tsconfig.json"],
"project": ["tsconfig.eslint.json"],
"ecmaVersion": 2022
},
"rules": {
Expand All @@ -22,6 +22,12 @@
"no-invalid-this": "warn"
},
"overrides": [
{
"files": ["*.test.ts"],
"rules": {
"max-nested-callbacks": ["warn", { "max": 8 }]
}
},
{
"files": ["*.ts"],
"excludedFiles": "*.test.ts",
Expand All @@ -39,7 +45,8 @@
"pepr-test-module",
"build.mjs",
"journey",
"__mocks__"
"__mocks__",
"integration/testroot"
],
"root": true
}
127 changes: 0 additions & 127 deletions .github/workflows/cli-tests.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ jobs:
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}

integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Use Node.js 22
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 22
cache: "npm"
- name: Setup Helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: v3.3.4

- run: npm ci
- run: npm run test:integration

journey:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions integration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
testroot/
.npm/
52 changes: 52 additions & 0 deletions integration/cli/build.defaults.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors

import { beforeAll, describe, expect, it } from "@jest/globals";
import * as path from "node:path";
import * as fs from "node:fs/promises";
import { Workdir } from "../helpers/workdir";
import * as time from "../helpers/time";
import * as pepr from "../helpers/pepr";

const FILE = path.basename(__filename);
const HERE = __dirname;

describe("build", () => {
const workdir = new Workdir(`${FILE}`, `${HERE}/../testroot/cli`);

beforeAll(async () => {
await workdir.recreate();
});

describe("builds a module", () => {
const id = FILE.split(".").at(1);
const testModule = `${workdir.path()}/${id}`;

beforeAll(async () => {
await fs.rm(testModule, { recursive: true, force: true });
const argz = [
`--name ${id}`,
`--description ${id}`,
`--errorBehavior reject`,
"--confirm",
"--skip-post-init",
].join(" ");
await pepr.cli(workdir.path(), { cmd: `pepr init ${argz}` });
await pepr.tgzifyModule(testModule);
await pepr.cli(testModule, { cmd: `npm install` });
}, time.toMs("2m"));

describe("using default build options", () => {
it(
"builds",
async () => {
const build = await pepr.cli(testModule, { cmd: `pepr build` });
expect(build.exitcode).toBe(0);
expect(build.stderr.join("").trim()).toBe("");
expect(build.stdout.join("").trim()).toContain("K8s resource for the module saved");
},
time.toMs("1m"),
);
});
});
});
31 changes: 31 additions & 0 deletions integration/cli/build.help.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors

import { beforeAll, describe, expect, it } from "@jest/globals";
import * as path from "node:path";
import { Workdir } from "../helpers/workdir";
import * as pepr from "../helpers/pepr";
import * as time from "../helpers/time";

const FILE = path.basename(__filename);
const HERE = __dirname;

describe("build", () => {
const workdir = new Workdir(`${FILE}`, `${HERE}/../testroot/cli`);

beforeAll(async () => {
await workdir.recreate();
});

it(
"gives command line help",
async () => {
const argz = "--help";
const result = await pepr.cli(workdir.path(), { cmd: `pepr build ${argz}` });
expect(result.exitcode).toBe(0);
expect(result.stderr.join("").trim()).toBe("");
expect(result.stdout.at(0)).toMatch("Usage: pepr build");
},
time.toMs("30s"),
);
});
88 changes: 88 additions & 0 deletions integration/cli/build.noembed.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors

import { beforeAll, describe, expect, it } from "@jest/globals";
import * as path from "node:path";
import * as fs from "node:fs/promises";
import { existsSync } from "node:fs";
import { Workdir } from "../helpers/workdir";
import * as time from "../helpers/time";
import * as pepr from "../helpers/pepr";
import * as resource from "../helpers/resource";

const FILE = path.basename(__filename);
const HERE = __dirname;

describe("build", () => {
const workdir = new Workdir(`${FILE}`, `${HERE}/../testroot/cli`);

beforeAll(async () => {
await workdir.recreate();
});

describe("builds a module", () => {
const id = FILE.split(".").at(1);
const testModule = `${workdir.path()}/${id}`;

beforeAll(async () => {
await fs.rm(testModule, { recursive: true, force: true });
const argz = [
`--name ${id}`,
`--description ${id}`,
`--errorBehavior reject`,
"--confirm",
"--skip-post-init",
].join(" ");
await pepr.cli(workdir.path(), { cmd: `pepr init ${argz}` });
await pepr.tgzifyModule(testModule);
await pepr.cli(testModule, { cmd: `npm install` });
}, time.toMs("2m"));

describe("for use as a library", () => {
let packageJson;
let uuid: string;

it(
"builds",
async () => {
const argz = [`--no-embed`].join(" ");
const build = await pepr.cli(testModule, { cmd: `pepr build ${argz}` });
expect(build.exitcode).toBe(0);
expect(build.stderr.join("").trim()).toContain("Error: Cannot find module");
expect(build.stdout.join("").trim()).toContain("");

packageJson = await resource.fromFile(`${testModule}/package.json`);
uuid = packageJson.pepr.uuid;
},
time.toMs("1m"),
);

it(
"outputs appropriate configuration",
async () => {
const missing = [
`${testModule}/dist/pepr-${uuid}.js`,
`${testModule}/dist/pepr-${uuid}.js.map`,
`${testModule}/dist/pepr-${uuid}.js.LEGAL.txt`,
`${testModule}/dist/pepr-module-${uuid}.yaml`,
`${testModule}/dist/zarf.yaml`,
`${testModule}/dist/${uuid}-chart/`,
];
for (const path of missing) {
expect(existsSync(path)).toBe(false);
}

const found = [
`${testModule}/dist/pepr.js`,
`${testModule}/dist/pepr.js.map`,
`${testModule}/dist/pepr.js.LEGAL.txt`,
];
for (const path of found) {
expect(existsSync(path)).toBe(true);
}
},
time.toMs("1m"),
);
});
});
});
Loading
Loading