Skip to content

Commit 57d87db

Browse files
authored
feat: add support for rust tests in CI (#433)
* remove test to rust action * add cargo test to solana-native action
1 parent c80856b commit 57d87db

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,13 @@ on:
1010
branches:
1111
- main
1212
pull_request:
13-
types: [ opened, synchronize, reopened ]
13+
types: [opened, synchronize, reopened]
1414
branches:
1515
- main
1616

1717
# A workflow run is made up of one or more jobs, which run in parallel by default
1818
# Each job runs in a runner environment specified by runs-on
1919
jobs:
20-
# Unique identifier of our job (`job_id`)
21-
test:
22-
# Sets the name `Test` for the job, which is displayed in the GitHub UI
23-
name: Test
24-
# Containers must run in Linux based operating systems
25-
runs-on: ubuntu-latest
26-
steps:
27-
# Downloads a copy of the code in your repository before running CI tests
28-
- name: Check out repository code
29-
# The uses keyword specifies that this step will run v3 of the actions/checkout action.
30-
# This is an action that checks out your repository onto the runner, allowing you to run scripts or other actions against your code (such as build and test tools).
31-
# You should use the checkout action any time your workflow will run against the repository's code.
32-
uses: actions/checkout@v4
33-
34-
# This GitHub Action installs a Rust toolchain using rustup. It is designed for one-line concise usage and good defaults.
35-
- name: Install the Rust toolchain
36-
uses: dtolnay/rust-toolchain@stable
37-
38-
- name: Run tests
39-
run: cargo test
40-
4120
# `fmt` container job
4221
fmt:
4322
name: Rustfmt

.github/workflows/solana-native.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ jobs:
135135
return 1
136136
fi
137137
138+
# Run Rust unit tests
139+
if [ -d "program" ]; then
140+
echo "Running Rust unit tests for $project"
141+
if ! cargo test --manifest-path=./program/Cargo.toml; then
142+
echo "::error::Rust unit tests failed for $project"
143+
echo "$project: Rust unit tests failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
144+
cd - > /dev/null
145+
return 1
146+
fi
147+
fi
148+
138149
# Test
139150
if ! pnpm build-and-test; then
140151
echo "::error::tests failed for $project"

0 commit comments

Comments
 (0)