Skip to content

Commit 020d768

Browse files
authored
Merge pull request #125 from TrueNine/dev
Fix cleanup guard behavior and standardize workspace check scripts
2 parents cf7bd5c + 1279f0f commit 020d768

File tree

30 files changed

+1245
-729
lines changed

30 files changed

+1245
-729
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: NPM Auth Preflight
2+
description: Validate npm authentication and report package access
3+
4+
inputs:
5+
registry-url:
6+
description: npm registry URL
7+
required: false
8+
default: "https://registry.npmjs.org/"
9+
package-dir:
10+
description: Directory containing package.json to validate
11+
required: true
12+
package-name:
13+
description: Display name for error messages
14+
required: true
15+
16+
runs:
17+
using: composite
18+
steps:
19+
- name: Preflight npm auth
20+
shell: bash
21+
env:
22+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23+
REGISTRY_URL: ${{ inputs.registry-url }}
24+
PACKAGE_DIR: ${{ inputs.package-dir }}
25+
PACKAGE_NAME: ${{ inputs.package-name }}
26+
run: |
27+
set -euo pipefail
28+
29+
if [[ -z "${NODE_AUTH_TOKEN:-}" ]]; then
30+
echo "::error::NPM_TOKEN is missing. Configure a publish-capable npm token for ${PACKAGE_NAME} before rerunning release."
31+
exit 1
32+
fi
33+
34+
pushd "$PACKAGE_DIR" >/dev/null
35+
npm config set //registry.npmjs.org/:_authToken "${NODE_AUTH_TOKEN}"
36+
npm_user=$(npm whoami --registry "$REGISTRY_URL")
37+
popd >/dev/null
38+
39+
echo "Authenticated to npm as ${npm_user}"
40+
echo "Deferring publish permission enforcement for ${PACKAGE_NAME} to the publish step because npm access output is not stable in this workflow."
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: NPM Publish Package
2+
description: Publish a package to npm with retry and verification logic
3+
4+
inputs:
5+
registry-url:
6+
description: npm registry URL
7+
required: false
8+
default: "https://registry.npmjs.org/"
9+
package-dir:
10+
description: Directory containing package.json to publish
11+
required: true
12+
verify-attempts:
13+
description: Number of verification attempts
14+
required: false
15+
default: "90"
16+
verify-delay:
17+
description: Delay between verification attempts in seconds
18+
required: false
19+
default: "10"
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- name: Publish to npm
25+
shell: bash
26+
env:
27+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28+
REGISTRY_URL: ${{ inputs.registry-url }}
29+
PACKAGE_DIR: ${{ inputs.package-dir }}
30+
VERIFY_ATTEMPTS: ${{ inputs.verify-attempts }}
31+
VERIFY_DELAY: ${{ inputs.verify-delay }}
32+
run: |
33+
set -euo pipefail
34+
35+
package_name=$(jq -r '.name' "${PACKAGE_DIR}/package.json")
36+
package_version=$(jq -r '.version' "${PACKAGE_DIR}/package.json")
37+
38+
registry_version_exists() {
39+
local encoded_package_name
40+
local version_json
41+
local published_version
42+
43+
encoded_package_name=$(node -e 'process.stdout.write(encodeURIComponent(process.argv[1]))' "$package_name")
44+
version_json=$(curl --silent --show-error --fail "${REGISTRY_URL%/}/${encoded_package_name}/${package_version}" 2>/dev/null || true)
45+
46+
if [[ -z "$version_json" ]]; then
47+
return 1
48+
fi
49+
50+
published_version=$(jq -r '.version // empty' <<<"$version_json")
51+
[[ "$published_version" == "$package_version" ]]
52+
}
53+
54+
version_exists() {
55+
local published_version
56+
published_version=$(npm view "${package_name}@${package_version}" version --registry "$REGISTRY_URL" 2>/dev/null || true)
57+
58+
if [[ "$published_version" == "$package_version" ]]; then
59+
return 0
60+
fi
61+
62+
registry_version_exists
63+
}
64+
65+
verify_version_exists() {
66+
local attempts="$VERIFY_ATTEMPTS"
67+
local delay_seconds="$VERIFY_DELAY"
68+
69+
for attempt in $(seq 1 "$attempts"); do
70+
if version_exists; then
71+
echo "Verified ${package_name}@${package_version} on npm"
72+
return 0
73+
fi
74+
75+
if [[ "$attempt" -eq "$attempts" ]]; then
76+
break
77+
fi
78+
79+
echo "Waiting for ${package_name}@${package_version} to appear on npm (${attempt}/${attempts})..."
80+
sleep "$delay_seconds"
81+
done
82+
83+
echo "::error::${package_name}@${package_version} is still missing from npm after publish."
84+
return 1
85+
}
86+
87+
if version_exists; then
88+
echo "${package_name}@${package_version} already exists on npm, skipping"
89+
exit 0
90+
fi
91+
92+
publish_log=$(mktemp)
93+
94+
if (cd "$PACKAGE_DIR" && pnpm publish --access public --no-git-checks) 2>&1 | tee "$publish_log"; then
95+
verify_version_exists
96+
rm -f "$publish_log"
97+
exit 0
98+
fi
99+
100+
if grep -Eiq 'cannot publish over the previously published versions|previously published versions' "$publish_log"; then
101+
echo "${package_name}@${package_version} was already published according to npm, skipping"
102+
rm -f "$publish_log"
103+
exit 0
104+
fi
105+
106+
if version_exists; then
107+
echo "${package_name}@${package_version} already exists on npm after publish attempt, skipping"
108+
rm -f "$publish_log"
109+
exit 0
110+
fi
111+
112+
echo "::error::Failed to publish ${package_name}@${package_version}. Exact version is still missing from npm."
113+
rm -f "$publish_log"
114+
exit 1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Setup Cross-Compile Linux ARM64
2+
description: Install aarch64-linux-gnu cross-compilation toolchain
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Install cross-compilation tools (aarch64-linux)
8+
shell: bash
9+
run: |
10+
sudo apt-get update
11+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
12+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV

