-
Notifications
You must be signed in to change notification settings - Fork 228
Add reusable GitHub Action to install and cache nats server #744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
c49a18e
to
430e3fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a reusable GitHub Action to optimize NATS server installation in CI workflows, reducing installation time from 2-3 minutes to 2-3 seconds through caching.
- Replaces manual installation scripts with a centralized GitHub Action
- Implements caching strategy for NATS server binaries across workflow runs
- Simplifies workflow configuration by eliminating manual PATH management
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
.github/actions/setup-nats-server/action.yml |
New composite action that downloads, caches, and configures NATS server |
.github/workflows/test.yml |
Updated to use the new action and simplified matrix configuration |
nats/scripts/install_nats.sh |
Removed obsolete installation script |
nats/tests/utils.py |
Updated comment to reference official NATS installation docs |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
include: | ||
- nats_version: "main" | ||
continue-on-error: true | ||
nats_version: ["latest"] |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider testing against multiple NATS versions to ensure compatibility. The original configuration tested against specific versions (v2.10.29, v2.11.8) and main branch, which provided better coverage for potential breaking changes.
nats_version: ["latest"] | |
nats_version: ["v2.10.29", "v2.11.8", "latest", "main"] |
Copilot uses AI. Check for mistakes.
run: | | ||
INSTALL_DIR="$HOME/nats-server" | ||
mkdir -p "$INSTALL_DIR" | ||
curl -fsSL https://binaries.nats.dev/nats-io/nats-server/v2@${{ inputs.version }} | PREFIX="$INSTALL_DIR" sh |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Piping curl output directly to shell without verification poses a security risk. Consider downloading the script first, verifying its integrity, then executing it.
curl -fsSL https://binaries.nats.dev/nats-io/nats-server/v2@${{ inputs.version }} | PREFIX="$INSTALL_DIR" sh | |
INSTALL_SCRIPT="$(mktemp)" | |
curl -fsSL https://binaries.nats.dev/nats-io/nats-server/v2@${{ inputs.version }} -o "$INSTALL_SCRIPT" | |
# TODO: (Optional) Verify the integrity of $INSTALL_SCRIPT here (e.g., with sha256sum) | |
PREFIX="$INSTALL_DIR" sh "$INSTALL_SCRIPT" | |
rm -f "$INSTALL_SCRIPT" |
Copilot uses AI. Check for mistakes.
# On Windows, create a shim without .exe extension | ||
if [ "$RUNNER_OS" = "Windows" ] && [ -f "$INSTALL_DIR/nats-server.exe" ]; then | ||
echo '#!/bin/bash' > "$INSTALL_DIR/nats-server" | ||
echo 'exec "$(dirname "$0")/nats-server.exe" "$@"' >> "$INSTALL_DIR/nats-server" | ||
chmod +x "$INSTALL_DIR/nats-server" |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Windows shim creation uses bash-specific syntax but may not work correctly on Windows runners. Consider using PowerShell or a more portable approach for Windows compatibility.
# On Windows, create a shim without .exe extension | |
if [ "$RUNNER_OS" = "Windows" ] && [ -f "$INSTALL_DIR/nats-server.exe" ]; then | |
echo '#!/bin/bash' > "$INSTALL_DIR/nats-server" | |
echo 'exec "$(dirname "$0")/nats-server.exe" "$@"' >> "$INSTALL_DIR/nats-server" | |
chmod +x "$INSTALL_DIR/nats-server" | |
# On Windows, create a shim without .exe extension using PowerShell | |
if [ "$RUNNER_OS" = "Windows" ] && [ -f "$INSTALL_DIR/nats-server.exe" ]; then | |
# Create a CMD shim for Windows | |
echo '@echo off' > "$INSTALL_DIR/nats-server.cmd" | |
echo 'set SCRIPT_DIR=%~dp0' >> "$INSTALL_DIR/nats-server.cmd" | |
echo '"%SCRIPT_DIR%nats-server.exe" %*' >> "$INSTALL_DIR/nats-server.cmd" |
Copilot uses AI. Check for mistakes.
6f2ee8a
to
a467549
Compare
Signed-off-by: Casper Beyer <[email protected]>
a467549
to
3e13e9a
Compare
Signed-off-by: Casper Beyer <[email protected]>
Brings install time of nats-server from 2-3 minutes to 2-3 seconds.