Skip to content

Commit

Permalink
feat: Introduce Steel framework in program-examples (#128)
Browse files Browse the repository at this point in the history
* add steel framework

* add steel ci

* add steel in workspace

* fix workspace issue

* fix rust fmt error

* added steel in Contributing.md
  • Loading branch information
heyAyushh authored Oct 8, 2024
1 parent ea26e37 commit 401366c
Show file tree
Hide file tree
Showing 11 changed files with 2,373 additions and 608 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/steel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Steel

on:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
solana-version: [stable]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true
- uses: heyAyushh/[email protected]
with:
solana-cli-version: ${{ matrix.solana-version }}
- run: solana block
shell: bash
- name: Install pnpm
run: |
npm install --global pnpm
- name: Build Steel native programs
run: |
declare -a ProjectDirs=($(find . -type d -name "steel"| grep -v -f <(grep . .github/.ghaignore | grep -v '^$')))
echo "Projects to Build:"
printf "%s\n" "${ProjectDirs[@]}"
for projectDir in "${ProjectDirs[@]}"; do
echo "
********
Building $projectDir
********"
cd $projectDir
if pnpm build; then
echo "Build succeeded for $projectDir."
else
failed=true
failed_builds+=($projectDir)
echo "Build failed for $projectDir. Continuing with the next program."
fi
cd - > /dev/null
done
if [ "$failed" = true ]; then
echo "Programs that failed building:"
printf "%s\n" "${failed_builds[@]}"
exit 1
else
echo "All programs built successfully."
fi
shell: bash

test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
solana-version: [1.18.17, stable]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true
- uses: heyAyushh/[email protected]
with:
solana-cli-version: ${{ matrix.solana-version }}
- run: solana block
shell: bash
- name: Install pnpm
run: |
npm install --global pnpm
- name: Test Steel native programs
run: |
solana -V
rustc -V
declare -a ProjectDirs=($(find . -type d -name "steel"| grep -v -f <(grep . .github/.ghaignore | grep -v '^$')))
echo "Projects to Test:"
printf "%s\n" "${ProjectDirs[@]}"
for projectDir in "${ProjectDirs[@]}"; do
echo "
********
Testing $projectDir
********"
cd $projectDir
pnpm install --frozen-lockfile
if pnpm build-and-test; then
echo "Tests succeeded for $projectDir."
else
failed=true
failed_tests+=($projectDir)
echo "Tests failed for $projectDir. Continuing with the next program."
fi
cd - > /dev/null
done
if [ "$failed" = true ]; then
echo "*****************************"
echo "Programs that failed testing:"
printf "%s\n" "${failed_tests[@]}"
exit 1
else
echo "All tests passed."
fi
shell: bash
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ Specifically for code in this repo:

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.

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

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

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

```json
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"basics/cross-program-invocation/anchor/programs/*",
"basics/hello-solana/native/program",
"basics/hello-solana/anchor/programs/*",
"basics/hello-solana/steel/program",
"basics/pda-rent-payer/native/program",
"basics/pda-rent-payer/anchor/programs/*",
"basics/processing-instructions/native/program",
Expand Down
Loading

0 comments on commit 401366c

Please sign in to comment.