From db550971c0c4ab30009535e06f74ab4f91a5bf78 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 21 Apr 2023 17:48:26 +0900 Subject: [PATCH] admin: adding initial environment tests --- .github/workflows/test-env.yml | 44 +++++++++++++++++++ testcases/test-env/.gitignore | 2 + .../test-env/ts-import-cjs-node16/.gitignore | 2 + .../test-env/ts-import-cjs-node16/index.ts | 5 +++ .../ts-import-cjs-node16/package.json | 19 ++++++++ .../ts-import-cjs-node16/tsconfig.json | 19 ++++++++ testcases/test-env/ts-import-cjs/.gitignore | 2 + testcases/test-env/ts-import-cjs/index.ts | 5 +++ testcases/test-env/ts-import-cjs/package.json | 19 ++++++++ .../test-env/ts-import-cjs/tsconfig.json | 19 ++++++++ .../test-env/ts-import-esm-node16/.gitignore | 2 + .../test-env/ts-import-esm-node16/index.ts | 5 +++ .../ts-import-esm-node16/package.json | 28 ++++++++++++ .../ts-import-esm-node16/tsconfig.json | 19 ++++++++ testcases/test-env/ts-import-esm/.gitignore | 2 + testcases/test-env/ts-import-esm/index.ts | 5 +++ testcases/test-env/ts-import-esm/package.json | 28 ++++++++++++ .../test-env/ts-import-esm/tsconfig.json | 19 ++++++++ 18 files changed, 244 insertions(+) create mode 100644 .github/workflows/test-env.yml create mode 100644 testcases/test-env/.gitignore create mode 100644 testcases/test-env/ts-import-cjs-node16/.gitignore create mode 100644 testcases/test-env/ts-import-cjs-node16/index.ts create mode 100644 testcases/test-env/ts-import-cjs-node16/package.json create mode 100644 testcases/test-env/ts-import-cjs-node16/tsconfig.json create mode 100644 testcases/test-env/ts-import-cjs/.gitignore create mode 100644 testcases/test-env/ts-import-cjs/index.ts create mode 100644 testcases/test-env/ts-import-cjs/package.json create mode 100644 testcases/test-env/ts-import-cjs/tsconfig.json create mode 100644 testcases/test-env/ts-import-esm-node16/.gitignore create mode 100644 testcases/test-env/ts-import-esm-node16/index.ts create mode 100644 testcases/test-env/ts-import-esm-node16/package.json create mode 100644 testcases/test-env/ts-import-esm-node16/tsconfig.json create mode 100644 testcases/test-env/ts-import-esm/.gitignore create mode 100644 testcases/test-env/ts-import-esm/index.ts create mode 100644 testcases/test-env/ts-import-esm/package.json create mode 100644 testcases/test-env/ts-import-esm/tsconfig.json diff --git a/.github/workflows/test-env.yml b/.github/workflows/test-env.yml new file mode 100644 index 000000000..35a8940e5 --- /dev/null +++ b/.github/workflows/test-env.yml @@ -0,0 +1,44 @@ +name: Environment Tests + +on: + push: + branches: + - main + +jobs: + + test-env: + name: Test Environments + + runs-on: ubuntu-latest + + env: + npm_config_registry: http://localhost:8043 + + strategy: + fail-fast: false + matrix: + node-version: [ "ts-import-cjs-node16", "ts-import-esm-node16", "ts-import-cjs", "ts-import-esm" ] + + steps: + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: 18.x + + - name: Checkout repository + uses: actions/checkout@v3 + with: + path: "faux_modules/ethers" + + - name: Install and run Faux Registry + uses: ethers-io/hijack-npm-action + + - name: Copy tests to working directory + run: cp faux-npm/ethers/testcases/test-env/${{ matrix.test }}/* . + + - name: Install packages + run: npm install + + - name: Run tests + run: npm test diff --git a/testcases/test-env/.gitignore b/testcases/test-env/.gitignore new file mode 100644 index 000000000..f8159af09 --- /dev/null +++ b/testcases/test-env/.gitignore @@ -0,0 +1,2 @@ +*/node_modules/** +*/pacakge-lock.json diff --git a/testcases/test-env/ts-import-cjs-node16/.gitignore b/testcases/test-env/ts-import-cjs-node16/.gitignore new file mode 100644 index 000000000..a358b8e00 --- /dev/null +++ b/testcases/test-env/ts-import-cjs-node16/.gitignore @@ -0,0 +1,2 @@ +index.d.ts +index.js diff --git a/testcases/test-env/ts-import-cjs-node16/index.ts b/testcases/test-env/ts-import-cjs-node16/index.ts new file mode 100644 index 000000000..9c33b08f0 --- /dev/null +++ b/testcases/test-env/ts-import-cjs-node16/index.ts @@ -0,0 +1,5 @@ +import { ethers } from "ethers"; + +console.log("Version:", ethers.version); + +console.log(ethers.getAddress("0x0123456789abcdef0123456789abcdef01234567")); diff --git a/testcases/test-env/ts-import-cjs-node16/package.json b/testcases/test-env/ts-import-cjs-node16/package.json new file mode 100644 index 000000000..74876a303 --- /dev/null +++ b/testcases/test-env/ts-import-cjs-node16/package.json @@ -0,0 +1,19 @@ +{ + "name": "test", + "dependencies": { + "ethers": "^6.0.0" + }, + "devDependencies": { + "typescript": "^5.0.0" + }, + "version": "0.0.1", + "description": "Test case for simple import for ethers.", + "main": "index.js", + "private": true, + "publishConfig": { "access": "private" }, + "scripts": { + "build": "tsc --project tsconfig.json", + "test": "npm run build && node index.js" + }, + "license": "MIT" +} diff --git a/testcases/test-env/ts-import-cjs-node16/tsconfig.json b/testcases/test-env/ts-import-cjs-node16/tsconfig.json new file mode 100644 index 000000000..1ec02a581 --- /dev/null +++ b/testcases/test-env/ts-import-cjs-node16/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "declaration": true, + "importHelpers": false, + "lib": [ + "dom", + "es2020", + "es5" + ], + "module": "es2020", + "moduleResolution": "node16", + "strict": true, + "target": "es2022" + }, + "exclude": [ ], + "include": [ + "./index.ts" + ], +} diff --git a/testcases/test-env/ts-import-cjs/.gitignore b/testcases/test-env/ts-import-cjs/.gitignore new file mode 100644 index 000000000..a358b8e00 --- /dev/null +++ b/testcases/test-env/ts-import-cjs/.gitignore @@ -0,0 +1,2 @@ +index.d.ts +index.js diff --git a/testcases/test-env/ts-import-cjs/index.ts b/testcases/test-env/ts-import-cjs/index.ts new file mode 100644 index 000000000..9c33b08f0 --- /dev/null +++ b/testcases/test-env/ts-import-cjs/index.ts @@ -0,0 +1,5 @@ +import { ethers } from "ethers"; + +console.log("Version:", ethers.version); + +console.log(ethers.getAddress("0x0123456789abcdef0123456789abcdef01234567")); diff --git a/testcases/test-env/ts-import-cjs/package.json b/testcases/test-env/ts-import-cjs/package.json new file mode 100644 index 000000000..74876a303 --- /dev/null +++ b/testcases/test-env/ts-import-cjs/package.json @@ -0,0 +1,19 @@ +{ + "name": "test", + "dependencies": { + "ethers": "^6.0.0" + }, + "devDependencies": { + "typescript": "^5.0.0" + }, + "version": "0.0.1", + "description": "Test case for simple import for ethers.", + "main": "index.js", + "private": true, + "publishConfig": { "access": "private" }, + "scripts": { + "build": "tsc --project tsconfig.json", + "test": "npm run build && node index.js" + }, + "license": "MIT" +} diff --git a/testcases/test-env/ts-import-cjs/tsconfig.json b/testcases/test-env/ts-import-cjs/tsconfig.json new file mode 100644 index 000000000..cf90c7550 --- /dev/null +++ b/testcases/test-env/ts-import-cjs/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "declaration": true, + "importHelpers": false, + "lib": [ + "dom", + "es2020", + "es5" + ], + "module": "es2020", + "moduleResolution": "node", + "strict": true, + "target": "es2022" + }, + "exclude": [ ], + "include": [ + "./index.ts" + ], +} diff --git a/testcases/test-env/ts-import-esm-node16/.gitignore b/testcases/test-env/ts-import-esm-node16/.gitignore new file mode 100644 index 000000000..a358b8e00 --- /dev/null +++ b/testcases/test-env/ts-import-esm-node16/.gitignore @@ -0,0 +1,2 @@ +index.d.ts +index.js diff --git a/testcases/test-env/ts-import-esm-node16/index.ts b/testcases/test-env/ts-import-esm-node16/index.ts new file mode 100644 index 000000000..9c33b08f0 --- /dev/null +++ b/testcases/test-env/ts-import-esm-node16/index.ts @@ -0,0 +1,5 @@ +import { ethers } from "ethers"; + +console.log("Version:", ethers.version); + +console.log(ethers.getAddress("0x0123456789abcdef0123456789abcdef01234567")); diff --git a/testcases/test-env/ts-import-esm-node16/package.json b/testcases/test-env/ts-import-esm-node16/package.json new file mode 100644 index 000000000..a6968c744 --- /dev/null +++ b/testcases/test-env/ts-import-esm-node16/package.json @@ -0,0 +1,28 @@ +{ + "name": "test", + "dependencies": { + "ethers": "^6.0.0" + }, + "devDependencies": { + "typescript": "^5.0.0" + }, + "version": "0.0.1", + "description": "Test case for simple import for ethers.", + "main": "index.js", + "private": true, + "publishConfig": { + "access": "private" + }, + "type": "module", + "scripts": { + "build": "tsc --project tsconfig.json", + "test": "npm run build && node index.js" + }, + "keywords": [ + "ethers", + "tests", + "typescipt" + ], + "author": "Richard Moore ", + "license": "MIT" +} diff --git a/testcases/test-env/ts-import-esm-node16/tsconfig.json b/testcases/test-env/ts-import-esm-node16/tsconfig.json new file mode 100644 index 000000000..1ec02a581 --- /dev/null +++ b/testcases/test-env/ts-import-esm-node16/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "declaration": true, + "importHelpers": false, + "lib": [ + "dom", + "es2020", + "es5" + ], + "module": "es2020", + "moduleResolution": "node16", + "strict": true, + "target": "es2022" + }, + "exclude": [ ], + "include": [ + "./index.ts" + ], +} diff --git a/testcases/test-env/ts-import-esm/.gitignore b/testcases/test-env/ts-import-esm/.gitignore new file mode 100644 index 000000000..a358b8e00 --- /dev/null +++ b/testcases/test-env/ts-import-esm/.gitignore @@ -0,0 +1,2 @@ +index.d.ts +index.js diff --git a/testcases/test-env/ts-import-esm/index.ts b/testcases/test-env/ts-import-esm/index.ts new file mode 100644 index 000000000..9c33b08f0 --- /dev/null +++ b/testcases/test-env/ts-import-esm/index.ts @@ -0,0 +1,5 @@ +import { ethers } from "ethers"; + +console.log("Version:", ethers.version); + +console.log(ethers.getAddress("0x0123456789abcdef0123456789abcdef01234567")); diff --git a/testcases/test-env/ts-import-esm/package.json b/testcases/test-env/ts-import-esm/package.json new file mode 100644 index 000000000..a6968c744 --- /dev/null +++ b/testcases/test-env/ts-import-esm/package.json @@ -0,0 +1,28 @@ +{ + "name": "test", + "dependencies": { + "ethers": "^6.0.0" + }, + "devDependencies": { + "typescript": "^5.0.0" + }, + "version": "0.0.1", + "description": "Test case for simple import for ethers.", + "main": "index.js", + "private": true, + "publishConfig": { + "access": "private" + }, + "type": "module", + "scripts": { + "build": "tsc --project tsconfig.json", + "test": "npm run build && node index.js" + }, + "keywords": [ + "ethers", + "tests", + "typescipt" + ], + "author": "Richard Moore ", + "license": "MIT" +} diff --git a/testcases/test-env/ts-import-esm/tsconfig.json b/testcases/test-env/ts-import-esm/tsconfig.json new file mode 100644 index 000000000..cf90c7550 --- /dev/null +++ b/testcases/test-env/ts-import-esm/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "declaration": true, + "importHelpers": false, + "lib": [ + "dom", + "es2020", + "es5" + ], + "module": "es2020", + "moduleResolution": "node", + "strict": true, + "target": "es2022" + }, + "exclude": [ ], + "include": [ + "./index.ts" + ], +}