Skip to content

Commit

Permalink
fix(test): just testing (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke authored Mar 15, 2022
1 parent e48e673 commit 3e93e2b
Show file tree
Hide file tree
Showing 10 changed files with 2,465 additions and 116 deletions.
101 changes: 57 additions & 44 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
version: 2
version: 2.1

default_env: &default_env
working_directory: ~/set-protocol-v2
docker:
- image: circleci/node:14.18
environment:
NODE_OPTIONS: --max_old_space_size=8192

commands:
setup_job:
steps:
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}

jobs:
checkout_and_compile:
docker:
- image: circleci/node:12.16.0
environment:
NODE_OPTIONS: --max_old_space_size=8192
<<: *default_env
resource_class: large
working_directory: ~/set-protocol-v2
steps:
- checkout
- restore_cache:
Expand All @@ -30,16 +39,10 @@ jobs:
paths:
- ~/set-protocol-v2
test:
docker:
- image: circleci/node:12.16.0
working_directory: ~/set-protocol-v2
<<: *default_env
parallelism: 3
steps:
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Set Up Environment Variables
command: cp .env.default .env
- setup_job
- run:
name: Test RPC
command: yarn chain
Expand All @@ -51,35 +54,23 @@ jobs:
yarn test ${TEST_FILES}
test_forked_network:
docker:
- image: circleci/node:12.16.0
working_directory: ~/set-protocol-v2
<<: *default_env
steps:
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Set Up Environment Variables
command: cp .env.default .env
- setup_job
- run:
name: Hardhat Test
command: yarn test:fork

coverage:
docker:
- image: circleci/node:12.16.0
working_directory: ~/set-protocol-v2
<<: *default_env
# When changing the parallelism value, you also
# need to update the `persist_to_workspace` paths
# in this job (below) as well as the list of files passed
# to istanbul-combine in the `report_coverage` job
parallelism: 5
resource_class: medium+
steps:
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Set Up Environment Variables
command: cp .env.default .env
- setup_job
- run:
name: Create shared coverage outputs folder
command: mkdir -p /tmp/coverage
Expand All @@ -104,14 +95,11 @@ jobs:
- cov_4.json

report_coverage:
docker:
- image: circleci/node:12.16.0
working_directory: ~/set-protocol-v2
<<: *default_env
steps:
- setup_job
- attach_workspace:
at: /tmp/coverage
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Combine coverage reports
command: |
Expand All @@ -127,20 +115,45 @@ jobs:
command: |
cat coverage/lcov.info | node_modules/.bin/coveralls
release_latest:
<<: *default_env
steps:
- setup_job
- run:
name: Publish "latest" release
command: yarn publish:latest

release_hardhat:
<<: *default_env
steps:
- setup_job
- run:
name: Publish "hardhat" release
command: yarn publish:hardhat

workflows:
version: 2
build-and-test:
jobs:
- checkout_and_compile
- test:
requires:
- checkout_and_compile
- test_forked_network:
# - test:
# requires:
# - checkout_and_compile
# - test_forked_network:
# requires:
# - checkout_and_compile
# - coverage:
# requires:
# - checkout_and_compile
# - report_coverage:
# requires:
# - coverage
# Publish hardhat first, latest second so that repo's package version is set correctly on exit
- release_hardhat:
requires:
- checkout_and_compile
- coverage:
- release_latest:
requires:
- checkout_and_compile
- report_coverage:
requires:
- coverage
- release_hardhat


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
coverage.json
coverage/
.env
.releaserc.json

/.coverage_cache
/.coverage_contracts
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ perpSetup = getPerpV2Fixture(...);
[22]: https://www.npmjs.com/package/hardhat
[23]: https://www.npmjs.com/package/typechain

## Semantic Release

This repository uses [semantic-release][10] to automatically publish in CI on merge to master. To trigger
a release, use the following naming convention in your PR description (or in your squash & merge commit
description):

+ patch release (e.g 1.0.1 -> 1.0.2): `fix(topic): description`
+ example: `fix(perpV2Viewer): return uint256 instead of int256`
+ feature release (e.g 1.1.0 -> 1.2.0): `feat(feature_name): description`
+ example: `feat(PerpV2BasisTrading): Add PerpV2 Basis Trading Module`


## Contributing
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).

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

* Grant a monetary reward based on the OWASP risk assessment methodology.

