mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
Enhance CI workflow for CGO dependency installation and testing
Some checks failed
CI/CD Pipeline / frontend-lint (push) Successful in 1m43s
CI/CD Pipeline / frontend-build (push) Failing after 27s
CI/CD Pipeline / backend-lint (push) Failing after 5m8s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / e2e-test (push) Has been skipped
Some checks failed
CI/CD Pipeline / frontend-lint (push) Successful in 1m43s
CI/CD Pipeline / frontend-build (push) Failing after 27s
CI/CD Pipeline / backend-lint (push) Failing after 5m8s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / e2e-test (push) Has been skipped
- Update the installation step for GCC to include checks for various package managers - Improve error handling and output messages for GCC installation - Modify test execution to conditionally enable CGO based on GCC availability - Ensure compatibility with non-CGO builds by setting CGO_ENABLED appropriately
This commit is contained in:
parent
72701eedb4
commit
f7ec8352b9
@ -65,47 +65,52 @@ jobs:
|
||||
with:
|
||||
go-version: '1.25.3'
|
||||
cache: true
|
||||
- name: Install CGO dependencies
|
||||
- name: Install CGO dependencies (for race detector)
|
||||
id: cgo-setup
|
||||
run: |
|
||||
set -e
|
||||
echo "Checking for gcc..."
|
||||
# Check if gcc is available
|
||||
echo "Checking for gcc (required for race detector)..."
|
||||
CGO_AVAILABLE=0
|
||||
# Check if gcc is already available
|
||||
if command -v gcc &> /dev/null; then
|
||||
echo "✓ gcc is already available"
|
||||
gcc --version
|
||||
CGO_AVAILABLE=1
|
||||
else
|
||||
echo "gcc not found, installing build-essential..."
|
||||
# Install build-essential which includes gcc
|
||||
# Check if we're root (common in CI environments)
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
echo "Running as root, installing directly..."
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential
|
||||
echo "gcc not found, attempting to install..."
|
||||
# Detect package manager and install gcc
|
||||
if command -v apt-get &> /dev/null; then
|
||||
echo "Using apt-get (Debian/Ubuntu)..."
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential && CGO_AVAILABLE=1 || true
|
||||
else
|
||||
(sudo apt-get update -qq && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y -qq build-essential && CGO_AVAILABLE=1) || \
|
||||
(apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential && CGO_AVAILABLE=1) || true
|
||||
fi
|
||||
elif command -v apk &> /dev/null; then
|
||||
echo "Using apk (Alpine)..."
|
||||
apk add --no-cache gcc musl-dev && CGO_AVAILABLE=1 || true
|
||||
elif command -v yum &> /dev/null; then
|
||||
echo "Using yum (RHEL/CentOS)..."
|
||||
yum install -y gcc && CGO_AVAILABLE=1 || true
|
||||
elif command -v dnf &> /dev/null; then
|
||||
echo "Using dnf (Fedora)..."
|
||||
dnf install -y gcc && CGO_AVAILABLE=1 || true
|
||||
else
|
||||
echo "Not root, trying with sudo..."
|
||||
sudo apt-get update || apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y build-essential || \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential
|
||||
echo "⚠ No supported package manager found (apt-get, apk, yum, dnf)"
|
||||
echo "⚠ gcc installation skipped - race detector will be disabled"
|
||||
fi
|
||||
# Verify installation - check common locations
|
||||
if command -v gcc &> /dev/null; then
|
||||
|
||||
# Verify installation
|
||||
if command -v gcc &> /dev/null || [ -f /usr/bin/gcc ]; then
|
||||
echo "✓ gcc successfully installed"
|
||||
gcc --version
|
||||
elif [ -f /usr/bin/gcc ]; then
|
||||
echo "✓ gcc found at /usr/bin/gcc"
|
||||
/usr/bin/gcc --version
|
||||
export PATH="/usr/bin:$PATH"
|
||||
gcc --version || /usr/bin/gcc --version
|
||||
CGO_AVAILABLE=1
|
||||
else
|
||||
echo "✗ gcc installation verification failed"
|
||||
echo "PATH: $PATH"
|
||||
echo "Searching for gcc..."
|
||||
find /usr -name gcc 2>/dev/null | head -5 || echo "gcc not found in /usr"
|
||||
exit 1
|
||||
echo "⚠ gcc installation failed - race detector will be disabled"
|
||||
fi
|
||||
fi
|
||||
# Final verification
|
||||
echo "Final gcc check:"
|
||||
gcc --version || /usr/bin/gcc --version || (echo "ERROR: gcc still not found" && exit 1)
|
||||
echo "cgo_available=$CGO_AVAILABLE" >> $GITHUB_OUTPUT
|
||||
continue-on-error: true
|
||||
- name: Install dependencies
|
||||
working-directory: bugulma/backend
|
||||
run: go mod download
|
||||
@ -155,10 +160,18 @@ jobs:
|
||||
GOSUMDB: sum.golang.org
|
||||
- name: Test
|
||||
working-directory: bugulma/backend
|
||||
run: go test -v -race -coverprofile=coverage.out ./...
|
||||
run: |
|
||||
# Check if CGO is available for race detector
|
||||
CGO_AVAILABLE="${{ steps.cgo-setup.outputs.cgo_available || '0' }}"
|
||||
if [ "$CGO_AVAILABLE" = "1" ] && command -v gcc &> /dev/null; then
|
||||
echo "Running tests with race detector..."
|
||||
CGO_ENABLED=1 go test -v -race -coverprofile=coverage.out ./...
|
||||
else
|
||||
echo "Running tests without race detector (CGO not available)..."
|
||||
CGO_ENABLED=0 go test -v -coverprofile=coverage.out ./...
|
||||
fi
|
||||
env:
|
||||
GO111MODULE: on
|
||||
CGO_ENABLED: 1
|
||||
GOPROXY: https://proxy.golang.org,direct
|
||||
GOSUMDB: sum.golang.org
|
||||
- name: Coverage
|
||||
|
||||
Loading…
Reference in New Issue
Block a user