Skip to content

Commit 4e4a97a

Browse files
committed
steel clippy fmt and contributing guidelines
1 parent 46f66f3 commit 4e4a97a

File tree

3 files changed

+131
-25
lines changed

3 files changed

+131
-25
lines changed

.github/workflows/steel.yml

Lines changed: 97 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,50 @@ jobs:
9090
echo "matrix=[$(echo $indices | tr ' ' ',')]" >> $GITHUB_OUTPUT
9191
fi
9292
93+
fmt:
94+
needs: changes
95+
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.total_projects != '0' }}
96+
name: Rustfmt
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v4
100+
- uses: dtolnay/rust-toolchain@stable
101+
with:
102+
components: rustfmt
103+
- uses: mozilla-actions/[email protected]
104+
- name: Run fmt
105+
run: |
106+
readarray -t projects < <(echo '${{ needs.changes.outputs.changed_projects }}' | jq -r '.[]')
107+
for project in "${projects[@]}"; do
108+
if [ -f "$project/Cargo.toml" ]; then
109+
cd "$project"
110+
cargo fmt --check
111+
cd - > /dev/null
112+
fi
113+
done
114+
115+
clippy:
116+
needs: changes
117+
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.total_projects != '0' }}
118+
name: Clippy
119+
runs-on: ubuntu-latest
120+
steps:
121+
- uses: actions/checkout@v4
122+
- uses: dtolnay/rust-toolchain@stable
123+
with:
124+
components: clippy
125+
- uses: mozilla-actions/[email protected]
126+
- name: Run clippy
127+
run: |
128+
readarray -t projects < <(echo '${{ needs.changes.outputs.changed_projects }}' | jq -r '.[]')
129+
for project in "${projects[@]}"; do
130+
if [ -f "$project/Cargo.toml" ]; then
131+
cd "$project"
132+
cargo clippy -- -D warnings
133+
cd - > /dev/null
134+
fi
135+
done
136+
93137
build-and-test:
94138
needs: changes
95139
if: needs.changes.outputs.total_projects != '0'
@@ -120,27 +164,53 @@ jobs:
120164
cd "$project" || return 1
121165
122166
# Install dependencies
123-
if ! pnpm install --frozen-lockfile; then
124-
echo "::error::pnpm install failed for $project"
125-
echo "$project: pnpm install failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
126-
cd - > /dev/null
127-
return 1
128-
fi
167+
if [ -f "package.json" ]; then
168+
if ! pnpm install --frozen-lockfile; then
169+
echo "::error::pnpm install failed for $project"
170+
echo "$project: pnpm install failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
171+
cd - > /dev/null
172+
return 1
173+
fi
129174
130-
# Build
131-
if ! pnpm build; then
132-
echo "::error::build failed for $project"
133-
echo "$project: build failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
134-
cd - > /dev/null
135-
return 1
136-
fi
175+
# Build
176+
if ! pnpm build; then
177+
echo "::error::build failed for $project"
178+
echo "$project: build failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
179+
cd - > /dev/null
180+
return 1
181+
fi
137182
138-
# Test
139-
if ! pnpm build-and-test; then
140-
echo "::error::tests failed for $project"
141-
echo "$project: tests failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
142-
cd - > /dev/null
143-
return 1
183+
# Test
184+
if ! pnpm build-and-test; then
185+
echo "::error::tests failed for $project"
186+
echo "$project: tests failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
187+
cd - > /dev/null
188+
return 1
189+
fi
190+
else
191+
# Use Steel CLI
192+
if ! cargo install steel-cli; then
193+
echo "::error::steel-cli installation failed for $project"
194+
echo "$project: steel-cli installation failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
195+
cd - > /dev/null
196+
return 1
197+
fi
198+
199+
# Build
200+
if ! steel build; then
201+
echo "::error::steel build failed for $project"
202+
echo "$project: steel build failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
203+
cd - > /dev/null
204+
return 1
205+
fi
206+
207+
# Test
208+
if ! steel test; then
209+
echo "::error::steel test failed for $project"
210+
echo "$project: steel test failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
211+
cd - > /dev/null
212+
return 1
213+
fi
144214
fi
145215
146216
echo "Build and tests succeeded for $project with $solana_version version."
@@ -184,21 +254,29 @@ jobs:
184254
with:
185255
solana-cli-version: stable
186256
- name: Build and Test with Stable
257+
env:
258+
SCCACHE_GHA_ENABLED: "true"
259+
RUSTC_WRAPPER: "sccache"
187260
run: |
188261
source build_and_test.sh
189262
solana -V
190263
rustc -V
191264
process_projects "stable"
265+
sccache --show-stats
192266
- name: Setup Solana 1.18.17
193267
uses: heyAyushh/[email protected]
194268
with:
195269
solana-cli-version: 1.18.17
196270
- name: Build and Test with 1.18.17
271+
env:
272+
SCCACHE_GHA_ENABLED: "true"
273+
RUSTC_WRAPPER: "sccache"
197274
run: |
198275
source build_and_test.sh
199276
solana -V
200277
rustc -V
201278
process_projects "1.18.17"
279+
sccache --show-stats
202280
203281
- name: Set failed projects output
204282
id: set-failed

