Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 166 additions & 0 deletions .github/TESTING_AUTOMATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Testing the Enhanced Automated Dependency Management

This document explains how to test the improved automated dependency management system.

## Overview

The enhanced workflow now automatically:
1. Extracts version information from dependency update issues
2. Updates version numbers in installer files
3. Creates and commits changes to a new branch
4. Opens a Pull Request with actual code modifications
5. Links the PR to the original issue

## Testing with Issue #48

Issue #48 is a perfect test case for the Ansible dependency updates:
- **Python**: 3.14.2 → 3.14.3
- **Ansible**: 13.3.0 → 13.5.0

### Method 1: Manually Trigger via GitHub Actions UI

1. Go to the [Actions tab](https://github.com/Stensel8/Scripts/actions)
2. Select "Auto-Update Dependencies" workflow
3. Click "Run workflow"
4. Enter issue number: `48`
5. Click "Run workflow" button

### Method 2: Trigger by Editing the Issue

The workflow automatically runs when dependency issues are opened or edited:

1. Go to [Issue #48](https://github.com/Stensel8/Scripts/issues/48)
2. Click "Edit" on the issue
3. Add a space or make any minor edit to the description
4. Save the changes

The workflow will automatically trigger.

### Method 3: Using GitHub CLI (with proper authentication)

```bash
gh workflow run auto-update-dependencies.yml -f issue_number=48
```

## Expected Behavior

When the workflow runs successfully:

1. **Version Extraction**: The workflow parses issue #48 and extracts:
```
Python: 3.14.2 → 3.14.3
Ansible: 13.3.0 → 13.5.0
```

2. **File Updates**: Automatically modifies `ansible/ansible_installer.sh`:
- Updates `BUILD_PYTHON_VERSION:-3.14.2` to `BUILD_PYTHON_VERSION:-3.14.3`
- Updates `pip install ansible==13.3.0` to `pip install ansible==13.5.0`

3. **Branch Creation**: Creates a new branch like `automated-update/ansible-1743422410`

Copilot AI Mar 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example branch name uses a 10-digit timestamp (automated-update/ansible-1743422410), but the workflow generates branch names using Date.now() (milliseconds since epoch), which is typically 13 digits. Update the example to match the actual branch format, or change the workflow to use seconds if that’s the intended convention.

Suggested change
3. **Branch Creation**: Creates a new branch like `automated-update/ansible-1743422410`
3. **Branch Creation**: Creates a new branch like `automated-update/ansible-1743422410123`

Copilot uses AI. Check for mistakes.

4. **Commit**: Creates a commit with message:
```
chore: update Ansible dependencies

- Python: 3.14.2 → 3.14.3
- Ansible: 13.3.0 → 13.5.0

Automated update from issue #48
```

5. **PR Creation**: Opens a PR with:
- Title: "🔄 Update Ansible Dependencies"
- Body containing changelog, files updated, and testing checklist
- Labels: `dependencies`, `automated`, `ansible`
- Status: Ready for review (not draft, unlike NGINX PRs)

6. **Issue Comment**: Adds a comment to issue #48:
```
🤖 Automated PR Created

A pull request has been created with automated dependency updates: #XX

The changes have been automatically applied. Please review and test before merging.
```

7. **PR Closes Issue**: The PR body includes `Closes #48`, so merging the PR will automatically close the issue.

## Verification Steps

After the workflow completes:

1. **Check the PR**: Verify the actual code changes in the Files tab
2. **Review the commit**: Ensure version numbers are correct
3. **Test the installer**: Clone the PR branch and run:
```bash
git fetch origin automated-update/ansible-XXXXX
git checkout automated-update/ansible-XXXXX
./ansible/ansible_installer.sh
```
4. **Verify versions**: After installation, check:
```bash
python3 --version # Should show 3.14.3
ansible --version # Should show 13.5.0
```

## NGINX Updates (Different Flow)

For NGINX updates, the workflow behavior is different:

1. **Draft PR**: NGINX PRs are marked as draft because they require SHA256 checksum verification
2. **Manual Step Required**: Use the helper script to update checksums:
```bash
./.github/scripts/update-nginx-checksums.sh
```
3. **Review and Mark Ready**: After checksums are updated, mark the PR as ready for review

## Troubleshooting

### Workflow Doesn't Trigger

- Ensure the issue has the `dependencies` label
- Ensure the issue title contains "Update Available"
- Check the workflow runs in the Actions tab for any errors

### PR Not Created

- Check workflow logs in the Actions tab
- Look for errors in the "Parse issue and update dependencies" step
- Verify the issue body format matches expected patterns

### Version Regex Not Matching

The workflow expects version information in this format:
```
- **ComponentName**: current_version → latest_version
```

Examples:
```
- **Python**: 3.14.2 → 3.14.3
- **NGINX**: 1.29.7 → 1.29.8
- **OpenSSL**: 3.6.1 → 3.6.2
```

## Success Criteria

The automated dependency management is working correctly when:

1. ✅ Workflow triggers automatically on issue creation/edit
2. ✅ Version information is correctly extracted from issues
3. ✅ Installer files are modified with correct version numbers
4. ✅ PRs are created with actual code changes (not empty branches)
5. ✅ NGINX PRs are marked as draft
6. ✅ Ansible/Kubernetes PRs are ready to merge
7. ✅ Issues and PRs are properly linked
8. ✅ Comments are added to issues when PRs are created
9. ✅ All files are committed and pushed successfully

## Next Steps

After successful testing with issue #48:

1. Monitor for new dependency updates
2. Review and merge automatically created PRs
3. Verify that merged PRs close their associated issues
4. Watch for the next weekly dependency check (every Monday at 9:00 AM UTC)
139 changes: 139 additions & 0 deletions .github/scripts/update-nginx-checksums.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#!/usr/bin/env bash
#
# Helper script to calculate and update SHA256 checksums for NGINX dependencies
# This script downloads the dependencies and updates the checksums in installer files
#
# Usage: ./update-nginx-checksums.sh [nginx_version] [openssl_version] [pcre2_version] [zlib_version]
#

set -euo pipefail

readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly NC='\033[0m'

log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
log_error() { echo -e "${RED}[✗]${NC} $1" >&2; }
log_warn() { echo -e "${YELLOW}[!]${NC} $1"; }

# Get versions from arguments or read from installer files
NGINX_VERSION="${1:-$(grep -oP 'NGINX_VERSION="\K[^"]+' nginx/nginx_installer.sh)}"
OPENSSL_VERSION="${2:-$(grep -oP 'OPENSSL_VERSION="\K[^"]+' nginx/nginx_installer.sh)}"
PCRE2_VERSION="${3:-$(grep -oP 'PCRE2_VERSION="\K[^"]+' nginx/nginx_installer.sh)}"
ZLIB_VERSION="${4:-$(grep -oP 'ZLIB_VERSION="\K[^"]+' nginx/nginx_installer.sh)}"

log_info "Versions to check:"
echo " NGINX: $NGINX_VERSION"
echo " OpenSSL: $OPENSSL_VERSION"
echo " PCRE2: $PCRE2_VERSION"
echo " Zlib: $ZLIB_VERSION"
echo

# Create temp directory
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT

Copilot AI Mar 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trap "rm -rf $TEMP_DIR" EXIT should quote the path to avoid issues if the temp directory ever contains unexpected characters. Prefer trap 'rm -rf "${TEMP_DIR}"' EXIT (and keep the rm argument quoted).

Suggested change
trap "rm -rf $TEMP_DIR" EXIT
trap 'rm -rf "${TEMP_DIR}"' EXIT

Copilot uses AI. Check for mistakes.

cd "$TEMP_DIR"

# Download and calculate checksums
log_info "Downloading NGINX $NGINX_VERSION..."
if wget -q "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"; then
NGINX_SHA256=$(sha256sum "nginx-${NGINX_VERSION}.tar.gz" | awk '{print $1}')
log_success "NGINX SHA256: $NGINX_SHA256"
else
log_error "Failed to download NGINX $NGINX_VERSION"
NGINX_SHA256=""
fi

log_info "Downloading OpenSSL $OPENSSL_VERSION..."
if wget -q "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"; then
OPENSSL_SHA256=$(sha256sum "openssl-${OPENSSL_VERSION}.tar.gz" | awk '{print $1}')
log_success "OpenSSL SHA256: $OPENSSL_SHA256"
else
log_error "Failed to download OpenSSL $OPENSSL_VERSION"
OPENSSL_SHA256=""
fi

log_info "Downloading PCRE2 $PCRE2_VERSION..."
if wget -q "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${PCRE2_VERSION}/pcre2-${PCRE2_VERSION}.tar.gz"; then
PCRE2_SHA256=$(sha256sum "pcre2-${PCRE2_VERSION}.tar.gz" | awk '{print $1}')
log_success "PCRE2 SHA256: $PCRE2_SHA256"
else
log_error "Failed to download PCRE2 $PCRE2_VERSION"
PCRE2_SHA256=""
fi

log_info "Downloading Zlib $ZLIB_VERSION..."
if wget -q "https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz"; then
ZLIB_SHA256=$(sha256sum "zlib-${ZLIB_VERSION}.tar.gz" | awk '{print $1}')
log_success "Zlib SHA256: $ZLIB_SHA256"
else
log_error "Failed to download Zlib $ZLIB_VERSION"
ZLIB_SHA256=""
fi

echo
log_info "SHA256 Checksums:"
echo "===================="
[ -n "$NGINX_SHA256" ] && echo "NGINX: $NGINX_SHA256"
[ -n "$OPENSSL_SHA256" ] && echo "OpenSSL: $OPENSSL_SHA256"
[ -n "$PCRE2_SHA256" ] && echo "PCRE2: $PCRE2_SHA256"
[ -n "$ZLIB_SHA256" ] && echo "Zlib: $ZLIB_SHA256"
echo

# Ask if user wants to update the files
read -rp "Update installer files with these checksums? [y/N] " response
if [[ "$response" =~ ^[Yy]$ ]]; then
cd "$OLDPWD"

# Update Bash installer
if [ -n "$NGINX_SHA256" ]; then
sed -i "s/NGINX_SHA256=\"[^\"]*\"/NGINX_SHA256=\"$NGINX_SHA256\"/" nginx/nginx_installer.sh
log_success "Updated NGINX SHA256 in nginx_installer.sh"
fi

if [ -n "$OPENSSL_SHA256" ]; then
sed -i "s/OPENSSL_SHA256=\"[^\"]*\"/OPENSSL_SHA256=\"$OPENSSL_SHA256\"/" nginx/nginx_installer.sh
log_success "Updated OpenSSL SHA256 in nginx_installer.sh"
fi

if [ -n "$PCRE2_SHA256" ]; then
sed -i "s/PCRE2_SHA256=\"[^\"]*\"/PCRE2_SHA256=\"$PCRE2_SHA256\"/" nginx/nginx_installer.sh
log_success "Updated PCRE2 SHA256 in nginx_installer.sh"
fi

if [ -n "$ZLIB_SHA256" ]; then
sed -i "s/ZLIB_SHA256=\"[^\"]*\"/ZLIB_SHA256=\"$ZLIB_SHA256\"/" nginx/nginx_installer.sh
log_success "Updated Zlib SHA256 in nginx_installer.sh"
fi

# Update PowerShell installer
if [ -n "$NGINX_SHA256" ]; then
sed -i "s/\$NGINX_SHA256 = \"[^\"]*\"/\$NGINX_SHA256 = \"$NGINX_SHA256\"/" nginx/nginx_installer.ps1
log_success "Updated NGINX SHA256 in nginx_installer.ps1"
fi

if [ -n "$OPENSSL_SHA256" ]; then
sed -i "s/\$OPENSSL_SHA256 = \"[^\"]*\"/\$OPENSSL_SHA256 = \"$OPENSSL_SHA256\"/" nginx/nginx_installer.ps1
log_success "Updated OpenSSL SHA256 in nginx_installer.ps1"
fi

if [ -n "$PCRE2_SHA256" ]; then
sed -i "s/\$PCRE2_SHA256 = \"[^\"]*\"/\$PCRE2_SHA256 = \"$PCRE2_SHA256\"/" nginx/nginx_installer.ps1
log_success "Updated PCRE2 SHA256 in nginx_installer.ps1"
fi

if [ -n "$ZLIB_SHA256" ]; then
sed -i "s/\$ZLIB_SHA256 = \"[^\"]*\"/\$ZLIB_SHA256 = \"$ZLIB_SHA256\"/" nginx/nginx_installer.ps1
Comment on lines +115 to +130

Copilot AI Mar 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sed replacements for nginx/nginx_installer.ps1 won't match the current file format (it uses $Script:NGINX_SHA256 = '...' with single quotes), so the helper script likely won't update PowerShell checksums even though it reports success. Update the patterns to target $Script:*_SHA256 assignments and the quoting/spacing used in the PS1 installer.

Suggested change
sed -i "s/\$NGINX_SHA256 = \"[^\"]*\"/\$NGINX_SHA256 = \"$NGINX_SHA256\"/" nginx/nginx_installer.ps1
log_success "Updated NGINX SHA256 in nginx_installer.ps1"
fi
if [ -n "$OPENSSL_SHA256" ]; then
sed -i "s/\$OPENSSL_SHA256 = \"[^\"]*\"/\$OPENSSL_SHA256 = \"$OPENSSL_SHA256\"/" nginx/nginx_installer.ps1
log_success "Updated OpenSSL SHA256 in nginx_installer.ps1"
fi
if [ -n "$PCRE2_SHA256" ]; then
sed -i "s/\$PCRE2_SHA256 = \"[^\"]*\"/\$PCRE2_SHA256 = \"$PCRE2_SHA256\"/" nginx/nginx_installer.ps1
log_success "Updated PCRE2 SHA256 in nginx_installer.ps1"
fi
if [ -n "$ZLIB_SHA256" ]; then
sed -i "s/\$ZLIB_SHA256 = \"[^\"]*\"/\$ZLIB_SHA256 = \"$ZLIB_SHA256\"/" nginx/nginx_installer.ps1
sed -i "s/\$Script:NGINX_SHA256[[:space:]]*=[[:space:]]*'[^']*'/\$Script:NGINX_SHA256 = '$NGINX_SHA256'/" nginx/nginx_installer.ps1
log_success "Updated NGINX SHA256 in nginx_installer.ps1"
fi
if [ -n "$OPENSSL_SHA256" ]; then
sed -i "s/\$Script:OPENSSL_SHA256[[:space:]]*=[[:space:]]*'[^']*'/\$Script:OPENSSL_SHA256 = '$OPENSSL_SHA256'/" nginx/nginx_installer.ps1
log_success "Updated OpenSSL SHA256 in nginx_installer.ps1"
fi
if [ -n "$PCRE2_SHA256" ]; then
sed -i "s/\$Script:PCRE2_SHA256[[:space:]]*=[[:space:]]*'[^']*'/\$Script:PCRE2_SHA256 = '$PCRE2_SHA256'/" nginx/nginx_installer.ps1
log_success "Updated PCRE2 SHA256 in nginx_installer.ps1"
fi
if [ -n "$ZLIB_SHA256" ]; then
sed -i "s/\$Script:ZLIB_SHA256[[:space:]]*=[[:space:]]*'[^']*'/\$Script:ZLIB_SHA256 = '$ZLIB_SHA256'/" nginx/nginx_installer.ps1

Copilot uses AI. Check for mistakes.
log_success "Updated Zlib SHA256 in nginx_installer.ps1"
fi

echo
log_success "All checksums updated in installer files!"
log_info "Review the changes with: git diff nginx/"
else
log_info "No changes made to installer files"
fi
Loading
Loading