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

Infra Pipeline: Modular Environment Setups #328

Merged
merged 105 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
dfd61d4
[WIP] New modular test environment working
namesty Apr 25, 2021
740da6e
Modular test-env config working with up and down commands
namesty Apr 25, 2021
9752bbe
v0.0.2
namesty May 1, 2021
59c0402
[WIP] Show Env Vars
namesty May 6, 2021
289935e
Testenv renamed to env. Build key in manifest working. Logic now in CLI
namesty May 10, 2021
6c24020
Deleted old test-env folder
namesty May 13, 2021
468ea42
Modularized code a bit better
namesty Jun 8, 2021
e1e051b
Merge branch 'prealpha-dev' into modular-testenv
namesty Jun 8, 2021
62c8614
Merge branch 'feature/reproducible-build-pipeline' into modular-testenv
namesty Jun 8, 2021
ebf1384
[WIP] improvements to CLI messaging
namesty Jun 10, 2021
d109ab4
Abstracted env code in its own EnvProject class
namesty Jun 11, 2021
77e70d4
[wip]: tests for vars and config passing. Needs to create "env" dir
namesty Jun 11, 2021
f187cae
Tests for all commands working. Missing wrong manifests error throwing
namesty Jun 12, 2021
f2fe69f
Tests passsing and default env working
namesty Jun 12, 2021
4224d23
Renamed EnvProject to ProjectEnv
namesty Jun 12, 2021
5405f5d
merge prealpha-dev
dOrgJelli Sep 18, 2021
45b3b62
add back appveyor.yaml
dOrgJelli Sep 18, 2021
513d86c
remove old web3api.env version number
dOrgJelli Sep 18, 2021
c741789
part way through refactor
dOrgJelli Sep 22, 2021
0af9415
init refactoring
dOrgJelli Nov 5, 2021
1fb5aa7
Merge branch 'prealpha-dev' into modular-testenv
namesty Apr 27, 2022
0186e4f
(wip): post merge fixes. Infra overhaul start
namesty Apr 28, 2022
e694a1c
(chore): package manager abstraction
namesty Apr 28, 2022
e77cdf9
(wip): added registry to infra package and separating pkgs per registry
namesty Apr 29, 2022
b045c40
(wip): simplified infra command, added missing functions post-merge
namesty Apr 29, 2022
e29e749
(chore): tweaked manifest to allow for local fs packages
namesty May 3, 2022
f6e721b
(chore): Filesystem fetcher. Moved infra stuff to its own dir
namesty May 3, 2022
38254b7
(chore): local modules resolution re-done. Renamed pkgs to modules
namesty May 4, 2022
51034d3
(chore): minor messaging fixing
namesty May 4, 2022
860c938
(feat): more durable and readable way of correcting build context paths
namesty May 4, 2022
43529d1
(chore): moved cache paths to project class
namesty May 4, 2022
7b56c9a
(chore): pathing and fs writing moved to project
namesty May 6, 2022
52a423b
(chore): infra class refactor
namesty May 7, 2022
8ddd77a
(chore): moved tests to test-cases dir. Improved CLI messaging
namesty May 7, 2022
6692707
(feat): test cases for dockerCompose prop and duplicates handling
namesty May 9, 2022
9c5aa5e
(chore): improved messaging. Removed fs from fetchers. Modules mandatory
namesty May 10, 2022
85b5edd
(fix): dont change build context path if already absolute
namesty May 10, 2022
3533d0a
(chore): removed infra packages dir
namesty May 10, 2022
8efd370
(chore): added test case for --test flag
namesty May 10, 2022
0ca1dc6
(chore): minor format fix
namesty May 10, 2022
884afb5
(fix): remove orphans flag added to down subcommand
namesty May 11, 2022
c889da4
(chore): restored test env temporarily
namesty May 11, 2022
f33470e
Merge branch 'prealpha-dev' into modular-testenv
namesty May 12, 2022
261c325
(fix): merge fixes
namesty May 12, 2022
c7b02fa
(chore): removed test-env command
namesty May 16, 2022
a9e9b1a
(chore): removed unused test cases
namesty May 16, 2022
111734b
(chore): fixed infra tests. Test environment startup. Docker lib used
namesty May 16, 2022
cadc6a1
(feat): presets added. Removed test env repo from monorepo
namesty May 17, 2022
e3e5753
(chore): dockerCompose encapsulation. Better lock handling
namesty May 17, 2022
8a684c7
(feat): updated dev server usage and deterministic ENS address
namesty May 19, 2022
e255897
(chore): minor fix on down command flag
namesty May 19, 2022
c5a7442
(feat): local dev ens publisher
namesty May 19, 2022
784ffa1
chore: update with prealpha-dev
cbrzn May 24, 2022
ec5deab
(chore): removed usages of test-env
namesty May 24, 2022
ceee9ab
(fix): Ethereum plugin test ens addresses fix
namesty May 24, 2022
4256ca3
(chore): updated test env query error message
namesty May 24, 2022
26dea84
chore: update with prealpha-dev
cbrzn May 30, 2022
857f064
chore(cli): infra command migrated to commander
cbrzn May 30, 2022
dce747c
test(cli): show help text in infra command fixed
cbrzn May 30, 2022
4667f6b
Merge branch 'prealpha-dev' into modular-testenv
dOrgJelli May 31, 2022
d90e04e
test(cli): updated with latest & test-cli/test-core scripts -almost- …
cbrzn May 31, 2022
cd9da32
fix conflicts
cbrzn May 31, 2022
249a8da
chore: update with latest changes
cbrzn May 31, 2022
c4ee955
(fix): fixed resolver not set for local dev ENS publisher package
namesty Jun 2, 2022
c4c07c8
chore: update with latest
cbrzn Jun 2, 2022
07002b4
Merge branch 'modular-testenv' of github.com:polywrap/monorepo into m…
cbrzn Jun 2, 2022
753def9
fix(cli/deploy): happy tests :)
cbrzn Jun 2, 2022
cab8006
merge prealpha-dev
dOrgJelli Jun 3, 2022
144b7e6
renaming + minor fixes
dOrgJelli Jun 4, 2022
c7d6498
(feat): local-dev-ens deploy module now registers names
namesty Jun 4, 2022
2874f3c
(chore): changed ens deploy module implementation to use client
namesty Jun 4, 2022
a9d544b
(chore): remove ethers and ensdomains/ensjs as cli deps
namesty Jun 4, 2022
de433b3
(chore): tests passing
namesty Jun 4, 2022
c6239aa
(fix): lint fixes
namesty Jun 4, 2022
55f1535
(fix): uncommented query tests
namesty Jun 4, 2022
b5e86e3
fix tests
dOrgJelli Jun 6, 2022
0834f25
(feat): deterministic ENS addresses
namesty Jun 7, 2022
a329a22
env improvements
dOrgJelli Jun 7, 2022
092fc22
Merge branch 'modular-testenv' of https://github.com/polywrap/monorep…
dOrgJelli Jun 7, 2022
57ec9d4
infra config output pretty yaml
dOrgJelli Jun 7, 2022
34a7eca
rename to base-docker-compose.yaml
dOrgJelli Jun 7, 2022
6ad57a1
(chore): renaming preset to defaults
namesty Jun 7, 2022
03ca135
CacheDirectory class refactor
dOrgJelli Jun 7, 2022
fd95c16
Remove infra's dependency on Web3ApiProject
dOrgJelli Jun 7, 2022
3e708e9
(fix): minor fix to copyfiles script
namesty Jun 7, 2022
bfd4b32
(feat): removed concept of preset options in favor of just --modules
namesty Jun 7, 2022
f88c455
(fix): updated error messages and tests
namesty Jun 7, 2022
c5b40c4
Merge remote-tracking branch 'origin/modular-testenv' into modular-te…
namesty Jun 7, 2022
b52a7a9
(fix): solved remaining merge conflicts
namesty Jun 7, 2022
cadf8ea
lint fixes
dOrgJelli Jun 7, 2022
0cfa399
(fix): fixed copyfiles script and CLI workspace
namesty Jun 7, 2022
34f28dd
(chore): changing preset syntax usages
namesty Jun 7, 2022
f250778
(fix): fixed infra tests and local module copying
namesty Jun 7, 2022
1f2c953
(chore): all tests passing
namesty Jun 7, 2022
f66c4c2
Merge remote-tracking branch 'origin/modular-testenv' into modular-te…
namesty Jun 7, 2022
895090c
(fix): deterministic testing provider ports and removal of devserver use
namesty Jun 7, 2022
890171c
(fix): ignore default dockerized infra modules linting
namesty Jun 7, 2022
c671f4b
preset -> defaults
dOrgJelli Jun 7, 2022
3a4ce27
minor test fixes
dOrgJelli Jun 7, 2022
267ac96
fix cli tests
dOrgJelli Jun 7, 2022
55ac7b9
lint fix
dOrgJelli Jun 7, 2022
5fbbcd1
fix tests
dOrgJelli Jun 7, 2022
d23bc83
fix deploy test
dOrgJelli Jun 7, 2022
b05c548
revert minor changes
dOrgJelli Jun 7, 2022
4e99974
fix deploy tests
dOrgJelli Jun 7, 2022
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
root: true,
ignorePatterns: [
"**/w3/**/*.*",
"**/infra-modules/**/*.*",
"**/build/**/*.*",
"**/__tests__/**/*.*",
"**/node_modules/**/*.*",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/js-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ jobs:

# NOTE: Mac & Windows CI is not currently possible, since GitHub Actions does not
# use "Docker Enterprise". Docker Enterprise is required when running linux based
# containers, which is what we run within our toolchain for test-envs and build-envs.
# containers, which is what we run within our toolchain for infra and build-images.
# In order to enable this, we can move to Circle CI, which supports Docker Enterprise.

# JS-CI-Mac:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rs-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ jobs:

# NOTE: Mac & Windows CI is not currently possible, since GitHub Actions does not
# use "Docker Enterprise". Docker Enterprise is required when running linux based
# containers, which is what we run within our toolchain for test-envs and build-envs.
# containers, which is what we run within our toolchain for infra and build-images.
# In order to enable this, we can move to Circle CI, which supports Docker Enterprise.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"workspaces": {
"packages": [
"./packages/apis/**",
"./packages/cli/**",
"./packages/cli",
"./packages/core-interfaces/**",
"./packages/js/**",
"./packages/manifest-schemas/**",
Expand Down
21 changes: 21 additions & 0 deletions packages/cli/copyfiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import fse from "fs-extra";

const source = process.argv[2];
const dest = process.argv[3];

const ignore = [
".env",
"node_modules",
".idea",
".log",
".vscode",
".w3",
".rs.bk",
".lock",
];

fse.copySync(source, dest, {
filter: function (path) {
return !ignore.some((ignorePath) => path.endsWith(ignorePath));
},
});
43 changes: 41 additions & 2 deletions packages/cli/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,44 @@
"commands_build_options_t": "Use the development server's ENS instance",
"commands_build_options_w": "Automatically rebuild when changes are made (default: false)",
"commands_build_options_v": "Verbose output (default: false)",
"commands_infra_description": "Manage infrastructure for your Web3API",
"commands_infra_actions_subtitle": "Infra allows you to execute the following commands:",
"commands_infra_options_options": "options",
"commands_infra_options_manifest": "manifest",
"commands_infra_options_i_node": "node",
"commands_infra_options_h": "Show usage information",
"commands_infra_options_m": "Use only specified modules",
"commands_infra_options_v": "Verbose output (default: false)",
"commands_infra_options_d": "Run in detached mode",
"commands_infra_moduleName": "module-name",
"commands_infra_manifestPath": "manifest-path",
"commands_infra_manifestPathDescription": "Infra Manifest path",
"commands_infra_command_up": "Start Web3API infrastructure",
"commands_infra_command_down": "Stop Web3API infrastructure",
"commands_infra_command_vars": "Show Web3API infrastructure's required .env variables",
"commands_infra_command_config": "Validate and display Web3API infrastructure's bundled docker-compose manifest",
"commands_infra_error_never": "This should never happen...",
"commands_infra_error_noCommand": "No command given",
"commands_infra_error_unrecognizedCommand": "Unrecognized command: {command}",
"commands_infra_error_noModulesMatch": "{modules} did not match any module names",
"commands_infra_error_noModulesDeclared": "No modules declared",
"commands_infra_modulesUsed_text": "Using infra modules",
"commands_infra_options_command": "command",
"commands_infra_options_start": "Startup the test env",
"commands_infra_options_stop": "Shutdown the test env",
"commands_infra_options_env_vars": "Show environment variables",
"commands_infra_shutdown_error": "Failed to shutdown test environment",
"commands_infra_shutdown_text": "Shutting down test environment...",
"commands_infra_shutdown_warning": "Warning shutting down test environment",
"commands_infra_startup_error": "Failed to start test environment",
"commands_infra_startup_text": "Starting test environment...",
"commands_infra_startup_warning": "Warning starting test environment",
"commands_infra_vars_text": "Extracting environment variables",
"commands_infra_vars_warning": "Warning extracting environment variables",
"commands_infra_vars_error": "Error extracting environment variables",
"commands_infra_manifest_text": "Aggregating manifest",
"commands_infra_manifest_warning": "Warning aggregating manifest",
"commands_infra_manifest_error": "Error aggregating manifest",
"commands_build_uriViewers": "URI Viewers",
"commands_deploy_description": "Deploys/Publishes a Web3API",
"commands_deploy_options_options": "options",
Expand Down Expand Up @@ -140,7 +178,7 @@
"commands_query_error_noApi": "API needs to be initialized",
"commands_query_error_readFail": "Failed to read query {query}",
"commands_query_error_noRecipeScriptFound": "Recipe script not found at path: {path}",
"commands_query_error_noTestEnvFound": "w3 test-env not found, please run 'w3 test-env up'",
"commands_query_error_noTestEnvFound": "w3 test-env not found, please run 'w3 infra up --modules=eth-ens-ipfs'",
"commands_testEnv_description": "Manage a test environment for Web3API",
"commands_testEnv_error_never": "This should never happen...",
"commands_testEnv_error_noCommand": "No command given",
Expand Down Expand Up @@ -226,5 +264,6 @@
"lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}",
"lib_wasm_rust_invalidModule": "Module paths must point to Cargo.toml files. Found: {path}",
"lib_docker_invalidImageId": "Invalid docker image ID returned: {imageId}",
"lib_docker_noInstall": "Docker executable not found in PATH"
"lib_docker_noInstall": "Docker executable not found in PATH",
"lib_infra_unrecognizedModule": "Unrecognized modules: {modules}. Default modules: {defaultModules}"
}
43 changes: 41 additions & 2 deletions packages/cli/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,44 @@
"commands_build_options_w": "Automatically rebuild when changes are made (default: false)",
"commands_build_options_v": "Verbose output (default: false)",
"commands_build_uriViewers": "URI Viewers",
"commands_infra_description": "Manage infrastructure for your Web3API",
"commands_infra_actions_subtitle": "Infra allows you to execute the following commands:",
"commands_infra_options_options": "options",
"commands_infra_options_manifest": "manifest",
"commands_infra_options_i_node": "node",
"commands_infra_options_h": "Show usage information",
"commands_infra_options_m": "Use only specified modules",
"commands_infra_options_v": "Verbose output (default: false)",
"commands_infra_options_d": "Run in detached mode",
"commands_infra_moduleName": "module-name",
"commands_infra_manifestPath": "manifest-path",
"commands_infra_manifestPathDescription": "Infra Manifest path",
"commands_infra_command_up": "Start Web3API infrastructure",
"commands_infra_command_down": "Stop Web3API infrastructure",
"commands_infra_command_vars": "Show Web3API infrastructure's required .env variables",
"commands_infra_command_config": "Validate and display Web3API infrastructure's bundled docker-compose manifest",
"commands_infra_error_never": "This should never happen...",
"commands_infra_error_noCommand": "No command given",
"commands_infra_error_unrecognizedCommand": "Unrecognized command: {command}",
"commands_infra_error_noModulesMatch": "{modules} did not match any module names",
"commands_infra_error_noModulesDeclared": "No modules declared",
"commands_infra_modulesUsed_text": "Using infra modules",
"commands_infra_options_command": "command",
"commands_infra_options_start": "Startup the test env",
"commands_infra_options_stop": "Shutdown the test env",
"commands_infra_options_env_vars": "Show environment variables",
"commands_infra_shutdown_error": "Failed to shutdown test environment",
"commands_infra_shutdown_text": "Shutting down test environment...",
"commands_infra_shutdown_warning": "Warning shutting down test environment",
"commands_infra_startup_error": "Failed to start test environment",
"commands_infra_startup_text": "Starting test environment...",
"commands_infra_startup_warning": "Warning starting test environment",
"commands_infra_vars_text": "Extracting environment variables",
"commands_infra_vars_warning": "Warning extracting environment variables",
"commands_infra_vars_error": "Error extracting environment variables",
"commands_infra_manifest_text": "Aggregating manifest",
"commands_infra_manifest_warning": "Warning aggregating manifest",
"commands_infra_manifest_error": "Error aggregating manifest",
"commands_deploy_description": "Deploys/Publishes a Web3API",
"commands_deploy_options_options": "options",
"commands_deploy_options_o_path": "path",
Expand Down Expand Up @@ -141,7 +179,7 @@
"commands_query_error_noApi": "API needs to be initialized",
"commands_query_error_readFail": "Failed to read query {query}",
"commands_query_error_noRecipeScriptFound": "Recipe script not found at path: {path}",
"commands_query_error_noTestEnvFound": "w3 test-env not found, please run 'w3 test-env up'",
"commands_query_error_noTestEnvFound": "w3 test-env not found, please run 'w3 infra up --modules=eth-ens-ipfs'",
"commands_testEnv_description": "Manage a test environment for Web3API",
"commands_testEnv_error_never": "This should never happen...",
"commands_testEnv_error_noCommand": "No command given",
Expand Down Expand Up @@ -227,5 +265,6 @@
"lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}",
"lib_wasm_rust_invalidModule": "Module paths must point to Cargo.toml files. Found: {path}",
"lib_docker_invalidImageId": "Invalid docker image ID returned: {imageId}",
"lib_docker_noInstall": "Docker executable not found in PATH"
"lib_docker_noInstall": "Docker executable not found in PATH",
"lib_infra_unrecognizedModule": "Unrecognized modules: {modules}. Default modules: {defaultModules}"
}
17 changes: 9 additions & 8 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"w3": "bin/w3"
},
"scripts": {
"build": "rimraf ./build && tsc --project tsconfig.build.json && yarn build:envs && yarn build:deployers",
"build:envs": "copyfiles ./src/lib/build-envs/**/**/* ./build/lib/build-envs/ -u 3",
"build:deployers": "copyfiles ./src/lib/deployers/**/web3api.deploy.ext.json ./build/lib/deployers -u 3",
"build": "rimraf ./build && tsc --project tsconfig.build.json && yarn build:build-images && yarn build:deploy-modules && yarn build:infra-modules",
"build:build-images": "copyfiles ./src/lib/defaults/build-images/**/**/* ./build/lib/defaults/build-images/ -u 4",
"build:deploy-modules": "copyfiles ./src/lib/defaults/deploy-modules/**/web3api.deploy.ext.json ./build/lib/defaults/deploy-modules -u 4",
"build:infra-modules": "ts-node ./copyfiles ./src/lib/defaults/infra-modules ./build/lib/defaults/infra-modules",
"prebuild": "ts-node ./scripts/generateIntlTypes.ts",
"build:fast": "rimraf ./build && tsc --project tsconfig.build.json && yarn build:envs",
"build:fast": "rimraf ./build && tsc --project tsconfig.build.json",
"lint": "eslint --color -c ../../.eslintrc.js .",
"test": "cross-env TEST=true jest --passWithNoTests --runInBand --verbose",
"test:ci": "cross-env TEST=true jest --passWithNoTests --runInBand --verbose",
Expand All @@ -30,11 +31,11 @@
"colors": "1.4.0"
},
"dependencies": {
"@ensdomains/ensjs": "2.0.1",
"@formatjs/intl": "1.8.2",
"@ethersproject/wallet": "5.6.2",
"@ethersproject/providers": "5.6.8",
"@web3api/asyncify-js": "0.0.1-prealpha.83",
"@web3api/client-js": "0.0.1-prealpha.83",
"@web3api/client-test-env": "0.0.1-prealpha.83",
"@web3api/core-js": "0.0.1-prealpha.83",
"@web3api/ens-plugin-js": "0.0.1-prealpha.83",
"@web3api/ethereum-plugin-js": "0.0.1-prealpha.83",
Expand All @@ -43,18 +44,19 @@
"@web3api/schema-bind": "0.0.1-prealpha.83",
"@web3api/schema-compose": "0.0.1-prealpha.83",
"@web3api/schema-parse": "0.0.1-prealpha.83",
"@web3api/test-env-js": "0.0.1-prealpha.83",
"assemblyscript": "0.19.1",
"axios": "0.21.2",
"chalk": "4.1.0",
"chokidar": "3.5.1",
"commander": "9.2.0",
"content-hash": "2.5.2",
"copyfiles": "2.4.1",
"ethers": "5.0.7",
"fs-extra": "9.0.1",
"gluegun": "4.6.1",
"graphql-tag": "2.11.0",
"ipfs-http-client": "48.1.3",
"docker-compose": "0.23.17",
"js-yaml": "3.14.0",
"jsonschema": "1.4.0",
"mustache": "4.0.1",
Expand All @@ -72,7 +74,6 @@
"@types/node": "12.12.26",
"@types/prettier": "2.6.0",
"@types/rimraf": "3.0.0",
"@web3api/test-env-js": "0.0.1-prealpha.83",
"cross-env": "7.0.3",
"dir-compare": "3.3.0",
"eslint-plugin-formatjs": "2.12.7",
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/__tests__/e2e/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ describe("e2e tests for build command", () => {
expect(output).toBe("")
});

test("Adds uuid-v4 suffix to build-env image if no build manifest specified", async () => {
test("Adds uuid-v4 suffix to build image if no build manifest specified", async () => {
const projectRoot = getTestCaseDir(0);
const project = new Web3ApiProject({
rootCacheDir: projectRoot,
rootDir: projectRoot,
web3apiManifestPath: path.join(projectRoot, "web3api.yaml")
});

await project.cacheDefaultBuildManifestFiles();
await project.cacheDefaultBuildImage();

const cacheBuildEnvPath = path.join(projectRoot, ".w3/web3api/build/env")
const cacheBuildEnvPath = path.join(projectRoot, ".w3/web3api/build/image")
const cachedBuildManifest = await loadBuildManifest(
path.join(cacheBuildEnvPath, "web3api.build.yaml")
);
Expand Down
41 changes: 22 additions & 19 deletions packages/cli/src/__tests__/e2e/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import {
initTestEnvironment,
runCLI,
stopTestEnvironment,
ensAddresses,
providers
} from "@web3api/test-env-js";
import { GetPathToCliTestFiles } from "@web3api/test-cases";
import axios from "axios";
import { Web3ApiClient } from "@web3api/client-js";
import { ethereumPlugin } from "@web3api/ethereum-plugin-js";
import { Wallet } from "ethers";
import { Wallet } from "@ethersproject/wallet";
import path from "path";
import fs from "fs";

Expand All @@ -33,12 +34,12 @@ const testCaseRoot = path.join(GetPathToCliTestFiles(), "api/deploy");
path.join(testCaseRoot, testCases[index]);

const setup = async (domainNames: string[]) => {
const { ethereum } = await initTestEnvironment();
const { data } = await axios.get("http://localhost:4040/deploy-ens");
await stopTestEnvironment();
await initTestEnvironment();

const ensAddress = data.ensAddress
const resolverAddress = data.resolverAddress
const registrarAddress = data.registrarAddress
const ensAddress = ensAddresses.ensAddress
const resolverAddress = ensAddresses.resolverAddress
const registrarAddress = ensAddresses.registrarAddress
const signer = new Wallet("0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d");

// Setup environment variables
Expand All @@ -49,15 +50,14 @@ const setup = async (domainNames: string[]) => {
};

const ethereumPluginUri = "w3://ens/ethereum.web3api.eth"

const client = new Web3ApiClient({
plugins: [
{
uri: ethereumPluginUri,
plugin: ethereumPlugin({
networks: {
testnet: {
provider: ethereum,
provider: providers.ethereum,
signer
}
},
Expand All @@ -73,7 +73,7 @@ const setup = async (domainNames: string[]) => {
)}`;

for await (const domainName of domainNames) {
await client.invoke<{ hash: string }>({
const result = await client.invoke({
uri: ensWrapperUri,
module: "mutation",
method: "registerDomainAndSubdomainsRecursively",
Expand All @@ -88,7 +88,13 @@ const setup = async (domainNames: string[]) => {
networkNameOrChainId: "testnet",
},
},
})
});

if (result.error) {
throw Error(
`Failed to register ${domainName}: ${result.error.message}`
);
}
}
}

Expand All @@ -105,11 +111,13 @@ describe("e2e tests for deploy command", () => {
},
);
}

await new Promise((resolve) => setTimeout(resolve, 5000));
});

afterAll(async () => {
await stopTestEnvironment();
})
});

test("Should show help text", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
Expand All @@ -126,7 +134,7 @@ describe("e2e tests for deploy command", () => {
});

test("Successfully deploys the project", async () => {
const { exitCode: code, stdout: output } = await runCLI(
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["deploy"],
cwd: getTestCaseDir(0),
Expand All @@ -137,19 +145,14 @@ describe("e2e tests for deploy command", () => {

const sanitizedOutput = clearStyle(output);

expect(error).toBeFalsy();
expect(code).toEqual(0);
expect(sanitizedOutput).toContain(
"Successfully executed stage 'ipfs_deploy'"
);
expect(sanitizedOutput).toContain(
"Successfully executed stage 'from_deploy'"
);
expect(sanitizedOutput).toContain(
"Successfully executed stage 'from_deploy2'"
);
expect(sanitizedOutput).toContain(
"Successfully executed stage 'from_uri'"
);
});

test("Should show warning if no manifest ext is found in deploy package", async () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/__tests__/e2e/help.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { clearStyle, w3Cli } from "./utils";

import { runCLI } from "@web3api/test-env-js";


const HELP = `Usage: w3 [options] [command]

Options:
Expand All @@ -15,7 +16,7 @@ Commands:
deploy|d [options] Deploys/Publishes a Web3API
plugin|p Build/generate types for the plugin
query|q [options] <recipe> Query Web3APIs using recipe scripts
test-env|t Manage a test environment for Web3API
infra|i [options] <action> Manage infrastructure for your Web3API
help [command] display help for command
`;

Expand Down
Loading