.github/workflows/deploy-doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
run: pnpm -C doc run lint
6363

6464
- name: Typecheck docs
65-
run: pnpm -C doc run typecheck
65+
run: pnpm -C doc run check:type
6666

6767
- name: Pull Vercel production settings
6868
run: pnpm dlx vercel@latest pull --yes --environment=production --token="$VERCEL_TOKEN"

.github/workflows/pull-request-doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
run: pnpm -C doc run lint
4242

4343
- name: Typecheck docs
44-
run: pnpm -C doc run typecheck
44+
run: pnpm -C doc run check:type
4545

4646
- name: Build docs
4747
run: pnpm -C doc run build

.github/workflows/pull-request.yml

Lines changed: 142 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ jobs:
5555
with:
5656
github-token: ${{ github.token }}
5757

58-
check:
58+
build:
5959
if: github.event.pull_request.draft == false
6060
runs-on: ubuntu-24.04
61-
timeout-minutes: 45
61+
timeout-minutes: 20
6262
steps:
6363
- uses: actions/checkout@v6
6464

@@ -74,14 +74,152 @@ jobs:
7474
- name: Build
7575
run: pnpm run build
7676

77+
lint:
78+
if: github.event.pull_request.draft == false
79+
runs-on: ubuntu-24.04
80+
timeout-minutes: 20
81+
steps:
82+
- uses: actions/checkout@v6
83+
84+
- uses: ./.github/actions/setup-node-pnpm
85+
86+
- uses: ./.github/actions/setup-rust
87+
with:
88+
cache-key: pr
89+
90+
- name: Build native modules
91+
run: pnpm run build:native
92+
7793
- name: Lint
7894
run: pnpm run lint
7995

