-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (82 loc) · 2.69 KB
/
Makefile
File metadata and controls
101 lines (82 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
SHELL := /usr/bin/env bash
.SHELLFLAGS := -euo pipefail -c
.DEFAULT_GOAL := build
PROGRAM_SO := ../target/deploy/contra_withdraw_program.so
PROGRAM_KEYPAIR := ../target/deploy/contra_withdraw_program-keypair.json
PROGRAM_ENV_KEY := WITHDRAW_PROGRAM_ID
.PHONY: install build fmt generate-idl generate-clients
.PHONY: unit-test integration-test integration-test-no-build all-test
.PHONY: unit-coverage coverage-html all-coverage
.PHONY: build-localnet build-devnet deploy-devnet
# Install dependencies
install:
pnpm install
# Build the program
build:
$(MAKE) generate-clients
cargo-build-sbf
# Format / lint code
fmt:
cargo fmt --all
@cd program && cargo clippy --all-targets -- -D warnings
@cd tests/integration-tests && cargo clippy --all-targets -- -D warnings
pnpm format
# Generate IDL from Codama annotations
generate-idl:
@echo "Generating IDL..."
pnpm run generate-idl
# Generate clients from IDL using Codama
generate-clients: generate-idl
@echo "Generating clients..."
pnpm run generate-clients
### Tests ###
# Run unit tests in program/
unit-test:
@echo "Running unit tests for withdraw program..."
pnpm test:unit
@cd program && cargo test
# Run integration tests without build (for CI composition)
integration-test-no-build:
@echo "Running integration tests for withdraw program..."
@cd tests/integration-tests && cargo test -- --nocapture
# Run integration tests (includes build)
integration-test: build integration-test-no-build
all-test: unit-test integration-test
# Run unit tests with coverage
unit-coverage:
@echo "Running unit tests with coverage..."
@mkdir -p ../coverage
@cd program && cargo llvm-cov --lib --tests --lcov --output-path ../../coverage/coverage-withdraw-unit.lcov
# Generate HTML coverage report
coverage-html:
@echo "Generating HTML coverage report..."
@mkdir -p ../coverage
@cd program && cargo llvm-cov --html --output-dir ../../coverage/coverage-withdraw-html
# Run all coverage tasks
all-coverage: unit-coverage coverage-html
#############
# Localnet
#############
build-localnet:
$(MAKE) generate-clients
cargo-build-sbf
@echo "Updating .env.local with program IDs..."
@../scripts/update-program-env.sh ../.env.local $(PROGRAM_ENV_KEY) $(PROGRAM_KEYPAIR)
#############
# Devnet
#############
# Build the program with devnet feature
build-devnet:
$(MAKE) generate-clients
cargo-build-sbf
# Deploy to devnet
deploy-devnet: build-devnet
@echo "Deploying to devnet..."
@if [ -z "$(DEPLOYER_KEY)" ]; then \
echo "Error: DEPLOYER_KEY parameter is required. Usage: make deploy-devnet DEPLOYER_KEY=/path/to/deployer-keypair.json"; \
exit 1; \
fi
solana program deploy $(PROGRAM_SO) \
--program-id $(PROGRAM_KEYPAIR) \
--keypair $(DEPLOYER_KEY) \
--url devnet