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" + ], +}