diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 318d8f4..098158a 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -159,6 +159,17 @@ jobs: - name: Verify registry installation run: | version=${RELEASE_TAG#v} + for attempt in {1..30}; do + if npm view "@createitv/agc-cli@$version" version 2>/dev/null | grep -Fx "$version"; then + break + fi + if test "$attempt" -eq 30; then + echo "@createitv/agc-cli@$version was not visible after 5 minutes" >&2 + exit 1 + fi + echo "Waiting for npm to finish processing @createitv/agc-cli@$version ($attempt/30)..." + sleep 10 + done npm install --global "@createitv/agc-cli@$version" --prefix "$RUNNER_TEMP/npm-install" --ignore-scripts "$RUNNER_TEMP/npm-install/bin/agc" version | tee "$RUNNER_TEMP/npm-version.txt" grep -F "$version" "$RUNNER_TEMP/npm-version.txt" diff --git a/scripts/test_npm_workflow.py b/scripts/test_npm_workflow.py index 39e74e9..6d3b5d3 100644 --- a/scripts/test_npm_workflow.py +++ b/scripts/test_npm_workflow.py @@ -32,6 +32,20 @@ def test_missing_version_does_not_turn_npm_json_error_into_integrity(self): "the workflow must only treat an sha512 integrity as published", ) + def test_registry_verification_waits_for_new_package_processing(self): + workflow = NPM_WORKFLOW.read_text(encoding="utf-8") + + self.assertIn( + "for attempt in {1..30}", + workflow, + "npm says newly published packages may take a few minutes to become available", + ) + self.assertIn( + 'npm view "@createitv/agc-cli@$version" version', + workflow, + "the retry must wait for the exact version before installing", + ) + if __name__ == "__main__": unittest.main()