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

Add lint-staged and husky for auto linting. Update github actions. #809

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
52 changes: 0 additions & 52 deletions .github/workflows/ci-dev.yml

This file was deleted.

88 changes: 36 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [ master ]
branches:
- master
pull_request:
branches: [ master ]

jobs:
lint:
Expand All @@ -13,70 +13,54 @@ jobs:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
MNEMONIC_TEST_ACCOUNT: ${{ secrets.MNEMONIC_TEST_ACCOUNT }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v2
with:
node-version: '16'
# fix for forcing git to use https when pulling deps
- run: 'git config --global --replace-all url."https://github.com/".insteadOf ssh://[email protected]/'
- run: npm ci --legacy-peer-deps
- run: npm run build --if-present
- run: npm run lint
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
# fix for forcing git to use https when pulling deps
- run: 'git config --global --replace-all url."https://github.com/".insteadOf ssh://[email protected]/'
- run: npm ci --legacy-peer-deps # runs prepare script which runs build
- run: npm run lint

test:
runs-on: ubuntu-latest
env:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
MNEMONIC_TEST_ACCOUNT: ${{ secrets.MNEMONIC_TEST_ACCOUNT }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v2
with:
node-version: '16'
# fix for forcing git to use https when pulling deps
- run: 'git config --global --replace-all url."https://github.com/".insteadOf ssh://[email protected]/'
- run: npm ci --legacy-peer-deps
- run: npm run build --if-present
- run: npm test
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
# fix for forcing git to use https when pulling deps
- run: 'git config --global --replace-all url."https://github.com/".insteadOf ssh://[email protected]/'
- run: npm ci --legacy-peer-deps
- run: npm test

coverage:
# Only run coverage if the PR is targeting master or if it's a push to master
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event.pull_request.base.ref == 'master'
runs-on: ubuntu-latest
env:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
MNEMONIC_TEST_ACCOUNT: ${{ secrets.MNEMONIC_TEST_ACCOUNT }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v2
with:
node-version: '16'
# fix for forcing git to use https when pulling deps
- run: 'git config --global --replace-all url."https://github.com/".insteadOf ssh://[email protected]/'
- run: npm ci --legacy-peer-deps
- run: npm run build --if-present
- env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: npm run coverage
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
# fix for forcing git to use https when pulling deps
- run: 'git config --global --replace-all url."https://github.com/".insteadOf ssh://[email protected]/'
- run: npm ci --legacy-peer-deps
- env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: npm run coverage
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

# slither:
# runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
Loading