Skip to content

Commit 7193829

Browse files
committed
Test revert verdaccio change
1 parent 3ce2a1b commit 7193829

File tree

13 files changed

+53
-102
lines changed

13 files changed

+53
-102
lines changed

.github/shared-actions/windows-bazel-test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runs:
2222

2323
- name: Initialize WSL
2424
id: init_wsl
25-
uses: angular/dev-infra/github-actions/setup-wsl@10c9ccde0b22c30eefc13adc5a5121b5898902d1
25+
uses: angular/dev-infra/github-actions/setup-wsl@9a3e28a515bf51cd2ecfd5f4d5b17613845e6f44
2626
with:
2727
wsl_firewall_interface: 'vEthernet (WSL (Hyper-V firewall))'
2828

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
- name: Setup Bazel RBE
9696
uses: angular/dev-infra/github-actions/bazel/configure-remote@744a2caa9074eaf2e0ca26d6f7cba79bdfec185d
9797
- name: Run CLI E2E tests
98-
run: yarn bazel test --define=E2E_SHARD_TOTAL=6 --define=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.${{ matrix.subset }}_node${{ matrix.node }}
98+
run: yarn bazel test --test_env=E2E_SHARD_TOTAL=6 --test_env=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.${{ matrix.subset }}_node${{ matrix.node }}
9999

100100
e2e-package-managers:
101101
needs: test
@@ -117,7 +117,7 @@ jobs:
117117
- name: Setup Bazel RBE
118118
uses: angular/dev-infra/github-actions/bazel/configure-remote@744a2caa9074eaf2e0ca26d6f7cba79bdfec185d
119119
- name: Run CLI E2E tests
120-
run: yarn bazel test --define=E2E_SHARD_TOTAL=3 --define=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.${{ matrix.subset }}_node${{ matrix.node }}
120+
run: yarn bazel test --test_env=E2E_SHARD_TOTAL=3 --test_env=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.${{ matrix.subset }}_node${{ matrix.node }}
121121

122122
e2e-snapshots:
123123
needs: test
@@ -139,7 +139,7 @@ jobs:
139139
- name: Setup Bazel RBE
140140
uses: angular/dev-infra/github-actions/bazel/configure-remote@744a2caa9074eaf2e0ca26d6f7cba79bdfec185d
141141
- name: Run CLI E2E tests
142-
run: yarn bazel test --define=E2E_SHARD_TOTAL=6 --define=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.snapshots.${{ matrix.subset }}_node${{ matrix.node }}
142+
run: yarn bazel test --test_env=E2E_SHARD_TOTAL=6 --test_env=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.snapshots.${{ matrix.subset }}_node${{ matrix.node }}
143143

144144
browsers:
145145
needs: build

.github/workflows/pr.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
- name: Setup Bazel RBE
124124
uses: angular/dev-infra/github-actions/bazel/configure-remote@744a2caa9074eaf2e0ca26d6f7cba79bdfec185d
125125
- name: Run CLI E2E tests
126-
run: yarn bazel test --define=E2E_SHARD_TOTAL=6 --define=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.${{ matrix.subset }}_node${{ matrix.node }}
126+
run: yarn bazel test --test_env=E2E_SHARD_TOTAL=6 --test_env=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.${{ matrix.subset }}_node${{ matrix.node }}
127127

128128
e2e-windows-subset:
129129
# needs: build
@@ -154,7 +154,7 @@ jobs:
154154
# with:
155155
# command: |
156156
# yarn bazel test \
157-
# --define=E2E_SHARD_TOTAL=6 --define=E2E_SHARD_INDEX=${{ matrix.shard }} \
157+
# --test_env=E2E_SHARD_TOTAL=6 --test_env=E2E_SHARD_INDEX=${{ matrix.shard }} \
158158
# --config=e2e //tests/legacy-cli:e2e.${{ matrix.subset }}_node${{ matrix.node }} \
159159

160160
e2e-package-managers:
@@ -177,7 +177,7 @@ jobs:
177177
- name: Setup Bazel RBE
178178
uses: angular/dev-infra/github-actions/bazel/configure-remote@744a2caa9074eaf2e0ca26d6f7cba79bdfec185d
179179
- name: Run CLI E2E tests
180-
run: yarn bazel test --define=E2E_SHARD_TOTAL=3 --define=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.${{ matrix.subset }}_node${{ matrix.node }}
180+
run: yarn bazel test --test_env=E2E_SHARD_TOTAL=3 --test_env=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.${{ matrix.subset }}_node${{ matrix.node }}
181181

