Skip to content

Commit

Permalink
feat: Add basic CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jhelison committed Feb 4, 2024
1 parent 4682ecc commit b60973d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Solidity CI

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

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
npm-version: [10.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install npm ${{ matrix.npm-version }}
run: npm install -g npm@${{ matrix.npm-version }}

- name: Install dependencies
run: yarn install

- name: Compile contracts
run: yarn compile

- name: Run linter
run: yarn lint

- name: Run tests
run: yarn test

- name: Run coverage
run: yarn coverage
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ A simple, yet effective starting point for your Solidity projects.
Features
- Clear and concise project structure
- TypeScript integration for enhanced developer experience
- Solidity and Github actions CI
- Hardhat configuration for compilation, testing, deployment, and more
- Solhint integration for linting and code quality checks
- Basic testing setup using Mocha and Chai
Expand Down
3 changes: 3 additions & 0 deletions contracts/Lock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ contract Lock {
event Withdrawal(uint256 amount, uint256 when);

constructor(uint256 _unlockTime) payable {
// solhint-disable-next-line
require(
block.timestamp < _unlockTime,
"Unlock time should be in the future"
Expand All @@ -24,7 +25,9 @@ contract Lock {
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);

// solhint-disable-next-line
require(block.timestamp >= unlockTime, "You can't withdraw yet");
// solhint-disable-next-line
require(msg.sender == owner, "You aren't the owner");

emit Withdrawal(address(this).balance, block.timestamp);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ethers": "^6.4.0",
"hardhat": "^2.19.4",
"hardhat-gas-reporter": "^1.0.8",
"solhint": "^4.0.0",
"solhint": "^4.1.1",
"solidity-coverage": "^0.8.0",
"ts-node": "^10.9.2",
"typechain": "^8.3.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3871,10 +3871,10 @@ [email protected]:
semver "^5.5.0"
tmp "0.0.33"

solhint@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/solhint/-/solhint-4.0.0.tgz"
integrity sha512-bFViMcFvhqVd/HK3Roo7xZXX5nbujS7Bxeg5vnZc9QvH0yCWCrQ38Yrn1pbAY9tlKROc6wFr+rK1mxYgYrjZgA==
solhint@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/solhint/-/solhint-4.1.1.tgz#137c935ef028f01ba13687a1f237288d94dae1bf"
integrity sha512-7G4iF8H5hKHc0tR+/uyZesSKtfppFIMvPSW+Ku6MSL25oVRuyFeqNhOsXHfkex64wYJyXs4fe+pvhB069I19Tw==
dependencies:
"@solidity-parser/parser" "^0.16.0"
ajv "^6.12.6"
Expand Down

0 comments on commit b60973d

Please sign in to comment.