Skip to content

Commit

Permalink
test: add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Dec 30, 2023
1 parent 26f5918 commit 2d85857
Show file tree
Hide file tree
Showing 55 changed files with 3,126 additions and 413 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn build
- run: yarn test

e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
# Authentication credentials shouldn't be needed as we stub the Secret Manager
# API service during integration tests. However, even though the client is overridden
# with a new endpoint (see src/infrastructure/secrets.ts), the client still requires
# a filled out application default credentials file to be present in order to work.
- uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- uses: google-github-actions/setup-gcloud@v2
with:
version: ">= 363.0.0"
# Run `info` to set up default credentials
- run: yarn install --frozen-lockfile
- run: yarn e2e
19 changes: 19 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# e2e tests

The end-to-end tests use a combination of fake and real services.

Email notifications are sent to a semi-real service called [Ethereal](https://ethereal.email/) which `nodemailer` natively supports.

GitHub and Google Secrets Manager are faked.

Arguably GitHub should not be faked given how important it is to the functioning of the app, but using it presents several challenges:

- At least two new GitHub orgs need to be created and maintained by the Bazel SIG: an org containing test ruleset repos along with a bazel-central-registry clone, and an org containing a fake canonical bazel-central-registry. This creates additional maintenance burden.
- Real repositories are shared resources so there may be difficulties with multiple developers running tests simultaneously. Repos being restored to pristine states between test runs could cause conflicts.
- Testing the full functionality requires multiple GitHub user handles and thus requires multiple test accounts to be managed.

Run with:

```bash
yarn e2e
```
348 changes: 348 additions & 0 deletions e2e/__snapshots__/e2e.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,348 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`e2e tests [snapshot] empty strip prefix 1`] = `
"----------------------------------------------------
modules/no-prefix/1.0.0/MODULE.bazel
----------------------------------------------------
module(
name = \\"no-prefix\\",
version = \\"1.0.0\\",
)
----------------------------------------------------
modules/no-prefix/1.0.0/presubmit.yml
----------------------------------------------------
bcr_test_module:
module_path: \\"e2e/bzlmod\\"
matrix:
platform: [\\"debian10\\", \\"macos\\", \\"ubuntu2004\\", \\"windows\\"]
tasks:
run_tests:
name: \\"Run test module\\"
platform: \${{ platform }}
test_targets:
- \\"//...\\"
----------------------------------------------------
modules/no-prefix/1.0.0/source.json
----------------------------------------------------
{
\\"integrity\\": \\"sha256-C+/h1qGARuDojvPpWzmYG2DbGxno+auAp2AeVWDgHpI=\\",
\\"url\\": \\"https://github.com/testorg/no-prefix/archive/refs/tags/v1.0.0.tar.gz\\"
}
----------------------------------------------------
modules/no-prefix/metadata.json
----------------------------------------------------
{
\\"homepage\\": \\"https://github.com/testorg/no-prefix\\",
\\"maintainers\\": [
{
\\"name\\": \\"Foo McBar\\",
\\"email\\": \\"foo@test.org\\",
\\"github\\": \\"foobar\\"
}
],
\\"repository\\": [
\\"github:testorg/no-prefix\\"
],
\\"versions\\": [
\\"1.0.0\\"
],
\\"yanked_versions\\": {}
}
"
`;

