Skip to content

Commit 85ee789

Browse files
refactor: simplify rust workflow and update README
1 parent 1704cef commit 85ee789

File tree

2 files changed

+3
-67
lines changed

2 files changed

+3
-67
lines changed

.github/workflows/rust-build.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ on:
1111
description: 'The directory to run jobs from'
1212
default: '.'
1313
type: string
14-
run-audit:
15-
description: 'Run cargo-audit for security vulnerabilities'
16-
default: true
17-
type: boolean
1814
enable-cache:
1915
description: 'Enable caching of dependencies'
2016
default: true
@@ -23,18 +19,6 @@ on:
2319
description: 'Publish package to crates.io'
2420
default: false
2521
type: boolean
26-
upload-artifact:
27-
description: 'Upload build artifact'
28-
default: false
29-
type: boolean
30-
artifact-name:
31-
description: 'Name of the artifact to upload'
32-
type: string
33-
required: false
34-
artifact-path:
35-
description: 'Path to the artifact to upload'
36-
type: string
37-
required: false
3822
secrets:
3923
CARGO_REGISTRY_TOKEN:
4024
required: false
@@ -76,15 +60,6 @@ jobs:
7660
- name: Run linter (Clippy)
7761
working-directory: ${{ inputs.working-directory }}
7862
run: cargo clippy --all-targets -- -D warnings
79-
80-
- name: Install cargo-audit
81-
if: ${{ inputs.run-audit }}
82-
run: cargo install cargo-audit
83-
84-
- name: Run security audit
85-
if: ${{ inputs.run-audit }}
86-
working-directory: ${{ inputs.working-directory }}
87-
run: cargo audit
8863

8964
- name: Build
9065
working-directory: ${{ inputs.working-directory }}
@@ -94,13 +69,6 @@ jobs:
9469
working-directory: ${{ inputs.working-directory }}
9570
run: cargo test --release
9671

97-
- name: Upload artifact
98-
if: ${{ inputs.upload-artifact }}
99-
uses: actions/upload-artifact@v4
100-
with:
101-
name: ${{ inputs.artifact-name }}
102-
path: ${{ inputs.artifact-path }}
103-
10472
- name: Validate package
10573
if: ${{ inputs.publish-crates-io }}
10674
working-directory: ${{ inputs.working-directory }}

rust-build/README.md

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
# Rust Build Workflow
22

3-
A reusable GitHub Actions workflow for building, linting, testing, and auditing Rust packages, with optional artifact upload and crates.io publishing.
3+
A reusable GitHub Actions workflow for building, linting, testing, and publishing Rust packages, with optional dependency caching and working directory support.
44

55
## Features
66

77
- Build and test Rust packages
88
- Lint code using `clippy`
99
- Check formatting with `cargo fmt`
10-
- Run security audits with `cargo audit`
1110
- Cache dependencies for faster builds
12-
- Set a working directory for monorepos
13-
- Upload build artifacts
11+
- Set a working directory (for monorepos or nested crates)
1412
- Publish to crates.io
15-
- All operations are performed in a single job (no redundant toolchain installs)
1613

1714
## Usage
1815

@@ -27,11 +24,8 @@ jobs:
2724
with:
2825
rust-version: 'stable'
2926
working-directory: './my-crate'
30-
run-audit: true
3127
enable-cache: true
32-
upload-artifact: true
33-
artifact-name: my-crate
34-
artifact-path: target/release/my-crate
28+
publish-crates-io: false
3529
secrets:
3630
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
3731
```
@@ -42,11 +36,7 @@ jobs:
4236
| ------------------- | --------------------------------------------------------- | -------- | -------- |
4337
| `rust-version` | Rust version to use | `stable` | No |
4438
| `working-directory` | The directory to run jobs from | `.` | No |
45-
| `run-audit` | Run `cargo audit` for security vulnerabilities | `true` | No |
4639
| `enable-cache` | Enable caching of dependencies | `true` | No |
47-
| `upload-artifact` | Upload a build artifact after building | `false` | No |
48-
| `artifact-name` | Name of the artifact to upload | – | No |
49-
| `artifact-path` | Path to the artifact to upload | – | No |
5040
| `publish-crates-io` | Publish the package to crates.io (only if build succeeds) | `false` | No |
5141

5242
Note: All builds use the release profile by default. There is no build-target input anymore
@@ -77,28 +67,6 @@ jobs:
7767
working-directory: './my-crate'
7868
```
7969

80-
### Disable Security Audit
81-
82-
```yaml
83-
jobs:
84-
build-and-test:
85-
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/rust-build.yml@main
86-
with:
87-
run-audit: false
88-
```
89-
90-
### Upload Artifact After Build
91-
92-
```yaml
93-
jobs:
94-
build-and-upload:
95-
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/rust-build.yml@main
96-
with:
97-
upload-artifact: true
98-
artifact-name: my-crate
99-
artifact-path: target/release/my-crate
100-
```
101-
10270
### Publish to crates.io (requires CARGO_REGISTRY_TOKEN)
10371

10472
```yaml

0 commit comments

Comments
 (0)