Skip to content

Commit dd54752

Browse files
authored
ci: setup style convention infrastructure (#144)
* Modify build workflow * Configure verify workflow * Add husky to prevent unlinted/unformatted commits or code
1 parent 55590fd commit dd54752

File tree

7 files changed

+93
-26
lines changed

7 files changed

+93
-26
lines changed

.github/workflows/build.yml

+1-25
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ jobs:
3333
steps:
3434
# Cloning
3535
- uses: actions/checkout@v2
36-
with:
37-
repository: "syntest-framework/syntest-framework"
38-
token: ${{ secrets.SYNTEST_CI }}
39-
path: syntest-framework
40-
- uses: actions/checkout@v2
41-
with:
42-
path: syntest-solidity
4336

4437
# Setup
4538
- name: Use Node.js ${{ matrix.node-version }}
@@ -61,31 +54,14 @@ jobs:
6154
${{ runner.os }}-node-
6255
${{ runner.os }}-
6356
64-
# SynTest Framework
65-
- name: Framework - Install Dependencies
66-
run: npm install
67-
working-directory: syntest-framework
68-
- name: Framework - Build framework
69-
run: npm run build
70-
working-directory: syntest-framework
71-
- name: Framework - Link
72-
run: npm link
73-
working-directory: syntest-framework
74-
7557
# Dependencies
7658
- name: Solidity - Install Dependencies
7759
run: npm install
78-
working-directory: syntest-solidity
79-
- name: Solidity - Link Local Framework
80-
run: npm link @syntest/core
81-
working-directory: syntest-solidity
8260

8361
# Building
84-
- name: Solidity - Build Solidity
62+
- name: Solidity - Build
8563
run: npm run build
86-
working-directory: syntest-solidity
8764

8865
# Testing
8966
- name: Solidity - Run Tests
9067
run: npm test
91-
working-directory: syntest-solidity

.github/workflows/verify.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: verify
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
paths-ignore:
7+
- "docs/"
8+
- "**.md"
9+
pull_request:
10+
branches: [main, develop]
11+
paths-ignore:
12+
- "docs/"
13+
- "**.md"
14+
15+
jobs:
16+
test:
17+
runs-on: ${{ matrix.os }}
18+
19+
strategy:
20+
# Keep running other versions when a job fails
21+
fail-fast: false
22+
23+
matrix:
24+
# Run the pipeline on all the currently supported OS versions
25+
os: [ubuntu-latest]
26+
27+
# Run the pipeline on all the currently supported LTS versions and the upcoming version
28+
node-version: [19]
29+
30+
# Run the pipeline on all the currently supported architectures
31+
architecture: [x64]
32+
33+
steps:
34+
# Cloning
35+
- uses: actions/checkout@v2
36+
37+
# Setup
38+
- name: Use Node.js ${{ matrix.node-version }}
39+
uses: actions/setup-node@v2
40+
with:
41+
node-version: ${{ matrix.node-version }}
42+
architecture: ${{ matrix.architecture }}
43+
44+
# Caching
45+
- name: Get NPM cache directory
46+
id: npm-cache-dir
47+
run: echo "::set-output name=dir::$(npm config get cache)"
48+
- name: Cache Node.js modules
49+
uses: actions/cache@v2
50+
with:
51+
path: ${{ steps.npm-cache-dir.outputs.dir }}
52+
key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}
53+
restore-keys: |
54+
${{ runner.os }}-node-
55+
${{ runner.os }}-
56+
57+
# Dependencies
58+
- name: Solidity - Install Dependencies
59+
run: npm install
60+
61+
# Format
62+
- name: Solidity - Run Formatter
63+
run: npm run format:check
64+
65+
# Linting
66+
- name: Solidity - Run Linter
67+
run: npm run lint

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no -- commitlint --edit

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

commitlint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ["@commitlint/config-conventional"],
3+
};

package.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"format:check": "prettier --config .prettierrc.json --ignore-path .prettierignore --check .",
4242
"lint": "eslint --config .eslintrc.json --ignore-path .eslintignore .",
4343
"lint:fix": "eslint --config .eslintrc.json --ignore-path .eslintignore . --fix",
44-
"prepare": "npm run build",
44+
"prepare": "husky install",
4545
"run": "truffle run syntest-solidity",
4646
"test": "mocha --config .mocharc.json",
4747
"test:coverage": "nyc mocha --config .mocharc.json",
@@ -70,6 +70,8 @@
7070
"web3-utils": "1.8.1"
7171
},
7272
"devDependencies": {
73+
"@commitlint/cli": "^17.4.2",
74+
"@commitlint/config-conventional": "^17.4.2",
7375
"@types/chai": "4.3.4",
7476
"@types/chai-as-promised": "7.1.1",
7577
"@types/mocha": "10.0.1",
@@ -78,8 +80,11 @@
7880
"@typescript-eslint/eslint-plugin": "5.45.1",
7981
"@typescript-eslint/parser": "5.45.1",
8082
"chai": "4.3.7",
83+
"commitlint": "^17.4.2",
8184
"eslint": "8.29.0",
8285
"eslint-config-prettier": "8.5.0",
86+
"husky": "^8.0.3",
87+
"lint-staged": "^13.1.0",
8388
"mocha": "10.2.0",
8489
"nyc": "15.1.0",
8590
"prettier": "2.8.1",
@@ -89,5 +94,11 @@
8994
},
9095
"engines": {
9196
"node": ">=10.24.0"
97+
},
98+
"lint-staged": {
99+
"**/*": [
100+
"npx prettier --config .prettierrc.json --ignore-path .prettierignore --write .",
101+
"npx eslint --config .eslintrc.json --ignore-path .eslintignore --fix ."
102+
]
92103
}
93104
}

src/util/network.ts

+2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ export function setNetwork(config: TruffleConfig, api: any): void {
7979
// eslint-disable-next-line
8080
export function setOuterConfigKeys(
8181
config: TruffleConfig,
82+
// eslint-disable-next-line
8283
api: any,
84+
// eslint-disable-next-line
8385
id: any
8486
): void {
8587
try {

0 commit comments

Comments
 (0)