exports[`e2e tests [snapshot] missing strip prefix 1`] = `
"----------------------------------------------------
modules/empty-prefix/1.0.0/MODULE.bazel
----------------------------------------------------
module(
name = \\"empty-prefix\\",
version = \\"1.0.0\\",
)
----------------------------------------------------
modules/empty-prefix/1.0.0/presubmit.yml
----------------------------------------------------
bcr_test_module:
module_path: \\"e2e/bzlmod\\"
matrix:
platform: [\\"debian10\\", \\"macos\\", \\"ubuntu2004\\", \\"windows\\"]
tasks:
run_tests:
name: \\"Run test module\\"
platform: \${{ platform }}
test_targets:
- \\"//...\\"
----------------------------------------------------
modules/empty-prefix/1.0.0/source.json
----------------------------------------------------
{
\\"integrity\\": \\"sha256-SZyzKXKklQTcm3nek6r6A6C+eU/hcJqbsIolv2cHNp0=\\",
\\"strip_prefix\\": \\"\\",
\\"url\\": \\"https://github.com/testorg/empty-prefix/archive/refs/tags/v1.0.0.tar.gz\\"
}
----------------------------------------------------
modules/empty-prefix/metadata.json
----------------------------------------------------
{
\\"homepage\\": \\"https://github.com/testorg/empty-prefix\\",
\\"maintainers\\": [
{
\\"name\\": \\"Foo McBar\\",
\\"email\\": \\"foo@test.org\\",
\\"github\\": \\"foobar\\"
}
],
\\"repository\\": [
\\"github:testorg/empty-prefix\\"
],
\\"versions\\": [
\\"1.0.0\\"
],
\\"yanked_versions\\": {}
}
"
`;

exports[`e2e tests [snapshot] ruleset with tarball release archive 1`] = `
"----------------------------------------------------
modules/tarball/1.0.0/MODULE.bazel
----------------------------------------------------
module(
name = \\"tarball\\",
version = \\"1.0.0\\",
)
----------------------------------------------------
modules/tarball/1.0.0/presubmit.yml
----------------------------------------------------
bcr_test_module:
module_path: \\"e2e/bzlmod\\"
matrix:
platform: [\\"debian10\\", \\"macos\\", \\"ubuntu2004\\", \\"windows\\"]
tasks:
run_tests:
name: \\"Run test module\\"
platform: \${{ platform }}
test_targets:
- \\"//...\\"
----------------------------------------------------
modules/tarball/1.0.0/source.json
----------------------------------------------------
{
\\"integrity\\": \\"sha256-OSeDLWfRYlYyur+lXnrIys8CuAsVQ5axng+LpVHs3c4=\\",
\\"strip_prefix\\": \\"tarball-1.0.0\\",
\\"url\\": \\"https://github.com/testorg/tarball/archive/refs/tags/v1.0.0.tar.gz\\"
}
----------------------------------------------------
modules/tarball/metadata.json
----------------------------------------------------
{
\\"homepage\\": \\"https://github.com/testorg/tarball\\",
\\"maintainers\\": [
{
\\"name\\": \\"Foo McBar\\",
\\"email\\": \\"foo@test.org\\",
\\"github\\": \\"foobar\\"
}
],
\\"repository\\": [
\\"github:testorg/tarball\\"
],
\\"versions\\": [
\\"1.0.0\\"
],
\\"yanked_versions\\": {}
}
"
`;

exports[`e2e tests [snapshot] ruleset with unversioned module in source 1`] = `
"----------------------------------------------------
modules/unversioned/1.0.0/MODULE.bazel
----------------------------------------------------
module(
name = \\"unversioned\\",
version = \\"1.0.0\\",
)
----------------------------------------------------
modules/unversioned/1.0.0/patches/module_dot_bazel_version.patch
----------------------------------------------------
===================================================================
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,4 +1,4 @@
module(
name = \\"unversioned\\",
- version = \\"0.0.0\\",
+ version = \\"1.0.0\\",
)
\\\\ No newline at end of file
----------------------------------------------------
modules/unversioned/1.0.0/presubmit.yml
----------------------------------------------------
bcr_test_module:
module_path: \\"e2e/bzlmod\\"
matrix:
platform: [\\"debian10\\", \\"macos\\", \\"ubuntu2004\\", \\"windows\\"]
tasks:
run_tests:
name: \\"Run test module\\"
platform: \${{ platform }}
test_targets:
- \\"//...\\"
----------------------------------------------------
modules/unversioned/1.0.0/source.json
----------------------------------------------------
{
\\"integrity\\": \\"sha256-eXQOU+DNwg/Q29tX59jP0+SFLvRHrQf3z+KJVS/gIRk=\\",
\\"strip_prefix\\": \\"unversioned-1.0.0\\",
\\"url\\": \\"https://github.com/testorg/unversioned/archive/refs/tags/v1.0.0.tar.gz\\",
\\"patches\\": {
\\"module_dot_bazel_version.patch\\": \\"sha256-y0kC8heeH9bQKhrfx2JuX+RK0KyjwHhPac3wBc4Nkg4=\\"
},
\\"patch_strip\\": 1
}
----------------------------------------------------
modules/unversioned/metadata.json
----------------------------------------------------
{
\\"homepage\\": \\"https://github.com/testorg/unversioned\\",
\\"maintainers\\": [
{
\\"name\\": \\"Foo McBar\\",
\\"email\\": \\"foo@test.org\\",
\\"github\\": \\"foobar\\"
}
],
\\"repository\\": [
\\"github:testorg/unversioned\\"
],
\\"versions\\": [
\\"1.0.0\\"
],
\\"yanked_versions\\": {}
}
"
`;

