Skip to content

Commit

Permalink
Fixes for build.
Browse files Browse the repository at this point in the history
  • Loading branch information
robotoer committed Jul 30, 2024
1 parent c0a7c8d commit 0c4eb1c
Show file tree
Hide file tree
Showing 14 changed files with 840 additions and 103 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
55 changes: 55 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CD
on:
release:
types:
- released
concurrency:
group: "stylebot"
cancel-in-progress: true
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.RELEASEBOT_APP_ID }}
private-key: ${{ secrets.RELEASEBOT_PRIVATE_KEY }}
- uses: actions/checkout@master
with:
fetch-depth: 0
- run: echo "package_version=$(jq -r .version package.json)" >> $GITHUB_ENV
- if: ${{ github.event.release.name != env.package_version }}
run: 'echo "Error: Tag name does not match package.json version" && exit 1'
- id: nodeversion
run: echo "::set-output name=version::$(grep nodejs .tool-versions | sed -e 's/[^[:space:]]*[[:space:]]*//')"
- uses: actions/setup-node@v4
with:
node-version: ${{ steps.nodeversion.outputs.version }}
cache: yarn
registry-url: "https://registry.npmjs.org"
token: ${{ secrets.NPM_TOKEN }}
- run: |
echo "npmRegistries:" >> .yarnrc.yml
echo ' "https://registry.npmjs.org":' >> .yarnrc.yml
echo " npmAlwaysAuth: true" >> .yarnrc.yml
echo " npmAuthToken: ${{ secrets.NPM_TOKEN }}" >> .yarnrc.yml
- run: yarn install --immutable
- run: yarn build:hardhat
- run: yarn build:tsc
- run: yarn publish --patch --access public --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: "[releasebot] Updates version post-release"
branch: releasebot/version-update
title: "[releasebot] Updates version post-release"
token: ${{ steps.app-token.outputs.token }}
body: |
The following files have been updated as a result of releasing version: ${{ env.package_version }}.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI
on: [push]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- id: nodeversion
run: echo "::set-output name=version::$(grep nodejs .tool-versions | sed -e 's/[^[:space:]]*[[:space:]]*//')"
- uses: actions/setup-node@v4
with:
node-version: ${{ steps.nodeversion.outputs.version }}
cache: yarn
- run: yarn install --immutable
- run: yarn check:eslint || true
- run: yarn check:prettier || true
- run: yarn build:hardhat
- run: yarn build:tsc
- run: yarn test
61 changes: 61 additions & 0 deletions .github/workflows/stylebot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: stylebot
on:
push:
branches:
- main
concurrency:
group: "stylebot"
cancel-in-progress: true
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
fix:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.STYLEBOT_GITHUB_APP_ID }}
private-key: ${{ secrets.STYLEBOT_GITHUB_APP_KEY }}
- uses: actions/checkout@master
- id: nodeversion
run: echo "::set-output name=version::$(grep nodejs .tool-versions | sed -e 's/[^[:space:]]*[[:space:]]*//')"
- uses: actions/setup-node@v4
with:
node-version: ${{ steps.nodeversion.outputs.version }}
cache: yarn
- run: yarn install --immutable
# Run fixes, save stdout.
- run: |
echo 'ESLINT_RESULTS<<EOF' >> ${GITHUB_ENV}
yarn fix:eslint || true >> ${GITHUB_ENV}
echo 'EOF' >> ${GITHUB_ENV}
- run: |
echo 'PRETTIER_RESULTS<<EOF' >> ${GITHUB_ENV}
yarn fix:prettier >> ${GITHUB_ENV}
echo 'EOF' >> ${GITHUB_ENV}
- run: git restore .yarn .yarnrc.yml
# Make PR from local changes.
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.app-token.outputs.token }}
commit-message: "[stylebot] Fixes for code style"
branch: stylebot/patch
title: "[stylebot] Fixes for code style"
body: |
Stylebot detected automatically fix-able code style issues.
`yarn fix:eslint`:
```
${{ env.ESLINT_RESULTS }}
```
`yarn fix:prettier`:
```
${{ env.PRETTIER_RESULTS }}
```
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ node_modules
/coverage.json

# Typescript files
/dist

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337
**/*.js
*.tgz
18 changes: 18 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
node_modules
.env
.tool-versions
.prettierrc
eslint.config.mjs
hardhat.config.ts

# Hardhat files
/cache
/test

# solidity-coverage files
/coverage
/coverage.json

/.github

/*.tgz
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("MyContract", () => {
abi,
inputs: [2n, 3n],
reason: "revert reason",
}
},
// ...
);

Expand All @@ -60,7 +60,7 @@ describe("MyContract", () => {
const result = await client.readContract(
mockContract.address,
"myFunction1",
[1, 2]
[1, 2],
);

// Check the result
Expand Down
19 changes: 19 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
ignores: [
"**/*.js",
"node_modules/",
"artifacts/",
"cache/",
".github/",
"hardhat.config.ts",
],
},
);
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "viem-mock-contract",
"version": "1.0.0",
"main": "dist/src/mock-contract.js",
"version": "0.1.0",
"main": "src/mock-contract.js",
"license": "MIT",
"devDependencies": {
"@eslint/js": "^9.8.0",
"@nomicfoundation/hardhat-ignition": "^0.15.0",
"@nomicfoundation/hardhat-ignition-viem": "^0.15.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
Expand All @@ -12,19 +13,28 @@
"@nomicfoundation/hardhat-viem": "^2.0.0",
"@types/chai": "^4.2.0",
"@types/chai-as-promised": "^7.1.6",
"@types/eslint__js": "^8.42.3",
"@types/mocha": ">=9.1.0",
"@types/node": ">=18.0.0",
"abitype": "^1.0.5",
"chai": "^4.2.0",
"eslint": "^9.8.0",
"hardhat": "^2.22.6",
"hardhat-gas-reporter": "^1.0.8",
"prettier": "^3.3.3",
"solidity-coverage": "^0.8.0",
"ts-node": ">=8.0.0",
"typescript": "~5.0.4",
"typescript": "^5.5.4",
"typescript-eslint": "^7.18.0",
"viem": "^2.7.6"
},
"scripts": {
"build": "hardhat compile",
"build:hardhat": "hardhat compile",
"build:tsc": "tsc",
"check:eslint": "eslint .",
"check:prettier": "prettier --check .",
"fix:eslint": "eslint --fix .",
"fix:prettier": "prettier --write .",
"test": "hardhat test",
"coverage": "hardhat coverage"
}
Expand Down
Loading

0 comments on commit 0c4eb1c

Please sign in to comment.