96+
check-type:
97+
if: github.event.pull_request.draft == false
98+
runs-on: ubuntu-24.04
99+
timeout-minutes: 20
100+
steps:
101+
- uses: actions/checkout@v6
102+
103+
- uses: ./.github/actions/setup-node-pnpm
104+
105+
- uses: ./.github/actions/setup-rust
106+
with:
107+
cache-key: pr
108+
109+
- name: Build native modules
110+
run: pnpm run build:native
111+
80112
- name: Typecheck
81-
run: pnpm run typecheck
113+
run: pnpm run check:type
82114

83-
- name: Run tests
115+
test:
116+
if: github.event.pull_request.draft == false
117+
runs-on: ubuntu-24.04
118+
timeout-minutes: 20
119+
steps:
120+
- uses: actions/checkout@v6
121+
122+
- uses: ./.github/actions/setup-node-pnpm
123+
124+
- uses: ./.github/actions/setup-rust
125+
with:
126+
cache-key: pr
127+
128+
- name: Build native modules
129+
run: pnpm run build:native
130+
131+
- name: Build
132+
run: pnpm run build
133+
134+
- name: Run all tests
84135
run: pnpm run test
85136

137+
test-sdk:
138+
if: github.event.pull_request.draft == false
139+
runs-on: ubuntu-24.04
140+
timeout-minutes: 15
141+
steps:
142+
- uses: actions/checkout@v6
143+
144+
- uses: ./.github/actions/setup-node-pnpm
145+
146+
- uses: ./.github/actions/setup-rust
147+
with:
148+
cache-key: pr
149+
150+
- name: Build native modules
151+
run: pnpm run build:native
152+
153+
- name: SDK tests
154+
run: pnpm turbo test --filter=@truenine/memory-sync-sdk
155+
156+
test-cli:
157+
if: github.event.pull_request.draft == false
158+
runs-on: ubuntu-24.04
159+
timeout-minutes: 15
160+
steps:
161+
- uses: actions/checkout@v6
162+
163+
- uses: ./.github/actions/setup-node-pnpm
164+
165+
- uses: ./.github/actions/setup-rust
166+
with:
167+
cache-key: pr
168+
169+
- name: Build native modules
170+
run: pnpm run build:native
171+
172+
- name: CLI tests
173+
run: pnpm turbo test --filter=@truenine/memory-sync-cli
174+
175+
test-mcp:
176+
if: github.event.pull_request.draft == false
177+
runs-on: ubuntu-24.04
178+
timeout-minutes: 15
179+
steps:
180+
- uses: actions/checkout@v6
181+
182+
- uses: ./.github/actions/setup-node-pnpm
183+
184+
- uses: ./.github/actions/setup-rust
185+
with:
186+
cache-key: pr
187+
188+
- name: Build native modules
189+
run: pnpm run build:native
190+
191+
- name: MCP tests
192+
run: pnpm turbo test --filter=@truenine/memory-sync-mcp
193+
194+
test-libraries:
195+
if: github.event.pull_request.draft == false
196+
runs-on: ubuntu-24.04
197+
timeout-minutes: 15
198+
steps:
199+
- uses: actions/checkout@v6
200+
201+
- uses: ./.github/actions/setup-node-pnpm
202+
203+
- uses: ./.github/actions/setup-rust
204+
with:
205+
cache-key: pr
206+
207+
- name: Build native modules
208+
run: pnpm run build:native
209+
210+
- name: Library tests
211+
run: pnpm turbo test --filter=@truenine/logger --filter=@truenine/md-compiler --filter=@truenine/script-runtime
212+
213+
test-rust:
214+
if: github.event.pull_request.draft == false
215+
runs-on: ubuntu-24.04
216+
timeout-minutes: 20
217+
steps:
218+
- uses: actions/checkout@v6
219+
220+
- uses: ./.github/actions/setup-rust
221+
with:
222+
cache-key: pr
223+
86224
- name: Rust tests (excluding GUI)
87225
run: cargo test --workspace --exclude memory-sync-gui --lib --bins --tests

0 commit comments

Comments
 (0)