exports[`e2e tests [snapshot] ruleset with versioned module in source 1`] = `
"----------------------------------------------------
modules/versioned/1.0.0/MODULE.bazel
----------------------------------------------------
module(
name = \\"versioned\\",
version = \\"1.0.0\\",
)
----------------------------------------------------
modules/versioned/1.0.0/presubmit.yml
----------------------------------------------------
bcr_test_module:
module_path: \\"e2e/bzlmod\\"
matrix:
platform: [\\"debian10\\", \\"macos\\", \\"ubuntu2004\\", \\"windows\\"]
tasks:
run_tests:
name: \\"Run test module\\"
platform: \${{ platform }}
test_targets:
- \\"//...\\"
----------------------------------------------------
modules/versioned/1.0.0/source.json
----------------------------------------------------
{
\\"integrity\\": \\"sha256-bQZY1F6G6wJWatGQeMeCh3OgsliTX4fazGsblBLV9jY=\\",
\\"strip_prefix\\": \\"versioned-1.0.0\\",
\\"url\\": \\"https://github.com/testorg/versioned/archive/refs/tags/v1.0.0.tar.gz\\"
}
----------------------------------------------------
modules/versioned/metadata.json
----------------------------------------------------
{
\\"homepage\\": \\"https://github.com/testorg/versioned\\",
\\"maintainers\\": [
{
\\"name\\": \\"Foo McBar\\",
\\"email\\": \\"foo@test.org\\",
\\"github\\": \\"foobar\\"
}
],
\\"repository\\": [
\\"github:testorg/versioned\\"
],
\\"versions\\": [
\\"1.0.0\\"
],
\\"yanked_versions\\": {}
}
"
`;

exports[`e2e tests [snapshot] ruleset with zip release archive 1`] = `
"----------------------------------------------------
modules/zip/1.0.0/MODULE.bazel
----------------------------------------------------
module(
name = \\"zip\\",
version = \\"1.0.0\\",
)
----------------------------------------------------
modules/zip/1.0.0/presubmit.yml
----------------------------------------------------
bcr_test_module:
module_path: \\"e2e/bzlmod\\"
matrix:
platform: [\\"debian10\\", \\"macos\\", \\"ubuntu2004\\", \\"windows\\"]
tasks:
run_tests:
name: \\"Run test module\\"
platform: \${{ platform }}
test_targets:
- \\"//...\\"
----------------------------------------------------
modules/zip/1.0.0/source.json
----------------------------------------------------
{
\\"integrity\\": \\"sha256-7qAmTBNY+y8DVPhj5nuzZFflX9tWa1h2OfuUMSUg6Hs=\\",
\\"strip_prefix\\": \\"zip-1.0.0\\",
\\"url\\": \\"https://github.com/testorg/zip/archive/refs/tags/v1.0.0.zip\\"
}
----------------------------------------------------
modules/zip/metadata.json
----------------------------------------------------
{
\\"homepage\\": \\"https://github.com/testorg/zip\\",
\\"maintainers\\": [
{
\\"name\\": \\"Foo McBar\\",
\\"email\\": \\"foo@test.org\\",
\\"github\\": \\"foobar\\"
}
],
\\"repository\\": [
\\"github:testorg/zip\\"
],
\\"versions\\": [
\\"1.0.0\\"
],
\\"yanked_versions\\": {}
}
"
`;
Loading

0 comments on commit 2d85857

Please sign in to comment.