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
10 changes: 1 addition & 9 deletions .github/workflows/pre-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ jobs:
uses: mfinelli/setup-shfmt@a25fda4c1fe115aec0f85e04126610841bc3141d # v4.0.1

- name: Lint shell scripts
run: |
echo "Linting shell scripts in scripts/ directory..."
shfmt -d -i 2 -ci scripts/*.sh
if [ $? -ne 0 ]; then
echo "❌ Shell script formatting issues found!"
echo "Run 'shfmt -w -i 2 -ci scripts/*.sh' to fix them."
exit 1
fi
echo "✅ All shell scripts are properly formatted!"
run: make lint

run-ocp:
needs: lint-scripts
Expand Down
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.PHONY: lint fix-lint help

help: ## Show this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'

lint: ## Check shell script formatting
@echo "Linting shell scripts in scripts/ directory..."
@shfmt -d -i 2 -ci scripts/*.sh
@if [ $$? -eq 0 ]; then \
echo "✅ All shell scripts are properly formatted!"; \
else \
echo "❌ Shell script formatting issues found!"; \
echo "Run 'make fix-lint' to fix them."; \
exit 1; \
fi

fix-lint: ## Fix shell script formatting issues
@echo "Fixing shell script formatting in scripts/ directory..."
@shfmt -w -i 2 -ci scripts/*.sh
@echo "✅ All shell scripts have been formatted!"

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ If you are looking to quickly spawn Kubernetes in your Action runner, try [quick

- This does not run correctly on `ubuntu-20.04` runners due to the version of `libvirt` available in the mirrors isn't the minimum version required by OpenShift Local.

# Connectivity Requirements:

This action requires network access to the **OpenShift Mirror** (`https://mirror.openshift.com`) for downloading CRC binaries and OpenShift client tools.

The action includes an automatic connectivity check that runs at the beginning of each workflow. If the OpenShift Mirror is unreachable, the action will fail gracefully with a clear error message.

You can disable this check by setting `disableConnectivityCheck: true` in your workflow:

```yaml
with:
disableConnectivityCheck: true
```

Note: Disabling this check is not recommended as it may result in less clear error messages if connectivity issues occur during the workflow.

# Usage:

Basic Usage:
Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ inputs:
description: 'Specific CRC version to use (overrides version detection and pinning)'
required: false
default: ''
disableConnectivityCheck:
description: 'Disable the connectivity check for OpenShift Mirror'
required: false
default: 'false'

runs:
using: 'composite'
steps:

- name: Check connectivity to required services
if: ${{ inputs.disableConnectivityCheck != 'true' }}
shell: bash
run: ${{ github.action_path }}/scripts/check-connectivity.sh

- name: Set CRC version variable
id: set_crc_version
shell: bash
Expand Down
62 changes: 62 additions & 0 deletions scripts/check-connectivity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
set -e

echo "=== Checking connectivity to required external services ==="

# Track if any checks fail
CONNECTIVITY_OK=true
FAILED_SERVICES=()

# Function to check connectivity to a service
check_service() {
local service_name="$1"
local url="$2"
local timeout="${3:-10}"

echo -n "Checking $service_name... "

# Use curl with timeout and follow redirects
# -s: silent, -f: fail on HTTP errors, -L: follow redirects, -I: HEAD request only
# --max-time: maximum time for the operation
# --connect-timeout: maximum time for connection
if curl -s -f -L -I --connect-timeout "$timeout" --max-time "$timeout" "$url" >/dev/null 2>&1; then
echo "✓ OK"
return 0
else
echo "✗ FAILED"
CONNECTIVITY_OK=false
FAILED_SERVICES+=("$service_name")
return 1
fi
}

# Check OpenShift Mirror (primary dependency)
# Test with a known stable endpoint
check_service "OpenShift Mirror" "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/release.txt" 15

echo ""
echo "=== Connectivity Check Summary ==="

if [ "$CONNECTIVITY_OK" = true ]; then
echo "✓ All required services are accessible"
echo ""
exit 0
else
echo "✗ Connectivity check FAILED"
echo ""
echo "The following services could not be reached:"
for service in "${FAILED_SERVICES[@]}"; do
echo " - $service"
done
echo ""
echo "This action requires internet access to the OpenShift mirrors."
echo "Please check your network connection and try again."
echo ""
echo "Common causes:"
echo " - Network connectivity issues"
echo " - Firewall blocking access to mirror.openshift.com"
echo " - OpenShift Mirror temporarily unavailable"
echo " - DNS resolution problems"
echo ""
exit 1
fi