-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba42de2
commit 6b26381
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
Setup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.9.0" | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v4 | ||
id: npm-cache | ||
with: | ||
path: | | ||
node_modules | ||
~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Install dependencies | ||
if: steps.npm-cache.outputs.cache-hit != 'true' | ||
run: npm i | ||
|
||
Test: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' # This line ensures that this job only runs on pull requests | ||
needs: Setup | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.9.0" | ||
|
||
- name: Cache node modules | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
node_modules | ||
~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Run tests | ||
run: npx hardhat test | ||
|
||
Coverage-Test: | ||
runs-on: ubuntu-latest | ||
needs: Setup | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.9.0" | ||
|
||
- name: Cache node modules | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
node_modules | ||
~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Run tests and generate coverage | ||
run: npx hardhat coverage | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} # required |