Skip to content

Commit a1c4675

Browse files
authored
Run CI on Windows (#494)
* Rewrite post-build to TS and run CI on Windows * Rewrite compile-contracts.sh to TypeScript * Prefix cli.js calls with Node to make tests work on Windows * Fix 'yarn ENOENT' on Windows * Change truffle.js to truffle-config.js * Change placeholder script from 'true' which fails on Windows to 'echo ok' * Increase ethers DataTypesInput test timeout * Make TypeChain CLI more permissive when parsing files glob * Update packages/typechain/src/cli/cli.ts * Improve error message * Fix contracts dir path in compile-contracts.ts * Reset process.cwd before calling readdir in hardhat test * Don't run yarn format check on Windows * Generate missing ERC20 * Fix ci.yml * Set global Mocha timeout to 5000ms * Remove redundant shebang
1 parent c93a1e7 commit a1c4675

File tree

21 files changed

+126
-55
lines changed

21 files changed

+126
-55
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
node: ['12.x']
14-
os: [ubuntu-latest]
15-
runs-on: ${{ matrix.os }}
14+
runs-on: ubuntu-latest
1615

1716
steps:
1817
- uses: actions/checkout@v1
@@ -37,9 +36,11 @@ jobs:
3736

3837
test:
3938
strategy:
39+
# When set to true, GitHub cancels all in-progress jobs if any matrix job fails.
40+
fail-fast: false
4041
matrix:
4142
node: ['12.x']
42-
os: [ubuntu-latest]
43+
os: [ubuntu-latest, windows-latest]
4344
runs-on: ${{ matrix.os }}
4445

4546
steps:
@@ -62,14 +63,19 @@ jobs:
6263
- run: yarn build
6364
- run: yarn test
6465
- run: yarn format # do it at the very end because "yarn test" can generate types (which should be formatted)
66+
if: runner.os == 'Linux'
67+
- run: yarn format:fix
68+
if: runner.os == 'Windows'
6569
- run: yarn typecheck # this has to happen after yarn test b/c test does type generation
6670
- run: yarn no-git-changes # ensure that committed types are up to date
6771

6872
test-examples:
6973
strategy:
74+
# When set to true, GitHub cancels all in-progress jobs if any matrix job fails.
75+
fail-fast: false
7076
matrix:
7177
node: ['12.x']
72-
os: [ubuntu-latest]
78+
os: [ubuntu-latest, windows-latest]
7379
runs-on: ${{ matrix.os }}
7480

7581
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ examples/hardhat-truffe-v5/typechain
2525
packages/hardhat/test/fixture-projects/hardhat-project/contracts/TestContract2.sol
2626
packages/hardhat-test/cache
2727
packages/hardhat-test/artifacts
28+
yarn-error.log

.mocharc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ module.exports = {
55
extension: ['ts'],
66
watchExtensions: ['ts'],
77
spec: ['test/**/*.test.ts'],
8+
timeout: 5000,
89
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build": "tsc --build --verbose ./tsconfig.prod.json && wsrun -m -c post-build",
2121
"watch": "tsc --build --verbose --watch ./tsconfig.prod.json",
2222
"clean": "wsrun -c clean",
23-
"compile-contracts": "./scripts/compile-contracts/compile-contracts.sh && wsrun -m -c compile-contracts",
23+
"compile-contracts": "ts-node ./scripts/compile-contracts && wsrun -m -c compile-contracts",
2424
"test": "yarn compile-contracts && wsrun -mse -c test",
2525
"test:fix": "yarn lint:fix && yarn test && yarn format:fix && yarn typecheck",
2626
"no-git-changes": "./scripts/no-git-changes.sh",

packages/hardhat-test/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"scripts": {
77
"format": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --check \"./**/*.ts\"",
88
"format:fix": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --write \"./**/*.ts\"",
9-
"lint": "true",
10-
"lint:fix": "true",
9+
"lint": "echo ok",
10+
"lint:fix": "echo ok",
1111
"typecheck": "tsc --noEmit --incremental false --composite false && tsc --noEmit --incremental false --composite false -p tsconfig.types.json",
1212
"clean": "hardhat clean && rm -f tsconfig.build.tsbuildinfo && rm -rf build",
1313
"generate-types": "hardhat clean && hardhat compile",

packages/hardhat/test/project.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ describe('Typechain x Hardhat', function () {
3434
it('compiles and generates typings when not in root directory', async function () {
3535
const exists = existsSync(this.hre.config.typechain.outDir)
3636
expect(exists).toEqual(false)
37+
3738
const oldCwd = process.cwd()
3839
// force change cwd to not-existing dir
3940
// cwd should not be used to determine output dir path
4041
process.cwd = () => join(oldCwd, 'src')
4142

4243
await this.hre.run('compile')
4344

45+
// fsPromises.readdir uses process.cwd on Windows
46+
process.cwd = originalCwd
47+
4448
const dir = await fsPromises.readdir(this.hre.config.typechain.outDir)
4549
expect(dir.length).not.toEqual(0)
4650
})

packages/target-ethers-v4-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint:fix": "yarn lint --fix",
1111
"typecheck": "tsc --noEmit --incremental false --composite false && tsc --noEmit --incremental false --composite false -p tsconfig.types.json",
1212
"clean": "rm -rf dist contracts/* && rm -f tsconfig.build.tsbuildinfo && rm -rf build",
13-
"generate-types": "../typechain/dist/cli/cli.js --target=`pwd`/../target-ethers-v4/dist/index.js --out-dir ./types/ '../../contracts/compiled/*.abi'",
13+
"generate-types": "node ../typechain/dist/cli/cli.js --target=../target-ethers-v4/dist/index.js --out-dir ./types/ '../../contracts/compiled/*.abi'",
1414
"test": "yarn generate-types && mocha --config ../../.mocharc.js",
1515
"test:fix": "yarn lint:fix && yarn format:fix && yarn test && yarn typecheck"
1616
},

packages/target-ethers-v5-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint:fix": "yarn lint --fix",
1111
"typecheck": "tsc --noEmit --incremental false --composite false && tsc --noEmit --incremental false --composite false -p tsconfig.types.json",
1212
"clean": "rm -rf dist contracts/* && rm -f tsconfig.build.tsbuildinfo && rm -rf build",
13-
"generate-types": "../typechain/dist/cli/cli.js --target=`pwd`/../target-ethers-v5/dist/index.js --out-dir ./types/ '../../contracts/compiled/*.abi'",
13+
"generate-types": "node ../typechain/dist/cli/cli.js --target=../target-ethers-v5/dist/index.js --out-dir ./types/ '../../contracts/compiled/*.abi'",
1414
"test": "yarn generate-types && mocha --config ../../.mocharc.js",
1515
"test:fix": "yarn lint:fix && yarn format:fix && yarn test && yarn typecheck"
1616
},

packages/target-truffle-v5-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"typecheck": "tsc --noEmit --incremental false --composite false && tsc --noEmit --incremental false --composite false -p tsconfig.types.json",
1212
"clean": "rm -rf dist contracts/* && rm -f tsconfig.build.tsbuildinfo && rm -rf build",
1313
"compile-contracts": "truffle compile",
14-
"generate-types": "../typechain/dist/cli/cli.js --target=`pwd`/../target-truffle-v5/dist/index.js './build/**/*.json'",
14+
"generate-types": "node ../typechain/dist/cli/cli.js --target=../target-truffle-v5/dist/index.js './build/**/*.json'",
1515
"test": "yarn generate-types && truffle test",
1616
"test:fix": "yarn lint:fix && yarn format:fix && yarn test && yarn typecheck"
1717
},
File renamed without changes.

0 commit comments

Comments
 (0)