Skip to content

Commit 3e93e2b

Browse files
authored
fix(test): just testing (#204)
1 parent e48e673 commit 3e93e2b

File tree

10 files changed

+2465
-116
lines changed

10 files changed

+2465
-116
lines changed

.circleci/config.yml

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
version: 2
1+
version: 2.1
2+
3+
default_env: &default_env
4+
working_directory: ~/set-protocol-v2
5+
docker:
6+
- image: circleci/node:14.18
7+
environment:
8+
NODE_OPTIONS: --max_old_space_size=8192
9+
10+
commands:
11+
setup_job:
12+
steps:
13+
- restore_cache:
14+
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
215

316
jobs:
417
checkout_and_compile:
5-
docker:
6-
- image: circleci/node:12.16.0
7-
environment:
8-
NODE_OPTIONS: --max_old_space_size=8192
18+
<<: *default_env
919
resource_class: large
10-
working_directory: ~/set-protocol-v2
1120
steps:
1221
- checkout
1322
- restore_cache:
@@ -30,16 +39,10 @@ jobs:
3039
paths:
3140
- ~/set-protocol-v2
3241
test:
33-
docker:
34-
- image: circleci/node:12.16.0
35-
working_directory: ~/set-protocol-v2
42+
<<: *default_env
3643
parallelism: 3
3744
steps:
38-
- restore_cache:
39-
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
40-
- run:
41-
name: Set Up Environment Variables
42-
command: cp .env.default .env
45+
- setup_job
4346
- run:
4447
name: Test RPC
4548
command: yarn chain
@@ -51,35 +54,23 @@ jobs:
5154
yarn test ${TEST_FILES}
5255
5356
test_forked_network:
54-
docker:
55-
- image: circleci/node:12.16.0
56-
working_directory: ~/set-protocol-v2
57+
<<: *default_env
5758
steps:
58-
- restore_cache:
59-
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
60-
- run:
61-
name: Set Up Environment Variables
62-
command: cp .env.default .env
59+
- setup_job
6360
- run:
6461
name: Hardhat Test
6562
command: yarn test:fork
6663

6764
coverage:
68-
docker:
69-
- image: circleci/node:12.16.0
70-
working_directory: ~/set-protocol-v2
65+
<<: *default_env
7166
# When changing the parallelism value, you also
7267
# need to update the `persist_to_workspace` paths
7368
# in this job (below) as well as the list of files passed
7469
# to istanbul-combine in the `report_coverage` job
7570
parallelism: 5
7671
resource_class: medium+
7772
steps:
78-
- restore_cache:
79-
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
80-
- run:
81-
name: Set Up Environment Variables
82-
command: cp .env.default .env
73+
- setup_job
8374
- run:
8475
name: Create shared coverage outputs folder
8576
command: mkdir -p /tmp/coverage
@@ -104,14 +95,11 @@ jobs:
10495
- cov_4.json
10596

10697
report_coverage:
107-
docker:
108-
- image: circleci/node:12.16.0
109-
working_directory: ~/set-protocol-v2
98+
<<: *default_env
11099
steps:
100+
- setup_job
111101
- attach_workspace:
112102
at: /tmp/coverage
113-
- restore_cache:
114-
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
115103
- run:
116104
name: Combine coverage reports
117105
command: |
@@ -127,20 +115,45 @@ jobs:
127115
command: |
128116
cat coverage/lcov.info | node_modules/.bin/coveralls
129117
118+
release_latest:
119+
<<: *default_env
120+
steps:
121+
- setup_job
122+
- run:
123+
name: Publish "latest" release
124+
command: yarn publish:latest
125+
126+
release_hardhat:
127+
<<: *default_env
128+
steps:
129+
- setup_job
130+
- run:
131+
name: Publish "hardhat" release
132+
command: yarn publish:hardhat
133+
130134
workflows:
131135
version: 2
132136
build-and-test:
133137
jobs:
134138
- checkout_and_compile
135-
- test:
136-
requires:
137-
- checkout_and_compile
138-
- test_forked_network:
139+
# - test:
140+
# requires:
141+
# - checkout_and_compile
142+
# - test_forked_network:
143+
# requires:
144+
# - checkout_and_compile
145+
# - coverage:
146+
# requires:
147+
# - checkout_and_compile
148+
# - report_coverage:
149+
# requires:
150+
# - coverage
151+
# Publish hardhat first, latest second so that repo's package version is set correctly on exit
152+
- release_hardhat:
139153
requires:
140154
- checkout_and_compile
141-
- coverage:
155+
- release_latest:
142156
requires:
143-
- checkout_and_compile
144-
- report_coverage:
145-
requires:
146-
- coverage
157+
- release_hardhat
158+
159+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
coverage.json
1818
coverage/
1919
.env
20+
.releaserc.json
2021

2122
/.coverage_cache
2223
/.coverage_contracts

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ perpSetup = getPerpV2Fixture(...);
6767
[22]: https://www.npmjs.com/package/hardhat
6868
[23]: https://www.npmjs.com/package/typechain
6969

70+
## Semantic Release
71+
72+
This repository uses [semantic-release][10] to automatically publish in CI on merge to master. To trigger
73+
a release, use the following naming convention in your PR description (or in your squash & merge commit
74+
description):
75+
76+
+ patch release (e.g 1.0.1 -> 1.0.2): `fix(topic): description`
77+
+ example: `fix(perpV2Viewer): return uint256 instead of int256`
78+
+ feature release (e.g 1.1.0 -> 1.2.0): `feat(feature_name): description`
79+
+ example: `feat(PerpV2BasisTrading): Add PerpV2 Basis Trading Module`
80+
81+
7082
## Contributing
7183
We highly encourage participation from the community to help shape the development of Set. If you are interested in developing on top of Set Protocol or have any questions, please ping us on [Discord](https://discord.gg/ZWY66aR).
7284

@@ -116,3 +128,5 @@ If you follow these guidelines when reporting an issue to us, we commit to:
116128
(including an initial confirmation of your report within 72 hours of submission).
117129

118130
* Grant a monetary reward based on the OWASP risk assessment methodology.
131+
132+
[10]: https://semantic-release.gitbook.io/semantic-release/v/beta/

package.json

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@setprotocol/set-protocol-v2",
3-
"version": "0.1.15",
3+
"version": "0.0.0-development",
44
"description": "",
55
"main": "dist",
66
"types": "dist/types",
@@ -15,13 +15,15 @@
1515
"tsconfig.json"
1616
],
1717
"scripts": {
18-
"build": "yarn clean && yarn compile && yarn build:typechain",
19-
"build:npm": "yarn clean && yarn compile:npm && yarn build:typechain",
20-
"build:typechain": "yarn typechain && yarn transpile-dist",
18+
"build": "yarn clean && yarn compile && yarn build:ts:latest",
19+
"build:npm:latest": "yarn clean && yarn compile:latest && yarn build:ts:latest",
20+
"build:npm:hardhat": "yarn clean && yarn compile && yarn build:ts:hardhat",
21+
"build:ts:latest": "yarn typechain && yarn transpile:dist:latest",
22+
"build:ts:hardhat": "yarn typechain && yarn transpile:dist:hardhat && cp -rf typechain dist",
2123
"chain": "npx hardhat node",
2224
"clean": "rm -rf coverage.json .coverage_cache .coverage_contracts cache coverage typechain artifacts dist",
2325
"compile": "npx hardhat compile",
24-
"compile:npm": "SKIP_ABI_GAS_MODS=true npx hardhat compile",
26+
"compile:latest": "SKIP_ABI_GAS_MODS=true npx hardhat compile",
2527
"coverage": "yarn clean && yarn build && yarn cov:command",
2628
"cov:command": "COVERAGE=true node --max-old-space-size=4096 ./node_modules/.bin/hardhat coverage",
2729
"etherscan:verify": "hardhat --network kovan etherscan-verify --solc-input --license 'None'",
@@ -31,24 +33,34 @@
3133
"lint-ts": "eslint -c .eslintrc.js --ext .ts test utils tasks --fix",
3234
"precommit": "lint-staged",
3335
"prepare": "yarn build",
34-
"prepublishOnly": "yarn clean && yarn build:npm",
36+
"prepublishOnly": "./scripts/prepublish_only.sh",
37+
"publish:latest": "./scripts/release_latest.sh",
38+
"publish:hardhat": "./scripts/release_hardhat.sh",
3539
"test": "npx hardhat test --network localhost",
3640
"test:fork": "FORK=true npx hardhat test",
3741
"test:fork:fast": "NO_COMPILE=true TS_NODE_TRANSPILE_ONLY=1 FORK=true npx hardhat test --no-compile",
3842
"test:clean": "yarn clean && yarn build && yarn test",
3943
"test:fast": "NO_COMPILE=true TS_NODE_TRANSPILE_ONLY=1 npx hardhat test --network localhost --no-compile",
4044
"test:fast:compile": "TS_NODE_TRANSPILE_ONLY=1 npx hardhat test --network localhost",
4145
"transpile": "tsc",
42-
"transpile-dist": "tsc -p tsconfig.dist.json",
43-
"typechain": "npx hardhat typechain"
46+
"transpile:dist:latest": "tsc -p tsconfig.dist.json",
47+
"transpile:dist:hardhat": "tsc -p tsconfig.hardhat.json",
48+
"typechain": "npx hardhat typechain",
49+
"semantic-release": "semantic-release"
4450
},
4551
"repository": {
4652
"type": "git",
47-
"url": "git+https://github.com/SetProtocol/set-protocol-v2-contracts.git"
53+
"url": "https://github.com/SetProtocol/set-protocol-v2.git"
4854
},
4955
"author": "felix2feng",
5056
"license": "MIT",
5157
"homepage": "https://github.com/SetProtocol",
58+
"resolutions": {
59+
"babel-code-frame/chalk": "4.1.0"
60+
},
61+
"engines": {
62+
"yarn": ">=1.10.1"
63+
},
5264
"devDependencies": {
5365
"@0x/utils": "^6.4.3",
5466
"@nomiclabs/hardhat-ethers": "^2.0.2",
@@ -77,6 +89,7 @@
7789
"istanbul-combine-updated": "^0.3.0",
7890
"lint-staged": "^10.2.11",
7991
"lodash": "^4.17.4",
92+
"semantic-release": "^19.0.2",
8093
"solc": "^0.6.10",
8194
"solhint": "^3.1.0",
8295
"solidity-coverage": "^0.7.17",

scripts/prepublish_only.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
# Run in the `prepublishOnly npm hook`. We publish a specially built version
4+
# of the repo to the @hardhat tag which includes hardcoded gas values in the hardhat
5+
# artifact abis and deposits type definitions alongside the js files in the dist.
6+
# This build is necessary for Perp fixtures to run correctly at set-v2-strategies
7+
set -o errexit
8+
9+
echo "Running prepublishOnly npm hook"
10+
echo "PUBLISH_HARDHAT = $PUBLISH_HARDHAT"
11+
12+
if [[ -v PUBLISH_HARDHAT ]]; then
13+
yarn clean && yarn build:npm:hardhat
14+
else
15+
yarn clean && yarn build:npm:latest
16+
fi

scripts/release_hardhat.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
5+
# Auto-publishes a specially built release to the @hardhat tag using version schema `x.x.x-hardhat.1`
6+
# See scripts/prepublish_only.sh for details about this build.
7+
#
8+
# The `release_default` branch config here is necessary to trick the semantic-release tool into publishing
9+
# latest and hardhat builds from `master`. These are handled by separate jobs in CI (see circleci/config.yml)
10+
echo '{
11+
"branches": [
12+
{ "name": "release_default_do_not_delete" },
13+
{ "name": "chris/semantic-release-test", "channel": "hardhat", "prerelease": "hardhat"}
14+
]
15+
}' > .releaserc.json
16+
17+
PUBLISH_HARDHAT=true npx semantic-release --debug

scripts/release_latest.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
5+
# Auto-publishes `latest` from master
6+
echo '{
7+
"branches": [
8+
{ "name": "master" }
9+
]
10+
}' > .releaserc.json
11+
12+
npx semantic-release --debug

tsconfig.hardhat.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"strict": true,
6+
"esModuleInterop": true,
7+
"strictPropertyInitialization": false,
8+
"outDir": "./dist",
9+
"resolveJsonModule": true,
10+
"declaration": true,
11+
"declarationMap": true,
12+
"sourceMap": true,
13+
"baseUrl": ".",
14+
"moduleResolution": "node",
15+
"paths": {
16+
"@utils/*": ["utils/*"],
17+
"@typechain/*": ["typechain/*"]
18+
}
19+
},
20+
"include": [
21+
"./utils/**/*.ts",
22+
"./deploy/**/*.ts",
23+
"./typechain/**/*.ts",
24+
"./tasks/**/*.ts"
25+
],
26+
"files": [
27+
"hardhat.config.ts",
28+
]
29+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"moduleResolution": "node",
1616
"paths": {
1717
"@utils/*": ["utils/*"],
18-
"@typechain/*": ["typechain/*"],
18+
"@typechain/*": ["typechain/*"]
1919
}
2020
},
2121
"include": [

0 commit comments

Comments
 (0)