Skip to content

Commit 401366c

Browse files
authored
feat: Introduce Steel framework in program-examples (#128)
* add steel framework * add steel ci * add steel in workspace * fix workspace issue * fix rust fmt error * added steel in Contributing.md
1 parent ea26e37 commit 401366c

File tree

11 files changed

+2373
-608
lines changed

11 files changed

+2373
-608
lines changed

.github/workflows/steel.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Steel
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
types: [opened, synchronize, reopened]
11+
branches:
12+
- main
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
node-version: [20.x]
20+
solana-version: [stable]
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
check-latest: true
28+
- uses: heyAyushh/setup-solana@v5.4
29+
with:
30+
solana-cli-version: ${{ matrix.solana-version }}
31+
- run: solana block
32+
shell: bash
33+
- name: Install pnpm
34+
run: |
35+
npm install --global pnpm
36+
- name: Build Steel native programs
37+
run: |
38+
declare -a ProjectDirs=($(find . -type d -name "steel"| grep -v -f <(grep . .github/.ghaignore | grep -v '^$')))
39+
echo "Projects to Build:"
40+
printf "%s\n" "${ProjectDirs[@]}"
41+
for projectDir in "${ProjectDirs[@]}"; do
42+
echo "
43+
********
44+
Building $projectDir
45+
********"
46+
cd $projectDir
47+
if pnpm build; then
48+
echo "Build succeeded for $projectDir."
49+
else
50+
failed=true
51+
failed_builds+=($projectDir)
52+
echo "Build failed for $projectDir. Continuing with the next program."
53+
fi
54+
cd - > /dev/null
55+
done
56+
if [ "$failed" = true ]; then
57+
echo "Programs that failed building:"
58+
printf "%s\n" "${failed_builds[@]}"
59+
exit 1
60+
else
61+
echo "All programs built successfully."
62+
fi
63+
shell: bash
64+
65+
test:
66+
runs-on: ubuntu-latest
67+
strategy:
68+
matrix:
69+
node-version: [20.x]
70+
solana-version: [1.18.17, stable]
71+
steps:
72+
- uses: actions/checkout@v4
73+
- name: Use Node.js ${{ matrix.node-version }}
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: ${{ matrix.node-version }}
77+
check-latest: true
78+
- uses: heyAyushh/setup-solana@v5.4
79+
with:
80+
solana-cli-version: ${{ matrix.solana-version }}
81+
- run: solana block
82+
shell: bash
83+
- name: Install pnpm
84+
run: |
85+
npm install --global pnpm
86+
- name: Test Steel native programs
87+
run: |
88+
solana -V
89+
rustc -V
90+
declare -a ProjectDirs=($(find . -type d -name "steel"| grep -v -f <(grep . .github/.ghaignore | grep -v '^$')))
91+
echo "Projects to Test:"
92+
printf "%s\n" "${ProjectDirs[@]}"
93+
for projectDir in "${ProjectDirs[@]}"; do
94+
echo "
95+
********
96+
Testing $projectDir
97+
********"
98+
cd $projectDir
99+
pnpm install --frozen-lockfile
100+
if pnpm build-and-test; then
101+
echo "Tests succeeded for $projectDir."
102+
else
103+
failed=true
104+
failed_tests+=($projectDir)
105+
echo "Tests failed for $projectDir. Continuing with the next program."
106+
fi
107+
cd - > /dev/null
108+
done
109+
if [ "$failed" = true ]; then
110+
echo "*****************************"
111+
echo "Programs that failed testing:"
112+
printf "%s\n" "${failed_tests[@]}"
113+
exit 1
114+
else
115+
echo "All tests passed."
116+
fi
117+
shell: bash

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Specifically for code in this repo:
2424

2525
2. Anchor programs should be in directory `anchor`, programs written for Solana Native should be in directory `native`, TypeScript in `posidon` and Python in `seahorse.
2626

27-
3. Tests for Solana native and Anchor programs should be written with [ts-mocha](https://github.com/piotrwitek/ts-mocha).
27+
3. Tests for Solana native, Steel and Anchor programs should be written with [ts-mocha](https://github.com/piotrwitek/ts-mocha).
2828

29-
4. Tests for solana native programs should be written with [solana-bankrun](https://kevinheavey.github.io/solana-bankrun)
29+
4. Tests for solana native programs and steel framework programs should be written with [solana-bankrun](https://kevinheavey.github.io/solana-bankrun)
3030

31-
5. For Solana native programs ensure adding these mandatory pnpm run scripts to your `package.json`. file for successful ci/cd builds:
31+
5. 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:
3232

3333
```json
3434
"scripts": {

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ 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",
1819
"basics/pda-rent-payer/native/program",
1920
"basics/pda-rent-payer/anchor/programs/*",
2021
"basics/processing-instructions/native/program",

0 commit comments

Comments
 (0)