182182
e2e-snapshots:
183183
needs: [analyze, build]
@@ -200,4 +200,4 @@ jobs:
200200
- name: Setup Bazel RBE
201201
uses: angular/dev-infra/github-actions/bazel/configure-remote@744a2caa9074eaf2e0ca26d6f7cba79bdfec185d
202202
- name: Run CLI E2E tests
203-
run: yarn bazel test --define=E2E_SHARD_TOTAL=6 --define=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.snapshots.${{ matrix.subset }}_node${{ matrix.node }}
203+
run: yarn bazel test --test_env=E2E_SHARD_TOTAL=6 --test_env=E2E_SHARD_INDEX=${{ matrix.shard }} --config=e2e //tests/legacy-cli:e2e.snapshots.${{ matrix.subset }}_node${{ matrix.node }}

WORKSPACE

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,8 @@ npm_translate_lock(
193193
},
194194
pnpm_lock = "//:pnpm-lock.yaml",
195195
public_hoist_packages = {
196-
# Pino of Verdaccio can't be bundled, so we make it loadable as runtime dep.
197-
# Similarly, logger-prettify is dynamically loaded at runtime.
198-
"pino": [""],
196+
# TODO: Remove when https://github.com/verdaccio/verdaccio/commit/bf0e09a509e8e0a74167b0307d129202bc3f40d2 is available.
199197
"@verdaccio/config": [""],
200-
"@verdaccio/logger-prettify": [""],
201198
},
202199
update_pnpm_lock = True,
203200
verify_node_modules_ignored = "//:.bazelignore",

test.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

test2.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/legacy-cli/BUILD.bazel

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path")
2-
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
32
load("@npm2//:rollup/package_json.bzl", rollup = "bin")
43
load("//tools:interop.bzl", "ts_project")
54
load(":e2e.bzl", "e2e_suites")
65

76
package(default_visibility = ["//visibility:public"])
87

9-
bool_flag(
10-
name = "enable_native_windows_testing",
11-
build_setting_default = False,
12-
)
13-
14-
config_setting(
15-
name = "native_windows_testing",
16-
flag_values = {
17-
":enable_native_windows_testing": "true",
18-
},
19-
)
20-
218
ts_project(
229
name = "runner",
2310
testonly = True,
@@ -75,13 +62,14 @@ e2e_suites(
7562
"package.json",
7663

7764
# Dynamically loaded.
78-
"//:node_modules/verdaccio-auth-memory",
7965
"//tests/legacy-cli/e2e/assets",
66+
"//:node_modules/verdaccio",
67+
"//:node_modules/verdaccio-auth-memory",
8068

81-
# Runtime deps due to bundling issues
69+
# Extra runtime deps due to bundling issues.
70+
# TODO: Clean this up.
8271
"//:node_modules/@verdaccio/config",
83-
"//:node_modules/@verdaccio/logger-prettify",
84-
"//:node_modules/pino",
72+
"//:node_modules/express",
8573
],
8674
runner = ":runner_entrypoint",
8775
)

tests/legacy-cli/e2e/utils/registry.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1+
import { ChildProcess, fork } from 'node:child_process';
2+
import { on } from 'node:events';
13
import { join } from 'node:path';
24
import { getGlobalVariable } from './env';
35
import { writeFile, readFile } from './fs';
46
import { mktempd } from './utils';
5-
import { runServer as runVerdaccioServer } from 'verdaccio';
6-
import { setup as setupVerdaccioLogger } from 'verdaccio/build/lib/logger';
77

