Skip to content

Commit d03fa49

Browse files
authored
Merge pull request #129 from Reloaded-Project/migrate/v1.2.0
Migrate project template to v1.2.0
2 parents 9b3def4 + ec63615 commit d03fa49

37 files changed

Lines changed: 123 additions & 29 deletions

.github/template-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
reloaded-templates-rust:1.1.0
1+
reloaded-templates-rust:1.2.0

.github/workflows/deploy-mkdocs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
push:
66
branches: [main]
77
paths:
8-
- "docs/**"
8+
- "src/docs/**"
99

1010
jobs:
1111
build:
@@ -18,7 +18,7 @@ jobs:
1818
- name: Deploy MkDocs
1919
uses: Reloaded-Project/devops-mkdocs@v1
2020
with:
21-
config-file: docs/mkdocs.yml
22-
requirements: ./docs/requirements.txt
21+
config-file: src/docs/mkdocs.yml
22+
requirements: ./src/docs/requirements.txt
2323
publish-to-pages: ${{ github.event_name == 'push' }}
2424
checkout-current-repo: true

.github/workflows/rust.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,8 @@ jobs:
141141
;;
142142
esac
143143
144-
format:
145-
name: Format
144+
format-check:
146145
runs-on: ubuntu-latest
147-
148146
steps:
149147
- uses: actions/checkout@v6
150148

@@ -204,7 +202,7 @@ jobs:
204202
permissions:
205203
contents: write
206204

207-
needs: [ci, format, semver-checks]
205+
needs: [ci, format-check, semver-checks]
208206
if: startsWith(github.ref, 'refs/tags/')
209207
runs-on: ubuntu-latest
210208
steps:

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"[yaml]": {
3+
"editor.formatOnSave": false
4+
}
5+
}

src/.cargo/verify.ps1

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,66 @@
11
# Post-change verification script
22
# All steps must pass without warnings
33
# Keep in sync with verify.sh
4+
# Script is relative to git repo root; search if not found
45
#
56
# Note: reloaded-code-serdesai is async-only.
67
# Blocking mode is validated for core and models-dev.
78
# reloaded-code-bubblewrap is Linux-only; all bubblewrap steps
89
# are skipped on non-Linux platforms.
910

10-
$ErrorActionPreference = "Stop"
11+
$originalDir = Get-Location
12+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
13+
$projectRoot = Join-Path $scriptDir ".."
14+
$originalRustdocFlags = $env:RUSTDOCFLAGS
15+
Set-Location $projectRoot -ErrorAction Stop
16+
17+
$script:exitCode = 0
18+
$script:failedCommands = @()
19+
20+
function Register-CommandFailure {
21+
param(
22+
[string]$DisplayCommand,
23+
[int]$Code,
24+
[string]$Message = ""
25+
)
26+
27+
Write-Host ("Command failed with exit code " + $Code + ": " + $DisplayCommand)
28+
if ($Message -ne "") {
29+
Write-Host $Message
30+
}
31+
32+
$script:failedCommands += $DisplayCommand
33+
if ($script:exitCode -eq 0) {
34+
$script:exitCode = $Code
35+
}
36+
}
1137

