Skip to content

Commit

Permalink
chore: add e2e/npm_translate_lock_auth e2e test for coverage of new .…
Browse files Browse the repository at this point in the history
…npmrc auth token feature (#500)
  • Loading branch information
gregmagolan authored Oct 7, 2022
1 parent 50d8841 commit 386610d
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
- 'e2e/npm_link_package-esm'
- 'e2e/pnpm_workspace'
- 'e2e/pnpm_workspace_rerooted'
- 'e2e/npm_translate_lock_auth'
- 'e2e/npm_translate_package_lock'
- 'e2e/npm_translate_yarn_lock'
- 'e2e/package_json_module'
Expand Down Expand Up @@ -81,7 +82,11 @@ jobs:
env:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
ASPECT_NPM_AUTH_TOKEN: ${{ secrets.ASPECT_NPM_AUTH_TOKEN }}
working-directory: ${{ matrix.folder }}
# Don't run e2e/npm_translate_lock_auth unless there is an auth token secret; this won't
# be set on forks
if: ${{ matrix.folder != 'e2e/npm_translate_lock_auth' || env.ASPECT_NPM_AUTH_TOKEN != ''}}
run: |
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc test --config=${{ matrix.config }} //...
ls $(bazel info output_base)/external | grep -v __links | grep -vz unused
Expand All @@ -90,6 +95,7 @@ jobs:
env:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
ASPECT_NPM_AUTH_TOKEN: ${{ secrets.ASPECT_NPM_AUTH_TOKEN }}
working-directory: ${{ matrix.folder }}
# Coverage does not work properly with RBE. See: bazelbuild/bazel#4685
if: ${{ matrix.config == 'local' }}
Expand Down
1 change: 1 addition & 0 deletions e2e/npm_translate_lock_auth/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
2 changes: 2 additions & 0 deletions e2e/npm_translate_lock_auth/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# import common bazelrc shared with e2e workspaces
import %workspace%/../../.bazelrc.common
1 change: 1 addition & 0 deletions e2e/npm_translate_lock_auth/.bazelversion
3 changes: 3 additions & 0 deletions e2e/npm_translate_lock_auth/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hoist=false
@aspect-priv-npm:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=${ASPECT_NPM_AUTH_TOKEN}
11 changes: 11 additions & 0 deletions e2e/npm_translate_lock_auth/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")

build_test(
name = "test",
targets = [
":node_modules",
],
)
6 changes: 6 additions & 0 deletions e2e/npm_translate_lock_auth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Npm auth integration test for npm_translate_lock

Auth token(s) are set in `.npmrc` to fetch packages from private registries.

npm auth token with permission to pull packages from `@aspect-priv-npm` scope must be set in
`ASPECT_NPM_AUTH_TOKEN` environment variable for this e2e test to pass.
29 changes: 29 additions & 0 deletions e2e/npm_translate_lock_auth/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local_repository(
name = "aspect_rules_js",
path = "../..",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")

nodejs_register_toolchains(
name = "nodejs",
node_version = DEFAULT_NODE_VERSION,
)

load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")

# Validate that we can use a yarn.lock file in place of pnpm-lock.yaml
npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)

load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()
6 changes: 6 additions & 0 deletions e2e/npm_translate_lock_auth/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"@aspect-priv-npm/a": "1.0.0"
}
}
16 changes: 16 additions & 0 deletions e2e/npm_translate_lock_auth/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions e2e/npm_translate_lock_auth/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- '.'

0 comments on commit 386610d

Please sign in to comment.