Skip to content

Commit 19b6594

Browse files
authored
use a makefile (#120)
1 parent 7ad9d61 commit 19b6594

File tree

7 files changed

+112
-136
lines changed

7 files changed

+112
-136
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@ on:
66
pull_request:
77
branches: [main, agave-2.2.0, agave-2.3.0]
88

9-
env:
10-
NIGHTLY_TOOLCHAIN: nightly-2024-11-22
11-
SOLANA_VERSION: 2.2.0
9+
env: {}
1210

1311
jobs:
1412
rust_fmt:
1513
name: Rustfmt
1614
runs-on: ubuntu-latest
1715
steps:
1816
- uses: actions/checkout@v4
17+
- name: Get nightly toolchain version
18+
id: nightly
19+
run: echo "version=$(make nightly-version)" >> $GITHUB_OUTPUT
1920
- uses: dtolnay/rust-toolchain@master
2021
with:
21-
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
22+
toolchain: ${{ steps.nightly.outputs.version }}
2223
components: rustfmt
2324
- name: Run format
24-
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} fmt --all -- --check
25+
run: make format-check
2526

2627
rust_clippy:
2728
name: Clippy
@@ -36,12 +37,15 @@ jobs:
3637
key: cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
3738
restore-keys: |
3839
cargo-clippy-
40+
- name: Get nightly toolchain version
41+
id: nightly
42+
run: echo "version=$(make nightly-version)" >> $GITHUB_OUTPUT
3943
- uses: dtolnay/rust-toolchain@master
4044
with:
41-
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
45+
toolchain: ${{ steps.nightly.outputs.version }}
4246
components: clippy
4347
- name: Run clippy
44-
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} clippy --all --all-features --all-targets -- --deny=warnings
48+
run: make clippy
4549

4650
cargo_build_test:
4751
name: Cargo Build and Test
@@ -56,16 +60,17 @@ jobs:
5660
key: cargo-build-sbf-${{ hashFiles('**/Cargo.lock') }}
5761
restore-keys: |
5862
cargo-build-sbf-
63+
- name: Get Solana version
64+
id: solana
65+
run: echo "version=$(make solana-version)" >> $GITHUB_OUTPUT
5966
- uses: metaplex-foundation/actions/install-solana@v1
6067
with:
6168
cache: true
62-
version: ${{ env.SOLANA_VERSION }}
69+
version: ${{ steps.solana.outputs.version }}
6370
- name: Build test programs
64-
run: |
65-
cargo build-sbf --manifest-path test-programs/cpi-target/Cargo.toml
66-
cargo build-sbf --manifest-path test-programs/primary/Cargo.toml
71+
run: make build-test-programs
6772
- name: Test
68-
run: cargo test --all-features
73+
run: make test
6974

7075
audit_rust:
7176
name: Audit Rust
@@ -84,4 +89,4 @@ jobs:
8489
with:
8590
tool: cargo-audit
8691
- name: Run cargo-audit
87-
run: bash scripts/audit.sh
92+
run: make audit

.github/workflows/publish.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
workflow_dispatch:
55

66
env:
7-
NIGHTLY_TOOLCHAIN: nightly-2024-11-22
8-
SOLANA_VERSION: 2.2.0
97
TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
108

119
jobs:
@@ -24,17 +22,23 @@ jobs:
2422
key: cargo-build-sbf-${{ hashFiles('**/Cargo.lock') }}
2523
restore-keys: |
2624
cargo-build-sbf-
25+
- name: Get nightly toolchain version
26+
id: nightly
27+
run: echo "version=$(make nightly-version)" >> $GITHUB_OUTPUT
2728
- uses: dtolnay/rust-toolchain@master
2829
with:
29-
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
30+
toolchain: ${{ steps.nightly.outputs.version }}
3031
components: rustfmt, clippy
32+
- name: Get Solana version
33+
id: solana
34+
run: echo "version=$(make solana-version)" >> $GITHUB_OUTPUT
3135
- uses: metaplex-foundation/actions/install-solana@v1
3236
with:
3337
cache: true
34-
version: ${{ env.SOLANA_VERSION }}
38+
version: ${{ steps.solana.outputs.version }}
3539
- name: Prepublish
3640
shell: bash
37-
run: bash scripts/prepublish.sh
41+
run: make prepublish
3842

