Skip to content
Closed
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
51 changes: 48 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,52 @@ jobs:
echo "Latest version from API: $LATEST_VERSION"
echo "✅ jq parsing works correctly"

test-rhel8:
name: Test RHEL8 compatibility
runs-on: ubuntu-latest
container:
image: rockylinux:8
steps:
- name: Install required tools
run: |
dnf install -y git curl jq tar gzip findutils which

- name: Checkout repository
uses: actions/checkout@v4

- name: Test setup buildcache on RHEL8
uses: ./

- name: Verify buildcache is in PATH
shell: bash
run: |
if ! command -v buildcache &> /dev/null; then
echo "Error: buildcache not found in PATH"
exit 1
fi
echo "buildcache found in PATH"

- name: Verify buildcache version
shell: bash
run: |
VERSION=$(buildcache --version)
echo "Installed version: $VERSION"
if [[ ! "$VERSION" =~ BuildCache.*version.*[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Error: Invalid version format: $VERSION"
exit 1
fi
echo "Version format is valid"

- name: Test buildcache basic functionality
shell: bash
run: |
buildcache -s
buildcache -z
echo "Basic buildcache commands work on RHEL8"

test-summary:
name: Test Summary
needs: [test-latest-version, test-specific-version, test-invalid-version, test-installation-paths, test-multiple-installations, test-url-formats, test-api-availability]
needs: [test-latest-version, test-specific-version, test-invalid-version, test-installation-paths, test-multiple-installations, test-url-formats, test-api-availability, test-rhel8]
runs-on: ubuntu-latest
if: always()
steps:
Expand All @@ -293,7 +336,8 @@ jobs:
[[ "${{ needs.test-installation-paths.result }}" != "success" ]] || \
[[ "${{ needs.test-multiple-installations.result }}" != "success" ]] || \
[[ "${{ needs.test-url-formats.result }}" != "success" ]] || \
[[ "${{ needs.test-api-availability.result }}" != "success" ]]; then
[[ "${{ needs.test-api-availability.result }}" != "success" ]] || \
[[ "${{ needs.test-rhel8.result }}" != "success" ]]; then
echo "❌ Some tests failed"
exit 1
fi
Expand All @@ -310,4 +354,5 @@ jobs:
echo "| Installation Paths | ${{ needs.test-installation-paths.result == 'success' && '✅ PASS' || '❌ FAIL' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Multiple Installations | ${{ needs.test-multiple-installations.result == 'success' && '✅ PASS' || '❌ FAIL' }} |" >> $GITHUB_STEP_SUMMARY
echo "| URL Format Compatibility | ${{ needs.test-url-formats.result == 'success' && '✅ PASS' || '❌ FAIL' }} |" >> $GITHUB_STEP_SUMMARY
echo "| API Availability | ${{ needs.test-api-availability.result == 'success' && '✅ PASS' || '❌ FAIL' }} |" >> $GITHUB_STEP_SUMMARY
echo "| API Availability | ${{ needs.test-api-availability.result == 'success' && '✅ PASS' || '❌ FAIL' }} |" >> $GITHUB_STEP_SUMMARY
echo "| RHEL8 Compatibility | ${{ needs.test-rhel8.result == 'success' && '✅ PASS' || '❌ FAIL' }} |" >> $GITHUB_STEP_SUMMARY
20 changes: 19 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,29 @@ This is a GitHub Action that installs [buildcache](https://gitlab.com/bits-n-bit
## Project Overview

**Purpose**: Automated installation of buildcache (a compilation caching tool) in GitHub Actions workflows
**Platforms**: Linux (Ubuntu) and Windows
**Platforms**: Linux (Ubuntu, Debian, RHEL, CentOS, Rocky Linux, AlmaLinux, Fedora) and Windows
**Language**: GitHub Actions YAML with Bash and PowerShell scripts

## Key Architecture

### Multi-Distribution Linux Support
The action automatically detects the Linux distribution and uses the appropriate package manager:

**Distribution Detection:**
- Uses `/etc/os-release` to identify the distribution
- Falls back to Debian-based behavior if detection fails

**Package Management:**
- **Debian-based** (Ubuntu, Debian): Uses `apt-get` to install `libssl1.1`
- **RHEL-based** (RHEL 8, CentOS 8, Rocky Linux 8, AlmaLinux 8): Uses `dnf`/`yum` to install `openssl-libs` and `compat-openssl11`
- **Fedora**: Uses `dnf` to install `openssl-libs`
- **Unsupported**: Continues without dependency installation with a warning

**OpenSSL Requirements:**
- buildcache requires OpenSSL 1.1 libraries (libcrypto.so.1.1)
- Ubuntu 24.04+ requires adding focal repository for libssl1.1
- RHEL 8 requires `compat-openssl11` package from PowerTools/CodeReady repository

### Download URL Handling
The action intelligently handles different download URL formats based on buildcache version:

Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This GitHub Action installs [buildcache](https://gitlab.com/bits-n-bites/buildca
## Features

- 🚀 Supports both Linux and Windows runners
- 🐧 Multi-distro Linux support (Ubuntu, Debian, RHEL, CentOS, Rocky Linux, AlmaLinux, Fedora)
- 🔧 Optional version specification (uses latest by default)
- ✅ Automatically adds buildcache to PATH
- 🧹 Cleans up temporary files after installation
Expand Down Expand Up @@ -69,9 +70,14 @@ jobs:

## Supported Platforms

- ✅ Linux (ubuntu-latest, ubuntu-22.04, ubuntu-20.04)
- ✅ Linux (ubuntu-latest, ubuntu-22.04, ubuntu-20.04, RHEL 8, CentOS 8, Rocky Linux 8, AlmaLinux 8)
- ✅ Windows (windows-latest, windows-2022, windows-2019)

The action automatically detects the Linux distribution and uses the appropriate package manager:
- **Debian-based systems** (Ubuntu, Debian): Uses `apt-get` to install `libssl1.1`
- **RHEL-based systems** (RHEL, CentOS, Rocky Linux, AlmaLinux): Uses `dnf`/`yum` to install `openssl-libs` and `compat-openssl11` if needed
- **Fedora**: Uses `dnf` to install `openssl-libs`

## Download URL Compatibility

The action automatically handles different download URL formats based on the buildcache version:
Expand Down Expand Up @@ -153,9 +159,22 @@ buildcache version 0.28.1

If you specify a version that doesn't exist, the action will fail. Check the [releases page](https://gitlab.com/bits-n-bites/buildcache/-/releases) for available versions.

### OpenSSL libraries on RHEL 8

On RHEL 8 systems, buildcache requires OpenSSL 1.1 compatibility libraries. The action will automatically attempt to install `compat-openssl11`. If this fails, you may need to enable the PowerTools (RHEL 8) or CodeReady Builder (CentOS 8) repository:

```bash
# RHEL 8
sudo subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms

# CentOS 8 / Rocky Linux 8 / AlmaLinux 8
sudo dnf config-manager --set-enabled powertools # CentOS 8
sudo dnf config-manager --set-enabled PowerTools # Rocky/Alma Linux 8
```

### Permission errors on Linux

The action uses `sudo` to install buildcache to `/usr/local/bin` on Linux. This should work on GitHub-hosted runners by default.
The action uses `sudo` to install dependencies on Linux. This should work on GitHub-hosted runners by default.

## Testing

Expand Down
94 changes: 72 additions & 22 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,52 +39,102 @@ runs:
if: runner.os == 'Linux'
shell: bash
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "Installing buildcache $VERSION for Linux..."
BUILDCACHE_VERSION="${{ steps.version.outputs.version }}"
echo "Installing buildcache $BUILDCACHE_VERSION for Linux..."

# Install required dependencies
echo "Installing required dependencies..."
sudo apt-get update -qq
# Install OpenSSL 1.1 libraries (buildcache requires libcrypto.so.1.1)
if ! sudo apt-get install -y libssl1.1; then
echo "libssl1.1 not available in default repos, adding focal repo for compatibility..."
echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
sudo apt-get update -qq
sudo apt-get install -y libssl1.1
# Detect Linux distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO_ID=$ID
DISTRO_NAME=$NAME
echo "Detected Linux distribution: $DISTRO_NAME ($DISTRO_ID)"
else
echo "Warning: Cannot detect distribution, assuming Debian-based"
DISTRO_ID="debian"
fi

# Install required dependencies based on distribution
echo "Installing required dependencies..."
case "$DISTRO_ID" in
ubuntu|debian)
# Debian-based systems
sudo apt-get update -qq
# Install OpenSSL 1.1 libraries (buildcache requires libcrypto.so.1.1)
if ! sudo apt-get install -y libssl1.1; then
echo "libssl1.1 not available in default repos, adding focal repo for compatibility..."
echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
sudo apt-get update -qq
sudo apt-get install -y libssl1.1
fi
;;
rhel|centos|rocky|almalinux)
# RHEL-based systems (RHEL 8, CentOS 8, Rocky Linux 8, AlmaLinux 8)
# Check if dnf is available (RHEL 8+), otherwise use yum
if command -v dnf &> /dev/null; then
PKG_MGR="dnf"
else
PKG_MGR="yum"
fi
echo "Using package manager: $PKG_MGR"

# Install OpenSSL libraries (buildcache requires OpenSSL 1.1)
sudo $PKG_MGR install -y openssl-libs || true

# For RHEL 8, we may need compat-openssl11 package for older buildcache versions
# Check if OpenSSL 1.1 libraries are available
if ! find /usr/lib /usr/lib64 /lib /lib64 -name 'libcrypto.so.1.1' 2>/dev/null | grep -q .; then
echo "OpenSSL 1.1 not found, trying to install compat-openssl11..."
if ! sudo $PKG_MGR install -y compat-openssl11; then
echo "Warning: compat-openssl11 not available. Buildcache may require OpenSSL 1.1 compatibility libraries."
echo "Enable the appropriate repository:"
echo " RHEL 8: sudo subscription-manager repos --enable codeready-builder-for-rhel-8-\$(arch)-rpms"
echo " CentOS 8: sudo dnf config-manager --set-enabled powertools"
echo " Rocky/AlmaLinux 8: sudo dnf config-manager --set-enabled PowerTools"
fi
fi
;;
fedora)
# Fedora systems
sudo dnf install -y openssl-libs
;;
*)
echo "Warning: Unsupported distribution '$DISTRO_ID'. Attempting to continue without dependency installation."
echo "Buildcache may require OpenSSL 1.1 libraries to be installed manually."
;;
esac

# Determine download URL based on version
# v0.31.4+ uses buildcache-linux-amd64.tar.gz
# v0.31.3 and earlier use buildcache-linux.tar.gz
VERSION_NUM=${VERSION#v}
VERSION_NUM=${BUILDCACHE_VERSION#v}
MAJOR=$(echo $VERSION_NUM | cut -d. -f1)
MINOR=$(echo $VERSION_NUM | cut -d. -f2)
PATCH=$(echo $VERSION_NUM | cut -d. -f3)

if [[ $MAJOR -eq 0 && $MINOR -lt 30 ]]; then
# v0.29.x and earlier use GitLab package registry
DOWNLOAD_URL="https://gitlab.com/api/v4/projects/49153623/packages/generic/releases/$VERSION/buildcache-linux.tar.gz"
echo "Using package registry URL for $VERSION (≤v0.29.x)"
DOWNLOAD_URL="https://gitlab.com/api/v4/projects/49153623/packages/generic/releases/$BUILDCACHE_VERSION/buildcache-linux.tar.gz"
echo "Using package registry URL for $BUILDCACHE_VERSION (≤v0.29.x)"
elif [[ $MAJOR -gt 0 ]] || [[ $MAJOR -eq 0 && $MINOR -gt 31 ]] || [[ $MAJOR -eq 0 && $MINOR -eq 31 && $PATCH -ge 4 ]]; then
# v0.31.4+ uses buildcache-linux-amd64.tar.gz
DOWNLOAD_URL="https://gitlab.com/bits-n-bites/buildcache/-/releases/$VERSION/downloads/buildcache-linux-amd64.tar.gz"
echo "Using new URL format for $VERSION (v0.31.4+)"
DOWNLOAD_URL="https://gitlab.com/bits-n-bites/buildcache/-/releases/$BUILDCACHE_VERSION/downloads/buildcache-linux-amd64.tar.gz"
echo "Using new URL format for $BUILDCACHE_VERSION (v0.31.4+)"
else
# v0.30.0 to v0.31.3 use buildcache-linux.tar.gz
DOWNLOAD_URL="https://gitlab.com/bits-n-bites/buildcache/-/releases/$VERSION/downloads/buildcache-linux.tar.gz"
echo "Using legacy URL format for $VERSION (v0.30.0-v0.31.3)"
DOWNLOAD_URL="https://gitlab.com/bits-n-bites/buildcache/-/releases/$BUILDCACHE_VERSION/downloads/buildcache-linux.tar.gz"
echo "Using legacy URL format for $BUILDCACHE_VERSION (v0.30.0-v0.31.3)"
fi

# Download with error handling
if ! curl -L "$DOWNLOAD_URL" -o buildcache.tar.gz --fail; then
echo "Error: Failed to download buildcache $VERSION. Please check if this version exists."
echo "Error: Failed to download buildcache $BUILDCACHE_VERSION. Please check if this version exists."
echo "Available releases: https://gitlab.com/bits-n-bites/buildcache/-/releases"
exit 1
fi

# Create installation directory
INSTALL_DIR="$HOME/.local/buildcache-$VERSION"
INSTALL_DIR="$HOME/.local/buildcache-$BUILDCACHE_VERSION"
mkdir -p "$INSTALL_DIR"

# Extract with error handling
Expand Down Expand Up @@ -129,7 +179,7 @@ runs:

# Show where buildcache was installed
INSTALLED_PATH=$(which buildcache)
echo "buildcache $VERSION installed successfully on Linux"
echo "buildcache $BUILDCACHE_VERSION installed successfully on Linux"
echo "Binary location: $INSTALLED_PATH"
echo "Installation directory: $BINARY_PATH"

Expand Down
Loading