Skip to content

Commit

Permalink
👷‍♂️ Implement userdoc, devdoc, and ape CI Tests (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcaversaccio authored Jun 3, 2023
1 parent 300014d commit 3e3e005
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jobs:
matrix:
os:
- ubuntu-latest
architecture:
- x64
python-version:
- 3.11
node_version:
- 18

Expand Down Expand Up @@ -44,6 +48,18 @@ jobs:
- name: Prettier and lint
run: yarn lint:check

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}

- name: Check formatting with Black
uses: psf/black@stable
with:
options: "--check --verbose"
src: "./scripts"

codespell:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ jobs:
- name: Install Vyper
run: pip install vyper

- name: Check userdoc and devdoc compilation
run: python scripts/compile.py

- name: Setup Ape
uses: ApeWorX/github-action@v1
with:
python-version: ${{ matrix.python-version }}

- name: Check Ape compilation
run: ape compile

- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -62,7 +73,7 @@ jobs:
version: nightly

- name: Show the Foundry CI config
run: "forge config"
run: forge config
env:
FOUNDRY_PROFILE: ci

Expand All @@ -72,7 +83,7 @@ jobs:
FOUNDRY_PROFILE: ci

- name: Show the Foundry default config
run: "forge config"
run: forge config
env:
FOUNDRY_PROFILE: default

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

### ♻️ Refactoring

- **General**
- All 🐍 snekmate contracts are now guaranteed to compile with the Vyper CLI flags `userdoc` and `devdoc`, and, if using the [Ape framework](https://github.com/ApeWorX/ape), with `ape compile`. ([#126](https://github.com/pcaversaccio/snekmate/pull/126))
- **Extensions**
- [`ERC4626`](https://github.com/pcaversaccio/snekmate/blob/v0.0.2/src/extensions/ERC4626.vy): Add `implements` interface `ERC20Detailed` and `ERC4626`. ([#125](https://github.com/pcaversaccio/snekmate/pull/125))
- **Tokens**
Expand All @@ -28,6 +30,10 @@

- All 🐍 snekmate contracts now target the Vyper version [`0.3.9`](https://github.com/vyperlang/vyper/releases/tag/v0.3.9). It is strongly recommended to upgrade accordingly your local Vyper version prior to using the 🐍 snekmate contracts. **Important:** The default EVM version since Vyper version `0.3.8` is set to `shanghai` (i.e. the EVM includes the [`PUSH0`](https://eips.ethereum.org/EIPS/eip-3855) instruction). If you intend to deploy on an EVM chain with no `PUSH0` support, you must compile the 🐍 snekmate contracts with the `--evm-version paris` option; e.g. `vyper --evm-version paris utils/Math.vy`. ([#122](https://github.com/pcaversaccio/snekmate/pull/122))

### 👀 Full Changelog

- [`v0.0.1...v0.0.2`](https://github.com/pcaversaccio/snekmate/compare/v0.0.1...v0.0.2)

## `0.0.1` (06-03-2023)

### 💥 New Features
Expand Down
7 changes: 7 additions & 0 deletions ape-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: snekmate
contracts_folder: src
default_ecosystem: ethereum
plugins:
- name: vyper
vyper:
evm_version: shanghai
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"url": "https://github.com/pcaversaccio/snekmate/issues"
},
"scripts": {
"prettier:check": "prettier -c **/*.{md,sol,js,json,yml}",
"prettier:fix": "prettier -w **/*.{md,sol,js,json,yml}",
"prettier:check": "prettier -c **/*.{md,sol,js,json,yml,yaml}",
"prettier:fix": "prettier -w **/*.{md,sol,js,json,yml,yaml}",
"solhint:check": "npx solhint '**/*.sol'",
"solhint:fix": "npx solhint '**/*.sol' --fix",
"lint:check": "yarn prettier:check && yarn solhint:check && eslint --ext .js .",
Expand Down
9 changes: 9 additions & 0 deletions scripts/compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import subprocess, glob

for filename in glob.glob("**/*.vy", recursive=True):
result = subprocess.run(
["vyper", "-f", "userdoc,devdoc", filename], capture_output=True, text=True
)
if result.stderr != "":
raise Exception("Error compiling: " + filename)
print("stdout:", result.stdout)
8 changes: 5 additions & 3 deletions src/auth/AccessControl.vy
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
Roles can be used to represent a set of permissions. To restrict
access to a function call, use the `external` function `hasRole`
or the `internal` function `_check_role`:
or the `internal` function `_check_role` (to avoid any NatSpec
parsing error, no `@` character is added to the visibility decorator
`@external` in the following examples; please add them accordingly):
```vy
@external
external
def foo():
assert self.hasRole[MY_ROLE][msg.sender], "AccessControl: account is missing role"
...
OR
@external
external
def foo():
self._check_role(MY_ROLE, msg.sender)
...
Expand Down

0 comments on commit 3e3e005

Please sign in to comment.