Skip to content

Commit

Permalink
Add lint and actions
Browse files Browse the repository at this point in the history
  • Loading branch information
viatrix committed Dec 9, 2024
1 parent 17b0168 commit df6745c
Show file tree
Hide file tree
Showing 11 changed files with 914 additions and 21 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
# Maintain npm dependencies
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on: [pull_request, push]
name: Linter check

jobs:
lint-solidity:
name: Lint Solidity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '18.x'

- run: yarn install --frozen-lockfile --non-interactive

- name: Run linter
run: yarn run lint:solidity

lint-js:
name: Lint JS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '18.x'

- run: yarn install --frozen-lockfile --non-interactive
- name: Run linter
run: yarn run lint:js
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Test

on:
push
pull_request:
types: [opened, synchronize, reopened]

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout code
uses: actions/[email protected]
- uses: actions/[email protected]
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install
- name: Compile contracts
run: yarn compile
- name: Store contract artifacts
uses: actions/upload-artifact@v3
with:
name: contracts-artifacts
path: build
- name: Create .env with Github Secrets
run: |
touch .env
echo JSON_RPC_PROVIDER=$JSON_RPC_PROVIDER >> .env
env:
JSON_RPC_PROVIDER: ${{ secrets.JSON_RPC_PROVIDER }}
- name: Hardhat Tests
run: |
yarn test
coverage:
needs: test
name: Coverage
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
- name: Download contracts artifacts
uses: actions/download-artifact@v3
with:
name: contracts-artifacts
path: build
- name: Yarn install
run: yarn install --frozen-lockfile
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ node_modules

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337

.openzeppelin
6 changes: 6 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "solhint:default",
"rules": {
"max-line-length": ["off", 120]
}
}
2 changes: 0 additions & 2 deletions contracts/helpers/TestContracts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import "../interfaces/INativeTokenAdapter.sol";
import "../interfaces/IFeeHandler.sol";
// import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "hardhat/console.sol";


/*
This is a test contract that serves as a mock entry point to the Sygma Bridge contract
Expand Down
44 changes: 44 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import globals from "globals";
import path from "node:path";
import {fileURLToPath} from "node:url";
import js from "@eslint/js";
import {FlatCompat} from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends("eslint:recommended"), {
languageOptions: {
globals: {
...globals.browser,
...globals.commonjs,
},

ecmaVersion: "latest",
sourceType: "module",
},

rules: {
"no-undef": "off",
"func-call-spacing": "off",

"max-len": ["error", {
code: 120,
}],

"new-parens": "error",
"no-caller": "error",
"no-bitwise": "off",
"no-console": "off",
"no-var": "error",
"object-curly-spacing": ["error", "never"],
"prefer-const": "error",
quotes: ["error", "double"],
semi: "off",
},
}];
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require("@nomicfoundation/hardhat-toolbox");

const dotenv = require('dotenv');
const dotenv = require("dotenv");

dotenv.config();

Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"repository": "https://github.com/sygmaprotocol/sprinter-solidity-periphery.git",
"author": "ChainSafe Systems",
"license": "LGPL-3.0-only",
"scripts": {
"compile": "npx hardhat compile",
"test": "npx hardhat test",
"lint": "npm run lint:solidity && npm run lint:js",
"lint:solidity": "solhint contracts/**/*.sol",
"lint:js": "npx eslint"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
"@nomicfoundation/hardhat-ethers": "^3.0.8",
Expand All @@ -19,9 +26,11 @@
"@types/mocha": ">=9.1.0",
"chai": "4.3.7",
"dotenv": "^16.4.5",
"eslint": "^9.16.0",
"ethers": "^6.13.4",
"hardhat": "^2.22.16",
"hardhat-gas-reporter": "^1.0.8",
"solhint": "^5.0.3",
"solidity-coverage": "^0.8.1",
"ts-node": ">=8.0.0",
"typechain": "^8.3.0",
Expand Down
4 changes: 2 additions & 2 deletions test/swapAdapter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// The Licensed Work is (c) 2022 Sygma
// SPDX-License-Identifier: LGPL-3.0-only

const { expect } = require("chai");
const { createResourceID, createERCDepositData, createOptionalContractCallDepositData } = require("./helpers.js");
const {expect} = require("chai");
const {createResourceID, createERCDepositData, createOptionalContractCallDepositData} = require("./helpers.js");

describe("SwapAdapter", function () {
const resourceID_Native = "0x0000000000000000000000000000000000000000000000000000000000000650";
Expand Down
Loading

0 comments on commit df6745c

Please sign in to comment.