[10]: https://semantic-release.gitbook.io/semantic-release/v/beta/
31 changes: 22 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@setprotocol/set-protocol-v2",
"version": "0.1.15",
"version": "0.0.0-development",
"description": "",
"main": "dist",
"types": "dist/types",
Expand All @@ -15,13 +15,15 @@
"tsconfig.json"
],
"scripts": {
"build": "yarn clean && yarn compile && yarn build:typechain",
"build:npm": "yarn clean && yarn compile:npm && yarn build:typechain",
"build:typechain": "yarn typechain && yarn transpile-dist",
"build": "yarn clean && yarn compile && yarn build:ts:latest",
"build:npm:latest": "yarn clean && yarn compile:latest && yarn build:ts:latest",
"build:npm:hardhat": "yarn clean && yarn compile && yarn build:ts:hardhat",
"build:ts:latest": "yarn typechain && yarn transpile:dist:latest",
"build:ts:hardhat": "yarn typechain && yarn transpile:dist:hardhat && cp -rf typechain dist",
"chain": "npx hardhat node",
"clean": "rm -rf coverage.json .coverage_cache .coverage_contracts cache coverage typechain artifacts dist",
"compile": "npx hardhat compile",
"compile:npm": "SKIP_ABI_GAS_MODS=true npx hardhat compile",
"compile:latest": "SKIP_ABI_GAS_MODS=true npx hardhat compile",
"coverage": "yarn clean && yarn build && yarn cov:command",
"cov:command": "COVERAGE=true node --max-old-space-size=4096 ./node_modules/.bin/hardhat coverage",
"etherscan:verify": "hardhat --network kovan etherscan-verify --solc-input --license 'None'",
Expand All @@ -31,24 +33,34 @@
"lint-ts": "eslint -c .eslintrc.js --ext .ts test utils tasks --fix",
"precommit": "lint-staged",
"prepare": "yarn build",
"prepublishOnly": "yarn clean && yarn build:npm",
"prepublishOnly": "./scripts/prepublish_only.sh",
"publish:latest": "./scripts/release_latest.sh",
"publish:hardhat": "./scripts/release_hardhat.sh",
"test": "npx hardhat test --network localhost",
"test:fork": "FORK=true npx hardhat test",
"test:fork:fast": "NO_COMPILE=true TS_NODE_TRANSPILE_ONLY=1 FORK=true npx hardhat test --no-compile",
"test:clean": "yarn clean && yarn build && yarn test",
"test:fast": "NO_COMPILE=true TS_NODE_TRANSPILE_ONLY=1 npx hardhat test --network localhost --no-compile",
"test:fast:compile": "TS_NODE_TRANSPILE_ONLY=1 npx hardhat test --network localhost",
"transpile": "tsc",
"transpile-dist": "tsc -p tsconfig.dist.json",
"typechain": "npx hardhat typechain"
"transpile:dist:latest": "tsc -p tsconfig.dist.json",
"transpile:dist:hardhat": "tsc -p tsconfig.hardhat.json",
"typechain": "npx hardhat typechain",
"semantic-release": "semantic-release"
},
"repository": {
"type": "git",
"url": "git+https://github.com/SetProtocol/set-protocol-v2-contracts.git"
"url": "https://github.com/SetProtocol/set-protocol-v2.git"
},
"author": "felix2feng",
"license": "MIT",
"homepage": "https://github.com/SetProtocol",
"resolutions": {
"babel-code-frame/chalk": "4.1.0"
},
"engines": {
"yarn": ">=1.10.1"
},
"devDependencies": {
"@0x/utils": "^6.4.3",
"@nomiclabs/hardhat-ethers": "^2.0.2",
Expand Down Expand Up @@ -77,6 +89,7 @@
"istanbul-combine-updated": "^0.3.0",
"lint-staged": "^10.2.11",
"lodash": "^4.17.4",
"semantic-release": "^19.0.2",
"solc": "^0.6.10",
"solhint": "^3.1.0",
"solidity-coverage": "^0.7.17",
Expand Down
16 changes: 16 additions & 0 deletions scripts/prepublish_only.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# Run in the `prepublishOnly npm hook`. We publish a specially built version
# of the repo to the @hardhat tag which includes hardcoded gas values in the hardhat
# artifact abis and deposits type definitions alongside the js files in the dist.
# This build is necessary for Perp fixtures to run correctly at set-v2-strategies
set -o errexit

echo "Running prepublishOnly npm hook"
echo "PUBLISH_HARDHAT = $PUBLISH_HARDHAT"

if [[ -v PUBLISH_HARDHAT ]]; then
yarn clean && yarn build:npm:hardhat
else
yarn clean && yarn build:npm:latest
fi
17 changes: 17 additions & 0 deletions scripts/release_hardhat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -o errexit

# Auto-publishes a specially built release to the @hardhat tag using version schema `x.x.x-hardhat.1`
# See scripts/prepublish_only.sh for details about this build.
#
# The `release_default` branch config here is necessary to trick the semantic-release tool into publishing
# latest and hardhat builds from `master`. These are handled by separate jobs in CI (see circleci/config.yml)
echo '{
"branches": [
{ "name": "release_default_do_not_delete" },
{ "name": "chris/semantic-release-test", "channel": "hardhat", "prerelease": "hardhat"}
]
}' > .releaserc.json

PUBLISH_HARDHAT=true npx semantic-release --debug
12 changes: 12 additions & 0 deletions scripts/release_latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -o errexit

# Auto-publishes `latest` from master
echo '{
"branches": [
{ "name": "master" }
]
}' > .releaserc.json

npx semantic-release --debug
29 changes: 29 additions & 0 deletions tsconfig.hardhat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"strictPropertyInitialization": false,
"outDir": "./dist",
"resolveJsonModule": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"baseUrl": ".",
"moduleResolution": "node",
"paths": {
"@utils/*": ["utils/*"],
"@typechain/*": ["typechain/*"]
}
},
"include": [
"./utils/**/*.ts",
"./deploy/**/*.ts",
"./typechain/**/*.ts",
"./tasks/**/*.ts"
],
"files": [
"hardhat.config.ts",
]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"moduleResolution": "node",
"paths": {
"@utils/*": ["utils/*"],
"@typechain/*": ["typechain/*"],
"@typechain/*": ["typechain/*"]
}
},
"include": [
Expand Down
Loading

0 comments on commit 3e93e2b

Please sign in to comment.