CONTRIBUTING.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,38 @@ Specifically for code in this repo:
2323
1. Use pnpm as the default package manager for the project. You can [install pnpm by following the instructions](https://pnpm.io/installation). Commit `pnpm-lock.yaml` to the repository.
2424

2525
2. Anchor programs should be in directory `anchor`, programs written for Solana Native should be in directory `native`, TypeScript in `poseidon` and Python in `seahorse`.
26+
- Project path structure: `/program-examples/category/example-name/steel`
2627

2728
3. Tests for Solana native programs, steel framework programs, and Anchor should be written with [solana-bankrun](https://kevinheavey.github.io/solana-bankrun)
2829

29-
4. For Solana native programs and Steel framework programs ensure adding these mandatory pnpm run scripts to your `package.json` file for successful CI/CD builds:
30+
4. Steel framework programs must be organized as a Cargo workspace with separate projects for API and program:
31+
- Project path structure: `/program-examples/category/example-name/steel`
32+
- Initialise project using `steel new <name>`
33+
- Must be a Cargo workspace with two separate projects:
34+
- `api`: Contains API-related code
35+
- `program`: Contains the program implementation
36+
- Steel projects should NOT be added in the root [`Cargo.toml` file](https://github.com/solana-developers/program-examples/blob/main/Cargo.toml)
37+
38+
This structure ensures proper organization and separation of concerns.
39+
40+
5. For Steel framework programs:
41+
- Steel CLI is the recommended way to build and test programs:
42+
```bash
43+
# Install Steel CLI (one-time setup)
44+
cargo install steel-cli
45+
46+
# Create a new Steel project
47+
steel new <name>
48+
49+
# Build the program
50+
steel build
51+
52+
# Run tests
53+
steel test
54+
```
55+
- Alternatively, you can use package.json scripts if you need custom build/test configurations as Solana native one described below.
56+
57+
6. For Solana native programs ensure adding these mandatory pnpm run scripts to your `package.json` file for successful CI/CD builds:
3058

3159
```json
3260
"scripts": {
@@ -37,20 +65,21 @@ Specifically for code in this repo:
3765
},
3866
```
3967

40-
5. Test command for Anchor should execute `pnpm test` instead of `yarn run test` for anchor programs. Replace `yarn` with `pnpm` in `[script]` table inside [Anchor.toml file.](https://www.anchor-lang.com/docs/manifest#scripts-required-for-testing)
68+
Alternatively, You can add `steel test` and `steel build` as commands according to your project.
4169

42-
6. TypeScript, JavaScript and JSON files are formatted and linted using
70+
7. Test command for Anchor should execute `pnpm test` instead of `yarn run test` for anchor programs. Replace `yarn` with `pnpm` in `[script]` table inside [Anchor.toml file.](https://www.anchor-lang.com/docs/manifest#scripts-required-for-testing)
71+
72+
8. TypeScript, JavaScript and JSON files are formatted and linted using
4373
[Biome](https://biomejs.dev/). Execute the following command to format and lint your code at the root of this project before submitting a pull request:
4474

4575
```bash
4676
pnpm fix
4777
```
4878

49-
7. Some projects can be ignored from the building and testing process by adding the project name to the `.gitignore` file.
79+
9. Some projects can be ignored from the building and testing process by adding the project name to the `.gitignore` file.
5080
When removing or updating an example, please ensure that the example is removed from the `.gitignore` file
5181
and there's a change in that example's directory.
5282

53-
5483
## Code of Conduct
5584

5685
We are committed to providing a friendly, safe, and welcoming environment for all contributors, regardless of their background, experience level, or personal characteristics. As a contributor, you are expected to:

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ members = [
1515
"basics/cross-program-invocation/anchor/programs/*",
1616
"basics/hello-solana/native/program",
1717
"basics/hello-solana/anchor/programs/*",
18-
"basics/hello-solana/steel/program",
1918
"basics/pda-rent-payer/native/program",
2019
"basics/pda-rent-payer/anchor/programs/*",
2120
"basics/processing-instructions/native/program",

0 commit comments

Comments
 (0)