Skip to content

Commit 937c0fd

Browse files
authored
CI: Move semver check to publish job (solana-program#57)
#### Problem The semver check job can be a bit noisy and give a lot of negatives, which can hamper development. #### Summary of changes Run the semver checks only during publish, similar to how pinocchio does things.
1 parent d9ecce0 commit 937c0fd

File tree

4 files changed

+17
-37
lines changed

4 files changed

+17
-37
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,6 @@ jobs:
6868
- name: Run cargo-audit
6969
run: pnpm rust:audit
7070

71-
semver_rust:
72-
name: Check semver Rust
73-
runs-on: ubuntu-latest
74-
steps:
75-
- name: Git Checkout
76-
uses: actions/checkout@v4
77-
78-
- name: Setup Environment
79-
uses: ./.github/actions/setup
80-
with:
81-
cargo-cache-key: cargo-semver
82-
83-
- name: Install cargo-audit
84-
uses: taiki-e/install-action@v2
85-
with:
86-
tool: cargo-semver-checks
87-
88-
- name: Run semver checks
89-
run: pnpm rust:semver
90-
9171
spellcheck_rust:
9272
name: Spellcheck Rust
9373
runs-on: ubuntu-latest

.github/workflows/publish-rust.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ on:
2727
- patch
2828
- minor
2929
- major
30-
- rc
31-
- beta
32-
- alpha
33-
- release
34-
- version
35-
version:
36-
description: Version (used with level "version")
37-
required: false
38-
type: string
3930
dry_run:
4031
description: Dry run
4132
required: true
@@ -63,6 +54,11 @@ jobs:
6354
cargo-cache-key: cargo-test-publish-${{ inputs.package_path }}
6455
cargo-cache-fallback-key: cargo-test-publish
6556

57+
- name: Install cargo-audit
58+
uses: taiki-e/install-action@v2
59+
with:
60+
tool: cargo-semver-checks
61+
6662
- name: Format
6763
run: pnpm zx ./scripts/rust/format.mjs "${{ inputs.package_path }}"
6864

@@ -72,6 +68,9 @@ jobs:
7268
- name: Test
7369
run: pnpm zx ./scripts/rust/test.mjs "${{ inputs.package_path }}"
7470

71+
- name: Check semver
72+
run: pnpm rust:semver ${{ inputs.package_path }} --release-type ${{ inputs.level }}
73+
7574
publish:
7675
name: Publish Rust Crate
7776
runs-on: ubuntu-latest
@@ -113,19 +112,13 @@ jobs:
113112
env:
114113
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
115114
run: |
116-
if [ "${{ inputs.level }}" == "version" ]; then
117-
LEVEL=${{ inputs.version }}
118-
else
119-
LEVEL=${{ inputs.level }}
120-
fi
121-
122115
if [ "${{ inputs.dry_run }}" == "true" ]; then
123116
OPTIONS="--dry-run"
124117
else
125118
OPTIONS=""
126119
fi
127120
128-
pnpm rust:publish "${{ inputs.package_path }}" $LEVEL $OPTIONS
121+
pnpm rust:publish "${{ inputs.package_path }}" "${{ inputs.level }}" $OPTIONS
129122
130123
- name: Generate a changelog
131124
if: github.event.inputs.create_release == 'true'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"rust:audit": "zx ./scripts/rust/audit.mjs",
3434
"rust:publish": "zx ./scripts/rust/publish.mjs",
3535
"rust:hack": "zx ./scripts/rust/hack.mjs",
36-
"rust:semver": "cargo semver-checks"
36+
"rust:semver": "zx ./scripts/rust/semver.mjs"
3737
},
3838
"devDependencies": {
3939
"@iarna/toml": "^2.2.5",

scripts/rust/semver.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env zx
2+
import 'zx/globals';
3+
import { cliArguments, getCargo, workingDirectory } from '../utils.mjs';
4+
5+
const [folder, ...args] = cliArguments();
6+
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
7+
await $`cargo semver-checks --manifest-path ${manifestPath} ${args}`;

0 commit comments

Comments
 (0)