Skip to content

Commit 9e5b95f

Browse files
committed
chore: add verdaccio publishing tests to CI
resolves #123 To validate that everything always works, running the integration tests directly from npm will replicate exactly how customers would use this. It will also verify that all dependencies of the clients can be satisfied from npm. Finally, it exercises the publishing process to make sure that each release could be published automatically.
1 parent c8a0265 commit 9e5b95f

File tree

8 files changed

+160
-4
lines changed

8 files changed

+160
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ coverage
3131
/tsconfig.json
3232
/tsconfig.module.json
3333
package.json.decrypt
34+
35+
# verdaccio
36+
/verdaccio/storage

buildspec.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
version: 0.2
1+
version: 0.3
22

33
phases:
44
install:
55
runtime-versions:
66
nodejs: 10
77
commands:
88
- npm ci
9-
- npm run build
109
build:
10+
commands:
11+
- npm run build
12+
unit_test:
1113
commands:
1214
- npm test
1315
- npm run test_conditions
14-
- npm run integration
16+
integration_tests:
17+
commands:
18+
- npm run verdaccio

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
"integration-node-encrypt": "npm run build; integration-node encrypt -m $npm_package_config_encryptManifestList -k $npm_package_config_encryptKeyManifest -o $npm_package_config_decryptOracle -c 20",
3737
"node-integration": "run-s integration-node-*",
3838
"integration": "run-s integration-*",
39+
"verdaccio": "run-s verdaccio-*",
40+
"verdaccio-publish": "./util/local_verdaccio_publish",
41+
"verdaccio-publish-browser-decrypt": "./util/npx_verdaccio @aws-crypto/integration-browser decrypt -v $npm_package_config_localTestVectors --karma",
42+
"verdaccio-publish-browser-encrypt": "./util/npx_verdaccio @aws-crypto/integration-browser encrypt -m $npm_package_config_encryptManifestList -k $npm_package_config_encryptKeyManifest -o $npm_package_config_decryptOracle --karma",
43+
"verdaccio-publish-node-decrypt": "./util/npx_verdaccio @aws-crypto/integration-node decrypt -v $npm_package_config_localTestVectors -c 10",
44+
"verdaccio-publish-node-encrypt": "./util/npx_verdaccio @aws-crypto/integration-node encrypt -m $npm_package_config_encryptManifestList -k $npm_package_config_encryptKeyManifest -o $npm_package_config_decryptOracle -c 20",
3945
"test_conditions": "./util/test_conditions"
4046
},
4147
"config": {
@@ -125,6 +131,7 @@
125131
"lerna": "^3.13.3",
126132
"source-map-support": "^0.5.12",
127133
"tslib": "^1.9.3",
128-
"rimraf": "^2.6.2"
134+
"rimraf": "^2.6.2",
135+
"verdaccio": "^4.5.1"
129136
}
130137
}

util/local_verdaccio_publish

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Always clear storage so the latest versions are published
4+
# I am not worried about _what_ version number is published
5+
# Only that it is the latest code
6+
rm -rf verdaccio/storage/@aws-crypto
7+
8+
# Start verdaccio in the background
9+
verdaccio -c verdaccio/config.yaml &
10+
11+
# Publish all changed packages the local verdaccio server.
12+
# Anything that has not been changed will match what is in npm
13+
npx lerna publish prepatch \
14+
--registry http://localhost:4873/ \
15+
--yes \
16+
--no-changelog \
17+
--no-git-tag-version \
18+
--no-push \
19+
--no-git-reset \
20+
--ignore-scripts \
21+
--preid ci \
22+
--no-verify-access
23+
24+
# The above command will make some modifications,
25+
# Roll them back
26+
# Idealy, we would find a way to not have to do this
27+
git checkout -- modules/**/package-lock.json
28+
git checkout -- modules/**/package.json
29+
30+
# Kill everying
31+
# Especialy the background verdaccio server
32+
kill $(jobs -pr)

util/npx_verdaccio

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# I am assumeing that you used `local_verdaccio_publish`
4+
# But either way,
5+
# this is to facilitate running `npx`
6+
# and interacting with a local verdaccio server
7+
# So... I need a running server
8+
verdaccio -c verdaccio/config.yaml &
9+
10+
# run npx, and stuff an rc file that has _valid_ tokens
11+
# that match the local htpassword
12+
13+
npm_config_registry=http://localhost:4873/ npx \
14+
--userconfig verdaccio/npmrc \
15+
--ignore-existing \
16+
"$@"
17+
18+
# Kill everying
19+
# Especialy the background verdaccio server
20+
kill $(jobs -pr)

verdaccio/config.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#
2+
# This is the default config file. It allows all users to do anything,
3+
# so don't use it on production systems.
4+
#
5+
# Look here for more config file examples:
6+
# https://github.com/verdaccio/verdaccio/tree/master/conf
7+
#
8+
9+
# path to a directory with all packages
10+
storage: ./storage
11+
# path to a directory with plugins to include
12+
plugins: ./plugins
13+
14+
web:
15+
title: Verdaccio
16+
# comment out to disable gravatar support
17+
# gravatar: false
18+
# by default packages are ordercer ascendant (asc|desc)
19+
# sort_packages: asc
20+
21+
auth:
22+
htpasswd:
23+
file: ./htpasswd
24+
# Maximum amount of users allowed to register, defaults to "+inf".
25+
# You can set this to -1 to disable registration.
26+
# max_users: 1000
27+
28+
security:
29+
api:
30+
jwt:
31+
sign:
32+
expiresIn: 60d
33+
notBefore: 1
34+
web:
35+
sign:
36+
expiresIn: 7d
37+
notBefore: 1
38+
39+
# a list of other known repositories we can talk to
40+
uplinks:
41+
npmjs:
42+
url: https://registry.npmjs.org/
43+
44+
packages:
45+
'@aws-crypto/*':
46+
# scoped packages
47+
access: $all
48+
publish: $all
49+
unpublish: $all
50+
proxy: npmjs
51+
'@*/*':
52+
# scoped packages
53+
access: $all
54+
publish: $authenticated
55+
unpublish: $authenticated
56+
proxy: npmjs
57+
58+
'**':
59+
# allow all users (including non-authenticated users) to read and
60+
# publish all packages
61+
#
62+
# you can specify usernames/groupnames (depending on your auth plugin)
63+
# and three keywords: "$all", "$anonymous", "$authenticated"
64+
access: $all
65+
66+
# allow all known users to publish/publish packages
67+
# (anyone can register by default, remember?)
68+
publish: $authenticated
69+
unpublish: $authenticated
70+
71+
# if package is not available locally, proxy requests to 'npmjs' registry
72+
proxy: npmjs
73+
74+
# You can specify HTTP/1.1 server keep alive timeout in seconds for incomming connections.
75+
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
76+
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought.
77+
server:
78+
keepAliveTimeout: 60
79+
80+
middlewares:
81+
audit:
82+
enabled: true
83+
84+
# log settings
85+
logs:
86+
- { type: stdout, format: pretty, level: http }
87+
#- {type: file, path: verdaccio.log, level: info}
88+

verdaccio/htpasswd

Whitespace-only changes.

verdaccio/npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
loglevel=warn
2+
registry=http://localhost:4873/

0 commit comments

Comments
 (0)