Skip to content

Commit

Permalink
Merge pull request #108 from hackdays-io/gactions
Browse files Browse the repository at this point in the history
テスト実行とガスレポートをGitHub Actionsに
  • Loading branch information
yu23ki14 authored Sep 29, 2024
2 parents 74a7f56 + 0a78f57 commit 052ef32
Show file tree
Hide file tree
Showing 5 changed files with 12,068 additions and 258 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/test-contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Test Contracts

on:
# mainブランチにプッシュされたとき、またはプルリクエストが作成されたときに実行
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: npm install
working-directory: ./pkgs/contract

- name: Run Hardhat tests
run: |
npx hardhat test > ./test-results.txt
echo "\`\`\`\n$(cat ./test-results.txt)" > ./comments
working-directory: ./pkgs/contract
env:
PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

- name: Generate Gas Report
run: |
npx hardhat test --network hardhat > ./gas-report.txt
echo "\n### Gas Report" >> ./comments
echo "\`\`\`\n$(cat ./gas-report.txt)" >> ./comments
working-directory: ./pkgs/contract

- name: Upload Gas Report as Artifact
uses: actions/upload-artifact@v3
with:
name: gas-report
path: ./pkgs/contract/gas-report.txt

# GitHub PRにテスト結果とガスレポートをコメントとして投稿
- name: Post comments
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
URL: ${{ github.event.pull_request.html_url }}
run: gh pr comment -F ./comments "${URL}"
Loading

0 comments on commit 052ef32

Please sign in to comment.