diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index d8bd79b..98e1130 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -14,8 +14,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} + # with: + # token: ${{ secrets.GITHUB_TOKEN }} - name: Install foundry uses: foundry-rs/foundry-toolchain@v1 @@ -34,6 +34,7 @@ jobs: forge coverage | grep '^|' | grep -v 'test/' echo EOF } >> "$GITHUB_OUTPUT" + echo $GITHUB_OUTPUT env: FOUNDRY_RPC_URL: "${{ secrets.RPC_URL }}" @@ -51,7 +52,7 @@ jobs: const currentCoverage = fs.readFileSync(file, "utf8").trim(); const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim(); if (newCoverage != currentCoverage) { - core.setFailed(`Code coverage not updated. Run : forge coverage | grep '^|' | grep -v 'test/' > coverage.txt`); + core.setFailed(`Code coverage not updated. Run : forge coverage --no-match-coverage "(test)" | grep '^|' > coverage.txt`); } - name: Comment on PR diff --git a/.gitignore b/.gitignore index 95a845d..39541da 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /out /cache /coverage +/report lcov.info .DS_Store .env @@ -10,7 +11,3 @@ lcov.info broadcast/*/31337 deployments/**/31337.* - -# storage layout checker library -storage_check_cache -storage_check_report \ No newline at end of file diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index 2529d83..216f766 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -8,8 +8,8 @@ import {Counter} from 'src/Counter.sol'; contract Deploy is Script { using stdJson for string; - function run() public { + function run() public returns (Counter) { uint256 initialNumber = 5; - new Counter(initialNumber); + return new Counter(initialNumber); } } diff --git a/test/Counter.t.sol b/test/Counter.t.sol index 9770497..084b23d 100644 --- a/test/Counter.t.sol +++ b/test/Counter.t.sol @@ -3,11 +3,11 @@ pragma solidity 0.8.26; import {GasSnapshot} from 'forge-gas-snapshot/GasSnapshot.sol'; import 'forge-std/Test.sol'; -import 'test/util/TestHelpers.sol'; +import {Deploy} from 'script/Deploy.s.sol'; import {Counter} from 'src/Counter.sol'; -abstract contract Deployed is Test, TestHelpers { +abstract contract Deployed is Test { Counter counter; function setUp() public virtual { @@ -38,3 +38,15 @@ contract CounterTest_Deployed is Deployed, GasSnapshot { snapLastCall('Set counter number'); } } + +contract DeploymentTest is Test { + Counter counter; + + function setUp() public virtual { + counter = new Deploy().run(); + } + + function test_IsDeployedCorrectly() public view { + assertEq(counter.number(), 5); + } +} diff --git a/test/util/TestHelpers.sol b/test/util/TestHelpers.sol deleted file mode 100644 index 934127f..0000000 --- a/test/util/TestHelpers.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.26; - -import 'forge-std/Test.sol'; - -abstract contract TestHelpers is Test { - Account internal DEPLOYER; - - constructor() { - DEPLOYER = makeAccount('DEPLOYER'); - vm.setEnv('PRIVATE_KEY', vm.toString(DEPLOYER.key)); - } -}