Skip to content

Commit ff3c45f

Browse files
committed
Add automated package content verification
1 parent 84130bb commit ff3c45f

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ jobs:
4848

4949
- name: Run tests
5050
run: cargo test
51+
52+
- name: Verify package contents
53+
run: ./scripts/verify-package.sh

.github/workflows/publish-crates.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,8 @@ jobs:
4545
- name: Dry-run publish
4646
run: cargo publish --dry-run
4747

48+
- name: Verify package contents
49+
run: ./scripts/verify-package.sh
50+
4851
- name: Publish solverforge-ui
4952
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ JS_SRC := $(sort $(wildcard js-src/*.js))
2626

2727
# ============== Phony Targets ==============
2828
.PHONY: banner help assets build build-release test test-quick test-doc test-unit test-one \
29-
lint fmt fmt-check clippy ci-local pre-release version \
29+
lint fmt fmt-check clippy ci-local pre-release version package-verify \
3030
bump-patch bump-minor bump-major bump-dry \
3131
publish-dry publish clean watch
3232

@@ -193,9 +193,16 @@ pre-release: banner
193193
@cargo test --quiet && printf "$(GREEN)$(CHECK) All tests passed$(RESET)\n"
194194
@printf "$(PROGRESS) Dry-run publish...\n"
195195
@cargo publish --dry-run 2>&1 | tail -1
196+
@printf "$(PROGRESS) Verifying packaged contents...\n"
197+
@./scripts/verify-package.sh
196198
@printf "$(GREEN)$(CHECK) Package valid$(RESET)\n"
197199
@printf "\n$(GREEN)$(BOLD)$(CHECK) Ready for release v$(VERSION)$(RESET)\n\n"
198200

201+
package-verify:
202+
@printf "$(PROGRESS) Verifying packaged crate contents...\n"
203+
@./scripts/verify-package.sh
204+
@printf "$(GREEN)$(CHECK) Package contents verified$(RESET)\n"
205+
199206
# ============== Publishing ==============
200207

201208
publish-dry: test banner
@@ -204,6 +211,7 @@ publish-dry: test banner
204211
@printf "$(CYAN)$(BOLD)╚══════════════════════════════════════════════════════════╝$(RESET)\n\n"
205212
@printf "$(GREEN)$(CHECK) All tests passed$(RESET)\n"
206213
@cargo publish --dry-run && \
214+
./scripts/verify-package.sh && \
207215
printf "$(GREEN)$(CHECK) Package valid$(RESET)\n" || \
208216
(printf "$(RED)$(CROSS) Package validation failed$(RESET)\n" && exit 1)
209217
@printf "\n$(GRAY)Use 'make publish' to publish v$(VERSION) to crates.io$(RESET)\n\n"

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ make
437437
cargo build
438438
```
439439

440+
## Package Verification
441+
442+
Use `make package-verify` to inspect the exact crate contents that would be published.
443+
444+
The verification step checks that required bundled assets and crate metadata are present, and that development-only sources such as `css-src/`, `js-src/`, `scripts/`, and screenshots are not shipped in the published crate.
445+
440446
## Acknowledgments
441447

442448
solverforge-ui builds on these excellent open-source projects:

scripts/verify-package.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
manifest="$(mktemp)"
5+
trap 'rm -f "$manifest"' EXIT
6+
7+
cargo package --allow-dirty --list > "$manifest"
8+
9+
require() {
10+
local path="$1"
11+
if ! rg -Fxq "$path" "$manifest"; then
12+
echo "missing packaged file: $path" >&2
13+
exit 1
14+
fi
15+
}
16+
17+
reject_prefix() {
18+
local prefix="$1"
19+
if rg -q "^${prefix}" "$manifest"; then
20+
echo "unexpected packaged path matching prefix: $prefix" >&2
21+
exit 1
22+
fi
23+
}
24+
25+
reject_exact() {
26+
local path="$1"
27+
if rg -Fxq "$path" "$manifest"; then
28+
echo "unexpected packaged file: $path" >&2
29+
exit 1
30+
fi
31+
}
32+
33+
require "Cargo.toml"
34+
require "Cargo.lock"
35+
require "README.md"
36+
require "LICENSE"
37+
require "CHANGELOG.md"
38+
require "src/lib.rs"
39+
require "static/sf/sf.css"
40+
require "static/sf/sf.js"
41+
require "static/sf/vendor/frappe-gantt/frappe-gantt.min.js"
42+
require "static/sf/vendor/split/split.min.js"
43+
require "static/sf/fonts/space-grotesk.woff2"
44+
require "static/sf/fonts/jetbrains-mono.woff2"
45+
require "static/sf/img/solverforge-logo.svg"
46+
47+
reject_prefix "css-src/"
48+
reject_prefix "js-src/"
49+
reject_prefix "screenshots/"
50+
reject_prefix "scripts/"
51+
reject_exact "WIREFRAME.md"
52+
reject_exact ".versionrc.json"
53+
54+
echo "package contents verified"

0 commit comments

Comments
 (0)