88
export async function createNpmRegistry(
99
port: number,
1010
httpsPort: number,
1111
withAuthentication = false,
12-
): Promise<void> {
12+
): Promise<ChildProcess> {
1313
// Setup local package registry
1414
const registryPath = await mktempd('angular-cli-e2e-registry-');
1515

1616
let configContent = await readFile(
17-
join('tests/legacy-cli', withAuthentication ? 'verdaccio_auth.yaml' : 'verdaccio.yaml'),
17+
join(__dirname, '../', withAuthentication ? 'verdaccio_auth.yaml' : 'verdaccio.yaml'),
1818
);
1919
configContent = configContent.replace(/\$\{HTTP_PORT\}/g, String(port));
2020
configContent = configContent.replace(/\$\{HTTPS_PORT\}/g, String(httpsPort));
2121
const configPath = join(registryPath, 'verdaccio.yaml');
2222
await writeFile(configPath, configContent);
2323

24-
const instancePort = withAuthentication ? httpsPort : port;
25-
26-
// Verdaccio config `log` section is not respected by the programmatic API.
27-
setupVerdaccioLogger({
28-
type: 'stdout',
29-
level: 'warn',
30-
format: 'pretty',
31-
});
32-
33-
const server = await runVerdaccioServer(configPath);
34-
35-
await new Promise<void>((resolve) => {
36-
server.listen(instancePort, () => resolve());
37-
});
24+
const verdaccioServer = fork(require.resolve('verdaccio/bin/verdaccio'), ['-c', configPath]);
25+
for await (const events of on(verdaccioServer, 'message', {
26+
signal: AbortSignal.timeout(30_000),
27+
})) {
28+
if (
29+
events.some(
30+
(event: unknown) =>
31+
event &&
32+
typeof event === 'object' &&
33+
'verdaccio_started' in event &&
34+
event.verdaccio_started,
35+
)
36+
) {
37+
break;
38+
}
39+
}
3840

39-
console.log(`Verdaccio running on: http://localhost:${instancePort}`);
41+
return verdaccioServer;
4042
}
4143

4244
// Token was generated using `echo -n 'testing:s3cret' | openssl base64`.

tests/legacy-cli/e2e_runner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ Promise.all([findFreePort(), findFreePort(), findPackageTars()])
223223
setGlobalVariable('package-tars', packageTars);
224224

225225
// NPM registries for the lifetime of the test execution
226-
await createNpmRegistry(httpPort, httpPort);
227-
await createNpmRegistry(httpPort, httpsPort, true);
226+
const registryProcess = await createNpmRegistry(httpPort, httpPort);
227+
const secureRegistryProcess = await createNpmRegistry(httpPort, httpsPort, true);
228228

229229
try {
230230
await runSteps(runSetup, allSetups, 'setup');
@@ -261,8 +261,8 @@ Promise.all([findFreePort(), findFreePort(), findPackageTars()])
261261

262262
process.exitCode = 1;
263263
} finally {
264-
// Note: Need to exit as Verdaccio API does not expose a way to stop the server.
265-
process.exit();
264+
registryProcess.kill();
265+
secureRegistryProcess.kill();
266266
}
267267
})
268268
.catch((err) => {

tests/legacy-cli/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/legacy-cli/rollup.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ for (const file of testFiles) {
2525

2626
export default {
2727
input: chunks,
28-
external: ['pino', '@verdaccio/logger-prettify'],
28+
external: [],
2929
plugins: [
3030
nodeResolve({
3131
preferBuiltins: true,

tests/legacy-cli/verdaccio.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ storage: ./storage
33
auth:
44
auth-memory:
55
users: {}
6-
listen: 0.0.0.0:${HTTP_PORT}
6+
listen: localhost:${HTTP_PORT}
77
uplinks:
88
npmjs:
99
url: https://registry.npmjs.org/
@@ -41,6 +41,11 @@ packages:
4141
access: $all
4242
proxy: npmjs
4343

44+
log:
45+
type: stdout
46+
format: pretty
47+
level: warn
48+
4449
# https://github.com/verdaccio/verdaccio/issues/301
4550
server:
4651
keepAliveTimeout: 0

tests/legacy-cli/verdaccio_auth.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ auth:
55
testing:
66
name: testing
77
password: s3cret
8-
listen: 0.0.0.0:${HTTPS_PORT}
8+
listen: localhost:${HTTPS_PORT}
99
uplinks:
1010
local:
11-
url: http://127.0.0.1:${HTTP_PORT}
11+
url: http://localhost:${HTTP_PORT}
1212
cache: false
1313
maxage: 20m
1414
max_fails: 32
@@ -23,6 +23,11 @@ packages:
2323
access: $authenticated
2424
proxy: local
2525

26+
log:
27+
type: stdout
28+
format: pretty
29+
level: warn
30+
2631
# https://github.com/verdaccio/verdaccio/issues/301
2732
server:
2833
keepAliveTimeout: 0

0 commit comments

Comments
 (0)