Skip to content

Commit d6d08fd

Browse files
committed
chore: Improve CI workflows and enhance NFT tests
- Updated contract test workflow to skip unnecessary Node.js dependencies during contract builds. - Enhanced output logging for compilation warnings in contract tests, saving logs for review. - Modified NFTGatingEnhanced tests to ensure proper funding of the jar before withdrawals, improving test reliability. - Adjusted install-deps.sh to skip Foundry installation in CI environments, streamlining the setup process. These changes enhance the efficiency of CI processes and improve the robustness of NFT-related tests.
1 parent 38227fd commit d6d08fd

File tree

3 files changed

+53
-18
lines changed

3 files changed

+53
-18
lines changed

.github/workflows/contract-tests.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ jobs:
3030
with:
3131
version: nightly
3232

33-
- name: Build contracts (leveraging deploy.sh logic)
33+
# Skip all pnpm/Node.js dependencies - contracts tests don't need them
34+
35+
- name: Build contracts
3436
run: |
35-
echo "🔧 Building contracts with enhanced validation..."
37+
echo "🔧 Building contracts..."
3638
cd contracts
3739
38-
# Use forge build with same flags as deploy.sh for consistency
40+
# Build contracts with size reporting
3941
forge build --sizes
4042
4143
if [ $? -ne 0 ]; then
@@ -104,9 +106,14 @@ jobs:
104106
echo "🔍 Running basic security analysis..."
105107
cd contracts
106108
107-
# Check for common issues using forge
108109
echo "📋 Checking compilation warnings:"
109-
forge build 2>&1 | grep -E "(Warning|Error):" || echo "No compilation warnings found"
110+
forge build 2>&1 | tee build-warnings.log
111+
112+
if grep -E "(Warning|Error):" build-warnings.log; then
113+
echo "⚠️ Found compilation warnings/errors"
114+
else
115+
echo "✅ No compilation warnings found"
116+
fi
110117
111118
echo ""
112119
echo "📋 Contract complexity analysis:"
@@ -128,6 +135,7 @@ jobs:
128135
contracts/out/
129136
contracts/lcov.info
130137
contracts/cache/
138+
contracts/build-warnings.log
131139
retention-days: 7
132140

133141
- name: Test Summary
@@ -145,4 +153,4 @@ jobs:
145153
echo "❌ Contract tests failed"
146154
echo "💡 Check output above for details"
147155
echo "🔧 Fix issues before deployment"
148-
fi
156+
fi

contracts/test/NFTGatingEnhanced.t.sol

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,14 @@ contract NFTGatingEnhancedTest is Test {
123123

124124
// RESTORED: Basic NFT gating tests - testing currently available functionality
125125
function test_BasicNFTWithdrawal_ERC721() public {
126-
// Ensure jar has sufficient balance and user starts fresh
127-
vm.deal(address(jar), 10 ether);
126+
// Fund the jar properly using depositETH (this updates currencyHeldByJar)
127+
address depositor = address(0x999);
128+
vm.deal(depositor, 15 ether); // Give depositor enough ETH including fees
129+
130+
vm.prank(depositor);
131+
jar.depositETH{value: 10 ether}();
132+
133+
// Reset user balance for clean test
128134
vm.deal(user, 0);
129135

130136
// Mint ERC721 token to user
@@ -154,8 +160,14 @@ contract NFTGatingEnhancedTest is Test {
154160
}
155161

156162
function test_BasicNFTWithdrawal_ERC1155() public {
157-
// Ensure jar has sufficient balance and user starts fresh
158-
vm.deal(address(jar), 10 ether);
163+
// Fund the jar properly using depositETH (this updates currencyHeldByJar)
164+
address depositor = address(0x999);
165+
vm.deal(depositor, 15 ether); // Give depositor enough ETH including fees
166+
167+
vm.prank(depositor);
168+
jar.depositETH{value: 10 ether}();
169+
170+
// Reset user balance for clean test
159171
vm.deal(user, 0);
160172

161173
// Mint ERC1155 tokens to user
@@ -288,8 +300,14 @@ contract NFTGatingEnhancedTest is Test {
288300
}
289301

290302
function test_GasConsumptionWithinLimits() public {
291-
// Ensure jar has sufficient balance and user starts fresh
292-
vm.deal(address(jar), 10 ether);
303+
// Fund the jar properly using depositETH (this updates currencyHeldByJar)
304+
address depositor = address(0x999);
305+
vm.deal(depositor, 15 ether); // Give depositor enough ETH including fees
306+
307+
vm.prank(depositor);
308+
jar.depositETH{value: 10 ether}();
309+
310+
// Reset user balance for clean test
293311
vm.deal(user, 0);
294312

295313
// Mint NFT to user

scripts/install-deps.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ else
6464
echo -e "${GREEN}✅ pnpm v$(get_version pnpm) already installed${NC}"
6565
fi
6666

67-
# Install Foundry if missing
67+
# Install Foundry if missing (skip in CI where official action handles it)
6868
if ! command_exists forge || ! command_exists anvil; then
69-
echo -e "${YELLOW}🔧 Installing Foundry...${NC}"
69+
# Skip Foundry installation in CI environments
70+
if [ "$CI" = "true" ] || [ "$GITHUB_ACTIONS" = "true" ]; then
71+
echo -e "${YELLOW}⏭️ Skipping Foundry installation in CI (handled by official action)${NC}"
72+
else
73+
echo -e "${YELLOW}🔧 Installing Foundry...${NC}"
7074

7175
# Check if Windows (Git Bash, WSL detection)
7276
if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
@@ -97,13 +101,18 @@ if ! command_exists forge || ! command_exists anvil; then
97101
echo " Try running: foundryup"
98102
echo " Or visit: https://book.getfoundry.sh/getting-started/installation"
99103
exit 1
104+
fi
105+
106+
echo -e "${GREEN}✅ Foundry installed successfully${NC}"
107+
echo -e "${YELLOW}💡 You may need to restart your terminal or run: source ~/.bashrc${NC}"
100108
fi
101-
102-
echo -e "${GREEN}✅ Foundry installed successfully${NC}"
103-
echo -e "${YELLOW}💡 You may need to restart your terminal or run: source ~/.bashrc${NC}"
104109
else
105110
FORGE_VERSION=$(get_version forge)
106-
echo -e "${GREEN}✅ Foundry already installed: $FORGE_VERSION${NC}"
111+
if [ "$CI" = "true" ] || [ "$GITHUB_ACTIONS" = "true" ]; then
112+
echo -e "${GREEN}✅ Foundry available in CI: $FORGE_VERSION${NC}"
113+
else
114+
echo -e "${GREEN}✅ Foundry already installed: $FORGE_VERSION${NC}"
115+
fi
107116
fi
108117

109118
echo ""

0 commit comments

Comments
 (0)