3943
publish:
4044
name: Publish
@@ -52,10 +56,13 @@ jobs:
5256
key: cargo-build-sbf-${{ hashFiles('**/Cargo.lock') }}
5357
restore-keys: |
5458
cargo-build-sbf-
59+
- name: Get Solana version
60+
id: solana
61+
run: echo "version=$(make solana-version)" >> $GITHUB_OUTPUT
5562
- uses: metaplex-foundation/actions/install-solana@v1
5663
with:
5764
cache: true
58-
version: ${{ env.SOLANA_VERSION }}
65+
version: ${{ steps.solana.outputs.version }}
5966
- name: Publish
6067
shell: bash
61-
run: bash scripts/publish.sh --locked
68+
run: make publish ARGS=--locked

Makefile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
NIGHTLY_TOOLCHAIN := nightly-2024-11-22
2+
SOLANA_VERSION := 2.2.0
3+
4+
.PHONY: audit build-test-programs prepublish publish format format-check clippy test nightly-version solana-version
5+
6+
# Print the nightly toolchain version for CI
7+
nightly-version:
8+
@echo $(NIGHTLY_TOOLCHAIN)
9+
10+
# Print the Solana version for CI
11+
solana-version:
12+
@echo $(SOLANA_VERSION)
13+
14+
# Security audit with ignored advisories
15+
audit:
16+
@cargo audit \
17+
--ignore RUSTSEC-2022-0093 \
18+
--ignore RUSTSEC-2024-0344 \
19+
--ignore RUSTSEC-2024-0421 \
20+
--ignore RUSTSEC-2024-0376 \
21+
--ignore RUSTSEC-2025-0009
22+
# RUSTSEC-2022-0093: ed25519-dalek: Double Public Key Signing Function Oracle Attack
23+
# RUSTSEC-2024-0344: curve25519-dalek
24+
# RUSTSEC-2024-0421: idna accepts Punycode labels that do not produce any non-ASCII when decoded
25+
# RUSTSEC-2024-0376: Remotely exploitable Denial of Service in Tonic
26+
# RUSTSEC-2025-0009: Some AES functions may panic when overflow checking is enabled
27+
28+
# Build test programs
29+
build-test-programs:
30+
@cargo build-sbf --manifest-path test-programs/cpi-target/Cargo.toml
31+
@cargo build-sbf --manifest-path test-programs/primary/Cargo.toml
32+
33+
# Pre-publish checks
34+
prepublish:
35+
@agave-install init $(SOLANA_VERSION)
36+
@rm -rf target
37+
@cargo build
38+
@$(MAKE) build-test-programs
39+
@$(MAKE) format-check
40+
@$(MAKE) clippy
41+
@$(MAKE) test
42+
43+
# Publish crates in order
44+
publish:
45+
@set -e && set -u && set -o pipefail && \
46+
CRATES=( \
47+
"mollusk-svm-error" \
48+
"mollusk-svm-keys" \
49+
"mollusk-svm-fuzz-fs" \
50+
"mollusk-svm-fuzz-fixture" \
51+
"mollusk-svm-fuzz-fixture-firedancer" \
52+
"mollusk-svm" \
53+
"mollusk-svm-bencher" \
54+
"mollusk-svm-programs-memo" \
55+
"mollusk-svm-programs-token" \
56+
"mollusk-svm-cli" \
57+
) && \
58+
for crate in "$${CRATES[@]}"; do \
59+
echo "Publishing $$crate..." && \
60+
cargo publish -p $$crate --token $$TOKEN $(ARGS) && \
61+
echo "$$crate published successfully!" && \
62+
sleep 5; \
63+
done && \
64+
echo "All crates published successfully!"
65+
66+
# Format code
67+
format:
68+
@cargo +$(NIGHTLY_TOOLCHAIN) fmt --all
69+
70+
# Check formatting
71+
format-check:
72+
@cargo +$(NIGHTLY_TOOLCHAIN) fmt --all -- --check
73+
74+
# Run clippy linter
75+
clippy:
76+
@cargo +$(NIGHTLY_TOOLCHAIN) clippy --all --all-features --all-targets -- -D warnings
77+
78+
# Run tests
79+
test:
80+
@cargo test --all-features

scripts/audit.sh

Lines changed: 0 additions & 62 deletions
This file was deleted.

scripts/build-test-programs.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

scripts/prepublish.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

scripts/publish.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)