Skip to content

Commit c02d24c

Browse files
authored
ci: update Cargo Artifactory publishing config (NVIDIA#68)
#### Overview Updates the scheduled Cargo Artifactory publish job so Cargo publishing no longer configures Git credential storage or derives a Basic auth credential from the Artifactory username and key. The job now uses the Artifactory key directly as the Cargo publish token and keeps registry configuration limited to the Artifactory sparse index. - [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license. - [x] I searched existing issues and open pull requests, and this does not duplicate existing work. #### Details - Remove the Cargo publish job's `NEMO_FLOW_CI_ARTIFACTORY_USER` requirement. - Remove `git_credential_url`, global Git credential helper setup, `.git-credentials` writes, and `git-fetch-with-cli` configuration from the Cargo publish path. - Remove the now-unused Basic auth token derivation and Cargo credential-provider setting. - Configure `~/.cargo/config.toml` with an Artifactory sparse registry entry: `sparse+${NEMO_FLOW_CI_ARTIFACTORY_CARGO_URL}`. - Pass `${NEMO_FLOW_CI_ARTIFACTORY_KEY}` directly to `cargo publish --token` for each Rust crate. Validation: - Inspected `git diff upstream/main...HEAD -- .gitlab-ci.yml` - Confirmed the PR branch changes only `.gitlab-ci.yml` #### Where should the reviewer start? Start with `.gitlab-ci.yml`, specifically the `publish:artifactory:cargo` job script. #### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to) - Relates to: NVIDIA#64 NVIDIA#60 NVIDIA#59 ## Summary by CodeRabbit * **Chores** * Simplified Cargo crate publishing configuration in CI/CD pipeline, reducing configuration complexity and credential management requirements while maintaining publishing functionality. Authors: - Will Killian (https://github.com/willkill07) Approvers: - David Gardner (https://github.com/dagardner-nv) URL: NVIDIA#68
1 parent 7744e0a commit c02d24c

1 file changed

Lines changed: 5 additions & 39 deletions

File tree

.gitlab-ci.yml

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ publish:artifactory:cargo:
232232
- |
233233
set -eu
234234
235-
if [ -z "${NEMO_FLOW_CI_ARTIFACTORY_USER:-}" ] || [ -z "${NEMO_FLOW_CI_ARTIFACTORY_KEY:-}" ] || [ -z "${NEMO_FLOW_CI_ARTIFACTORY_CARGO_URL:-}" ]; then
236-
echo "Error: uploading Cargo crates to Artifactory requires NEMO_FLOW_CI_ARTIFACTORY_USER, NEMO_FLOW_CI_ARTIFACTORY_KEY, and NEMO_FLOW_CI_ARTIFACTORY_CARGO_URL." >&2
235+
if [ -z "${NEMO_FLOW_CI_ARTIFACTORY_KEY:-}" ] || [ -z "${NEMO_FLOW_CI_ARTIFACTORY_CARGO_URL:-}" ]; then
236+
echo "Error: uploading Cargo crates to Artifactory requires NEMO_FLOW_CI_ARTIFACTORY_KEY and NEMO_FLOW_CI_ARTIFACTORY_CARGO_URL." >&2
237237
exit 1
238238
fi
239239
if [ ! -f collected/github-run.json ]; then
@@ -260,47 +260,13 @@ publish:artifactory:cargo:
260260
cargo_home="${CARGO_HOME:-${HOME}/.cargo}"
261261
mkdir -p "$cargo_home"
262262
263-
# Cargo fetches this Artifactory registry as an authenticated Git index.
264-
git_credential_url="$(
265-
uv run --no-project python - <<'PY'
266-
import os
267-
from urllib.parse import quote, urlsplit, urlunsplit
268-
269-
url = os.environ["NEMO_FLOW_CI_ARTIFACTORY_CARGO_URL"]
270-
user = quote(os.environ["NEMO_FLOW_CI_ARTIFACTORY_USER"], safe="")
271-
password = quote(os.environ["NEMO_FLOW_CI_ARTIFACTORY_KEY"], safe="")
272-
parts = urlsplit(url)
273-
if not parts.scheme or not parts.netloc:
274-
raise SystemExit("NEMO_FLOW_CI_ARTIFACTORY_CARGO_URL must be an absolute URL")
275-
print(urlunsplit((parts.scheme, f"{user}:{password}@{parts.netloc}", parts.path, parts.query, parts.fragment)))
276-
PY
277-
)"
278-
279-
git config --global credential.helper "store --file=${HOME}/.git-credentials"
280-
git config --global credential.useHttpPath true
281-
printf '%s\n' "$git_credential_url" > "${HOME}/.git-credentials"
282-
chmod 600 "${HOME}/.git-credentials"
283-
284-
cargo_auth="Basic $(printf '%s:%s' "${NEMO_FLOW_CI_ARTIFACTORY_USER}" "${NEMO_FLOW_CI_ARTIFACTORY_KEY}" | base64 | tr -d '\n')"
285-
286263
cat > "${cargo_home}/config.toml" <<EOF
287-
[registries.artifactory]
288-
index = "${NEMO_FLOW_CI_ARTIFACTORY_CARGO_URL}"
289-
credential-provider = "cargo:token"
290-
291-
[net]
292-
git-fetch-with-cli = true
264+
[registries]
265+
artifactory = { index = "sparse+${NEMO_FLOW_CI_ARTIFACTORY_CARGO_URL}" }
293266
EOF
294267
295-
cat > "${cargo_home}/credentials.toml" <<EOF
296-
[registries.artifactory]
297-
token = "${cargo_auth}"
298-
EOF
299-
300-
chmod 600 "${cargo_home}/credentials.toml"
301-
302268
for crate in nemo-flow nemo-flow-adaptive nemo-flow-ffi; do
303-
cargo publish --package "$crate" --registry artifactory --allow-dirty
269+
cargo publish --package "$crate" --registry artifactory --token "${NEMO_FLOW_CI_ARTIFACTORY_KEY}" --allow-dirty
304270
done
305271
306272
publish:artifactory:npm:

0 commit comments

Comments
 (0)