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

Disable temp folder logic for hardhat >= 2.0.4 #581

Merged
merged 2 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"pify": "^4.0.1",
"recursive-readdir": "^2.2.2",
"sc-istanbul": "^0.4.5",
"semver": "^7.3.4",
"shelljs": "^0.8.3",
"web3-utils": "^1.3.0"
},
Expand All @@ -52,7 +53,7 @@
"@truffle/contract": "^4.0.36",
"buidler-gas-reporter": "^0.1.3",
"decache": "^4.5.1",
"hardhat": "^2.0.2",
"hardhat": "2.0.2",
"hardhat-gas-reporter": "^1.0.1",
"mocha": "5.2.0",
"nyc": "^14.1.1",
Expand Down
22 changes: 13 additions & 9 deletions plugins/hardhat.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,19 @@ task("coverage", "Generates a code coverage report for tests")

config.temp = args.temp;

const {
tempArtifactsDir,
tempContractsDir
} = utils.getTempLocations(config);

utils.setupTempFolders(config, tempContractsDir, tempArtifactsDir)

config.paths.artifacts = tempArtifactsDir;
config.paths.cache = nomiclabsUtils.tempCacheDir(config);
// With Hardhat >= 2.0.4, everything should automatically recompile
// after solidity-coverage corrupts the artifacts.
// Prior to that version, we (try to) save artifacts to a temp folder.
if (!config.useHardhatDefaultPaths){
const {
tempArtifactsDir,
tempContractsDir
} = utils.getTempLocations(config);

utils.setupTempFolders(config, tempContractsDir, tempArtifactsDir)
config.paths.artifacts = tempArtifactsDir;
config.paths.cache = nomiclabsUtils.tempCacheDir(config);
}

await env.run(TASK_COMPILE);

Expand Down
8 changes: 8 additions & 0 deletions plugins/resources/nomiclabs.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const globby = require('globby');
const pluginUtils = require("./plugin.utils");
const path = require('path');
const DataCollector = require("./../../lib/collector")
const semver = require("semver")
const util = require('util')

// =============================
Expand Down Expand Up @@ -37,6 +38,13 @@ function normalizeConfig(config, args={}){
config.solcoverjs = args.solcoverjs
config.gasReporter = { enabled: false }

try {
const hardhatPackage = require('hardhat/package.json');
if (semver.gt(hardhatPackage.version, '2.0.3')){
config.useHardhatDefaultPaths = true;
}
} catch(e){ /* ignore */ }

return config;
}

Expand Down
22 changes: 22 additions & 0 deletions scripts/run-nomiclabs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ npx hardhat coverage

verifyCoverageExists

echo ""
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "wighawag/hardhat-deploy "
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo ""
cd ..
npm install -g yarn
git clone https://github.com/cgewecke/template-ethereum-contracts.git
cd template-ethereum-contracts
yarn
yarn add $PR_PATH --dev
cat package.json

# Here we want to make sure that HH cache triggers a
# complete recompile after coverage runs by verifying
# that gas consumption is same in both runs.
yarn run gas
yarn run coverage
yarn run gas

verifyCoverageExists

# Install buidler-ethers
echo ""
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
Expand Down
18 changes: 17 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3139,7 +3139,7 @@ hardhat-gas-reporter@^1.0.1:
dependencies:
eth-gas-reporter "^0.2.19"

hardhat@^2.0.2:
hardhat@2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.0.2.tgz#30c3c5a49f950aad2e39c479208b4132052dc735"
dependencies:
Expand Down Expand Up @@ -3950,6 +3950,12 @@ lru-cache@^5.1.1:
dependencies:
yallist "^3.0.2"

lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
dependencies:
yallist "^4.0.0"

lru_map@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
Expand Down Expand Up @@ -5303,6 +5309,12 @@ semver@^6.0.0, semver@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"

semver@^7.3.4:
version "7.3.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
dependencies:
lru-cache "^6.0.0"

semver@~5.4.1:
version "5.4.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
Expand Down Expand Up @@ -6931,6 +6943,10 @@ yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9"

yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"

yargs-parser@13.1.2, yargs-parser@^13.1.2:
version "13.1.2"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38"
Expand Down