Skip to content

Commit

Permalink
Github Action fixes for Test,Slither,Github Release and NPM package r…
Browse files Browse the repository at this point in the history
…elease (#1003)

* chore: update release trigger for CI

* chore: create github release when tag is pushed

* chore: secret to write github release

* chore: update node version

* chore: run CI on push or pull request includes test,lint,coverage,slither

* chore: run CI on push to main and develop branches only

* chore: run CI on push to release* branches also

* chore: fix release ci and add update common ci

* chore: fix release ci and add update common ci

* chore: undo package json change

* chore: node 20

* chore: test CI with node 20

* chore: test CI with node 16

* chore: update test

* chore: update to hardhat from truffle

* chore: fix lint and change prettier to warning

* chore: revert rely on node 20 fallback on git action end

* chore: keep prettier error

* fix: skale network hardhat config changed to frame url
  • Loading branch information
yohanelly95 authored Sep 11, 2024
1 parent dfdc489 commit 9d4088a
Show file tree
Hide file tree
Showing 9 changed files with 3,305 additions and 5,534 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: CI

on:
push:
branches:
- main
- develop
- "release*"
pull_request:
types: [opened, synchronize]

jobs:
install_dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: |
npm install
npm run cp-ci-env
- uses: bissolli/gh-action-persist-workspace@v1
with:
action: persist

test:
runs-on: ubuntu-latest
needs: install_dependencies
steps:
- uses: bissolli/gh-action-persist-workspace@v1
with:
action: retrieve
- name: Run tests
run: |
CI=true npm run test
- name: Store artifacts
uses: actions/upload-artifact@v2
with:
name: test
path: test

scenarios:
runs-on: ubuntu-latest
needs: install_dependencies
steps:
- uses: bissolli/gh-action-persist-workspace@v1
with:
action: retrieve
- name: Run scenarios
run: |
CI=true npm run scenarios
- name: Store artifacts
uses: actions/upload-artifact@v2
with:
name: scenarios
path: scenarios

lint:
runs-on: ubuntu-latest
needs: install_dependencies
steps:
- uses: bissolli/gh-action-persist-workspace@v1
with:
action: retrieve
- name: Run Lint
run: npm run lint
- name: Store artifacts
uses: actions/upload-artifact@v2
with:
name: lint
path: lint

coverage:
runs-on: ubuntu-latest
needs: install_dependencies
steps:
- uses: bissolli/gh-action-persist-workspace@v1
with:
action: retrieve
- name: Run Coverage
run: npm run coverage
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Store artifacts
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage

slither:
runs-on: ubuntu-latest
needs: install_dependencies
steps:
- uses: bissolli/gh-action-persist-workspace@v1
with:
action: retrieve
- name: Run Slither
uses: crytic/[email protected]
id: slither
with:
node-version: 16
sarif: results.sarif
fail-on: high
43 changes: 26 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
name: Release
name: Release Package

on:
push:
branches:
- "next"
tags:
- v*
jobs:
build:
publish-npm-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: actions/setup-node@v1
with:
node-version: "16.x"
- run: yarn cp-ci-env
- run: yarn install
- run: yarn run hardhat export-abi
- run: yarn semantic-release
env:
GITHUB_TOKEN: ${{ secrets.RAZORNETWORKBOT }}
NPM_TOKEN: ${{ secrets.RAZORDEPLOYER }}
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- run: yarn cp-ci-env
- run: |
PKG_VERSION=$(node -p "require('./package.json').version")
TAG_VERSION=${GITHUB_REF#refs/tags/v}
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
echo "Package version ($PKG_VERSION) does not match tag version ($TAG_VERSION)"
exit 1
fi
- run: yarn install
- run: yarn run hardhat export-abi
- run: npm publish
env:
GITHUB_TOKEN: ${{ secrets.RAZORNETWORKBOT }}
NPM_TOKEN: ${{ secrets.RAZORDEPLOYER }}
6 changes: 2 additions & 4 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ if (dotenvResult.error) {
}

require('@nomiclabs/hardhat-ethers');
require('@nomiclabs/hardhat-truffle5');
require('hardhat-gas-reporter');
require('solidity-coverage');
require('hardhat-abi-exporter');
Expand All @@ -32,7 +31,7 @@ const ENV_CHAIN_IDS = {
mainnet: 1,
goerli: 5,
mumbai: 80001,
skale: 1517929550,
skale: 2046399126,
};

module.exports = {
Expand Down Expand Up @@ -87,8 +86,7 @@ module.exports = {
timeout: 300000,
},
skale: {
url: PROVIDER_URL || '',
accounts: { mnemonic: MNEMONIC },
url: 'http://127.0.0.1:1248', // this is the RPC endpoint exposed by Frame,
chainId: ENV_CHAIN_IDS[NETWORK],
timeout: 300000,
},
Expand Down
187 changes: 93 additions & 94 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,96 +1,95 @@
{
"name": "@razor-network/contracts",
"version": "1.0.1",
"description": "These are the contracts for Razor network testnet",
"author": "Razor Network",
"private": false,
"files": [
"abi/**/*",
"contracts/**/*"
],
"scripts": {
"cp-ci-env": "cp .env.ci .env",
"compile": "npx hardhat compile",
"codechecks": "npx codechecks",
"coverage": "hardhat coverage && npm run coverage:check",
"coverage:check": "istanbul check-coverage --statements 90 --branches 60 --functions 85 --lines 86",
"start:local": "./node_modules/.bin/hardhat node",
"deploy": "./scripts/deploy.sh",
"lint": "npm run lint:sol && npm run lint:js",
"lint:fix": "npm run lint:js:fix && npm run lint:sol:fix",
"lint:js": "eslint \"**/*.js\"",
"lint:js:fix": "eslint --fix . \"**/*.js\"",
"lint:sol": "solhint 'contracts/**/*.sol'",
"lint:sol:fix": "prettier 'contracts/**/*.sol' -w",
"test": "hardhat test",
"scenarios": "hardhat test scenarios/scenarios.js",
"gas": "CI=true npm run test && node scripts/gasAnalyze.js",
"gasCompare": "node scripts/gasCompare.js",
"postinstall": "husky install",
"prepack": "pinst --disable",
"postpack": "pinst --enable"
},
"release": {
"plugins": [
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git",
"@semantic-release/github"
]
},
"repository": {
"type": "git",
"url": "https://github.com/razor-network/contracts.git"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/razor-network/contracts/issues"
},
"homepage": "https://github.com/razor-network/contracts#readme",
"dependencies": {
"@openzeppelin/contracts": "4.5.0",
"@primitivefi/hardhat-dodoc": "^0.1.3",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"circleci-pr-commenter": "^0.1.2",
"fs": "^0.0.1-security",
"hardhat-abi-exporter": "^2.3.0",
"json-to-markdown-table": "^1.0.0",
"jsonfile": "^6.1.0",
"semantic-release": "^19.0.2"
},
"devDependencies": {
"@codechecks/client": "^0.1.11",
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@nomiclabs/hardhat-ethers": "^2.0.6",
"@nomiclabs/hardhat-etherscan": "^2.1.6",
"@nomiclabs/hardhat-truffle5": "^2.0.0",
"@nomiclabs/hardhat-web3": "^2.0.0",
"@tenderly/hardhat-tenderly": "^1.0.12",
"axios": "^0.24.0",
"chai": "^4.3.4",
"coveralls": "^3.1.1",
"dotenv": "10.0.0",
"elliptic": "^6.5.4",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.2",
"ethers": "^5.6.8",
"get-json": "^1.0.1",
"hardhat": "^2.9.7",
"hardhat-gas-reporter": "1.0.4",
"husky": "^7.0.4",
"pinst": "^3.0.0",
"prettier": "^2.3.2",
"prettier-plugin-solidity": "^1.0.0-beta.17",
"solhint": "~3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.17"
},
"engines": {
"node": ">=16"
"name": "@razor-network/contracts",
"version": "2.0.0",
"description": "These are the contracts for Razor network testnet",
"author": "Razor Network",
"private": false,
"files": [
"abi/**/*",
"contracts/**/*"
],
"scripts": {
"cp-ci-env": "cp .env.ci .env",
"compile": "npx hardhat compile",
"codechecks": "npx codechecks",
"coverage": "hardhat coverage && npm run coverage:check",
"coverage:check": "istanbul check-coverage --statements 90 --branches 60 --functions 85 --lines 86",
"start:local": "./node_modules/.bin/hardhat node",
"deploy": "./scripts/deploy.sh",
"lint": "npm run lint:sol && npm run lint:js",
"lint:fix": "npm run lint:js:fix && npm run lint:sol:fix",
"lint:js": "eslint \"**/*.js\"",
"lint:js:fix": "eslint --fix . \"**/*.js\"",
"lint:sol": "solhint 'contracts/**/*.sol'",
"lint:sol:fix": "prettier 'contracts/**/*.sol' -w",
"test": "hardhat test",
"scenarios": "hardhat test scenarios/scenarios.js",
"gas": "CI=true npm run test && node scripts/gasAnalyze.js",
"gasCompare": "node scripts/gasCompare.js",
"postinstall": "husky install",
"prepack": "pinst --disable",
"postpack": "pinst --enable"
},
"release": {
"plugins": [
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git",
"@semantic-release/github"
]
},
"repository": {
"type": "git",
"url": "https://github.com/razor-network/contracts.git"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/razor-network/contracts/issues"
},
"homepage": "https://github.com/razor-network/contracts#readme",
"dependencies": {
"@openzeppelin/contracts": "4.7.3",
"@primitivefi/hardhat-dodoc": "^0.1.3",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"fs": "^0.0.1-security",
"hardhat": "^2.11.0",
"hardhat-abi-exporter": "^2.3.0",
"hardhat-deploy": "^0.11.4",
"json-to-markdown-table": "^1.0.0",
"jsonfile": "^6.1.0",
"semantic-release": "^19.0.2"
},
"devDependencies": {
"@codechecks/client": "^0.1.11",
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@nomiclabs/hardhat-ethers": "^2.0.6",
"@nomiclabs/hardhat-etherscan": "^2.1.6",
"@tenderly/hardhat-tenderly": "^1.0.12",
"axios": "^0.24.0",
"chai": "^4.3.4",
"coveralls": "^3.1.1",
"dotenv": "10.0.0",
"elliptic": "^6.5.4",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.2",
"ethers": "^5.6.8",
"get-json": "^1.0.1",
"hardhat-gas-reporter": "1.0.4",
"husky": "^7.0.4",
"pinst": "^3.0.0",
"prettier": "^2.3.2",
"prettier-plugin-solidity": "^1.0.0-beta.17",
"solhint": "~3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.8.0"
},
"engines": {
"node": ">=16"
}
}
}
Loading

0 comments on commit 9d4088a

Please sign in to comment.