1238
function Invoke-LoggedCommand {
1339
param(
1440
[string]$Command,
1541
[string[]]$Arguments
1642
)
1743

18-
if ($Arguments.Count -gt 0) {
19-
Write-Host ($Command + " " + ($Arguments -join " "))
44+
$displayCommand = if ($Arguments.Count -gt 0) {
45+
$Command + " " + ($Arguments -join " ")
2046
} else {
21-
Write-Host $Command
47+
$Command
2248
}
2349

24-
& $Command @Arguments
25-
if ($LASTEXITCODE -ne 0) {
26-
throw "Command '$Command' failed with exit code $LASTEXITCODE"
50+
Write-Host $displayCommand
51+
52+
try {
53+
& $Command @Arguments
54+
$commandExitCode = $LASTEXITCODE
55+
} catch {
56+
Register-CommandFailure $displayCommand 1 $_.Exception.Message
57+
return
2758
}
28-
}
2959

30-
$originalDir = Get-Location
31-
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
32-
$projectRoot = Join-Path $scriptDir ".."
33-
Set-Location $projectRoot
60+
if ($commandExitCode -ne 0) {
61+
Register-CommandFailure $displayCommand $commandExitCode
62+
}
63+
}
3464

3565
$onLinux = $IsLinux -eq $true
3666

@@ -67,7 +97,6 @@ try {
6797

6898
Write-Host "Docs..."
6999
$docArgs = @("--workspace", "--document-private-items", "--no-deps", "--quiet", "--exclude", "reloaded-code-bubblewrap")
70-
$originalRustdocFlags = $env:RUSTDOCFLAGS
71100
$env:RUSTDOCFLAGS = "-D warnings"
72101
try {
73102
Invoke-LoggedCommand "cargo" (@("doc") + $docArgs)
@@ -78,6 +107,9 @@ try {
78107
Write-Host "Formatting..."
79108
Invoke-LoggedCommand "cargo" @("fmt", "--all", "--quiet")
80109

110+
Write-Host "Publish dry-run..."
111+
Invoke-LoggedCommand "cargo" @("publish", "--dry-run", "--allow-dirty", "--quiet", "--workspace")
112+
81113
Write-Host "Linux-only feature coverage..."
82114
if ($onLinux) {
83115
Write-Host "Building (linux async features)..."
@@ -108,19 +140,28 @@ try {
108140
Invoke-LoggedCommand "cargo" @("clippy", "-p", "reloaded-code-core", "--no-default-features", "--features", "blocking,linux-bubblewrap", "--quiet", "--", "-D", "warnings")
109141

110142
Write-Host "Docs (linux-only package)..."
111-
$linuxRustdocFlags = $env:RUSTDOCFLAGS
112143
$env:RUSTDOCFLAGS = "-D warnings"
113144
try {
114145
Invoke-LoggedCommand "cargo" @("doc", "-p", "reloaded-code-bubblewrap", "--document-private-items", "--no-deps", "--quiet")
115146
} finally {
116-
$env:RUSTDOCFLAGS = $linuxRustdocFlags
147+
$env:RUSTDOCFLAGS = $originalRustdocFlags
117148
}
118149
} else {
119150
Write-Host " (skipped - not Linux)"
120151
}
152+
} finally {
153+
$env:RUSTDOCFLAGS = $originalRustdocFlags
154+
Set-Location $originalDir
155+
}
121156

157+
if ($script:exitCode -eq 0) {
122158
Write-Host "All checks passed!"
159+
} else {
160+
Write-Host "Verification failed."
161+
Write-Host "Failed commands:"
162+
foreach ($failedCommand in $script:failedCommands) {
163+
Write-Host (" - " + $failedCommand)
164+
}
123165
}
124-
finally {
125-
Set-Location $originalDir
126-
}
166+
167+
exit $script:exitCode

src/.cargo/verify.sh

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22
# Post-change verification script
33
# All steps must pass without warnings
44
# Keep in sync with verify.ps1
5+
# Script is relative to git repo root; search if not found
56
#
67
# Note: reloaded-code-serdesai is async-only.
78
# Blocking mode is validated for core and models-dev.
89
# reloaded-code-bubblewrap is Linux-only; all bubblewrap steps
910
# are skipped on non-Linux platforms.
1011

11-
set -e
12-
1312
run_cmd() {
1413
echo "$*"
14+
1515
"$@"
16+
local status=$?
17+
if [ "$status" -eq 0 ]; then
18+
return 0
19+
fi
20+
21+
printf 'Command failed with exit code %s: %s\n' "$status" "$*" >&2
22+
FAILED_COMMANDS+=("$*")
23+
if [ "$EXIT_CODE" -eq 0 ]; then
24+
EXIT_CODE=$status
25+
fi
26+
27+
return 0
1628
}
1729

1830
ORIGINAL_DIR="$(pwd)"
@@ -22,6 +34,9 @@ cd "$PROJECT_ROOT"
2234

2335
trap 'cd "$ORIGINAL_DIR"' EXIT
2436

37+
EXIT_CODE=0
38+
FAILED_COMMANDS=()
39+
2540
IS_LINUX=false
2641
if [ "$(uname -s)" = "Linux" ]; then
2742
IS_LINUX=true
@@ -64,6 +79,9 @@ run_cmd env RUSTDOCFLAGS="-D warnings" cargo doc "${DOC_ARGS[@]}"
6479
echo "Formatting..."
6580
run_cmd cargo fmt --all --quiet
6681

82+
echo "Publish dry-run..."
83+
run_cmd cargo publish --dry-run --allow-dirty --quiet --workspace
84+
6785
echo "Linux-only feature coverage..."
6886
if [ "$IS_LINUX" = true ]; then
6987
echo "Building (linux async features)..."
@@ -100,4 +118,12 @@ else
100118
echo " (skipped - not Linux)"
101119
fi
102120

103-
echo "All checks passed!"
121+
if [ "$EXIT_CODE" -eq 0 ]; then
122+
echo "All checks passed!"
123+
else
124+
echo "Verification failed."
125+
echo "Failed commands:"
126+
printf ' - %s\n' "${FAILED_COMMANDS[@]}"
127+
fi
128+
129+
exit "$EXIT_CODE"
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)