Skip to content

fix compiler-warning about masking lower-case copy (#37) #49

fix compiler-warning about masking lower-case copy (#37)

fix compiler-warning about masking lower-case copy (#37) #49

Workflow file for this run

name: OpenWrt Build Test
on:
push:
branches: [ master ]
paths:
- 'openwrt-main/**'
- 'openwrt-luci/**'
- '*.c'
- '*.h'
- 'Makefile'
pull_request:
branches: [ master ]
paths:
- 'openwrt-main/**'
- 'openwrt-luci/**'
- '*.c'
- '*.h'
- 'Makefile'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
OPENWRT_VERSION: "23.05.5"
jobs:
test-openwrt-build:
runs-on: ubuntu-latest
strategy:
matrix:
target:
# Popular OpenWrt targets for testing
# Format: [name, target, subtarget]
- [x86_64, x86, 64]
- [ramips_mt7621, ramips, mt7621]
- [ath79_generic, ath79, generic]
- [mediatek_filogic, mediatek, filogic]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Free up disk space
run: |
# Free up disk space on GitHub Actions runner
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo apt-get clean
df -h
- name: Set up environment
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
clang \
flex \
bison \
g++ \
gawk \
gcc-multilib \
g++-multilib \
gettext \
git \
libncurses5-dev \
libssl-dev \
rsync \
unzip \
zlib1g-dev \
file \
wget \
python3 \
python3-setuptools \
python3-dev \
swig
- name: Clone OpenWrt SDK
run: |
TARGET="${{ matrix.target[1] }}"
SUBTARGET="${{ matrix.target[2] }}"
echo "Downloading OpenWrt SDK for ${TARGET}/${SUBTARGET}..."
# Use SDK instead of full source for faster builds
SDK_URL="https://downloads.openwrt.org/releases/${OPENWRT_VERSION}/targets/${TARGET}/${SUBTARGET}/openwrt-sdk-${OPENWRT_VERSION}-${TARGET}-${SUBTARGET}_gcc-12.3.0_musl.Linux-x86_64.tar.xz"
wget -q "$SDK_URL" -O sdk.tar.xz || {
echo "Failed to download SDK from $SDK_URL"
echo "Trying alternative URL..."
SDK_URL="https://downloads.openwrt.org/releases/${OPENWRT_VERSION}/targets/${TARGET}/${SUBTARGET}/openwrt-sdk-${TARGET}-${SUBTARGET}_gcc-12.3.0_musl.Linux-x86_64.tar.xz"
wget -q "$SDK_URL" -O sdk.tar.xz
}
tar -xf sdk.tar.xz
SDK_DIR=$(find . -maxdepth 1 -type d -name "openwrt-sdk-*" | head -1)
echo "OPENWRT_DIR=$(realpath $SDK_DIR)" >> $GITHUB_ENV
echo "OpenWrt SDK extracted successfully: $SDK_DIR"
# Update feeds (only base packages, skip telephony to avoid non-critical errors)
cd "$SDK_DIR"
./scripts/feeds update -a || true
# Install only base and luci feeds, skip telephony
./scripts/feeds install -a -p base || true
./scripts/feeds install -a -p luci || true
./scripts/feeds install -a -p packages || true
./scripts/feeds install -a -p routing || true
- name: Prepare packages for build
run: |
TARGET_NAME="${{ matrix.target[0] }}"
echo "Preparing wg-obfuscator packages for ${TARGET_NAME}..."
# Create parent directories
mkdir -p "${OPENWRT_DIR}/package/network"
mkdir -p "${OPENWRT_DIR}/package/luci"
# Create symlink for main package
echo "Creating symlink for main package..."
ln -sf "$(pwd)/openwrt-main" "${OPENWRT_DIR}/package/network/wg-obfuscator"
echo "Main package structure:"
ls -la "${OPENWRT_DIR}/package/network/wg-obfuscator/"
# Create symlink for LuCI app
if [ -d "openwrt-luci" ]; then
echo "Creating symlink for LuCI app..."
ln -sf "$(pwd)/openwrt-luci" "${OPENWRT_DIR}/package/luci/luci-app-wg-obfuscator"
echo "LuCI app structure:"
ls -la "${OPENWRT_DIR}/package/luci/luci-app-wg-obfuscator/"
fi
# Make scripts executable
chmod +x openwrt-main/files/wg-obfuscator.init
chmod +x openwrt-main/files/wg-obfuscator-config.sh
- name: Configure OpenWrt build
run: |
cd "${OPENWRT_DIR}"
echo "Configuring OpenWrt..."
# Enable our packages
echo "CONFIG_PACKAGE_wg-obfuscator=y" >> .config
# Enable LuCI app if present
if [ -d "package/luci/luci-app-wg-obfuscator" ]; then
echo "CONFIG_PACKAGE_luci-app-wg-obfuscator=y" >> .config
fi
# Update config
make defconfig
# Debug: Show configuration
echo "=== Configuration ==="
grep "CONFIG_PACKAGE_wg-obfuscator" .config || echo "Packages not found in config!"
grep "CONFIG_PACKAGE_luci-app-wg-obfuscator" .config || echo "LuCI app not in config (may be optional)"
echo "=== End Configuration ==="
- name: Build OpenWrt packages
run: |
TARGET_NAME="${{ matrix.target[0] }}"
cd "${OPENWRT_DIR}"
echo "Building wg-obfuscator package for ${TARGET_NAME}..."
# Build main package (install is not a separate target, .ipk is created during compile)
make package/wg-obfuscator/{clean,download,prepare,compile} V=s CONFIG_PACKAGE_wg-obfuscator=y -j$(nproc) || {
echo "Main package build failed, checking logs..."
if [ -d "logs" ]; then
find logs -name "*.log" -type f 2>/dev/null | head -5 | xargs tail -50 2>/dev/null || true
fi
echo "Checking build directory..."
find build_dir -name "wg-obfuscator" -type f 2>/dev/null | head -5
exit 1
}
echo "✅ Main package built successfully!"
# Build LuCI app if present
if [ -d "package/luci/luci-app-wg-obfuscator" ]; then
echo "Building LuCI app for ${TARGET_NAME}..."
make package/luci-app-wg-obfuscator/{clean,compile} V=s CONFIG_PACKAGE_luci-app-wg-obfuscator=y -j$(nproc) || {
echo "⚠️ LuCI app build failed (non-critical)"
}
# Check if built
if find bin/packages -name "luci-app-wg-obfuscator*.ipk" -type f | head -1 | grep -q .; then
echo "✅ LuCI app built successfully!"
else
echo "⚠️ LuCI app was not built (this is optional)"
fi
fi
echo "Build completed!"
- name: Verify build artifacts
run: |
TARGET_NAME="${{ matrix.target[0] }}"
cd "${OPENWRT_DIR}"
echo "Verifying build artifacts for ${TARGET_NAME}..."
echo ""
# Find all built packages
echo "=== Built packages ==="
find bin/packages -name "*wg-obfuscator*.ipk" -type f | while read pkg; do
echo " - $pkg ($(du -h "$pkg" | cut -f1))"
done
echo ""
# Find main package
PKG_FILE=$(find bin/packages -name "wg-obfuscator_*.ipk" -type f | head -1)
if [ -n "$PKG_FILE" ]; then
echo "=== Main package verification ==="
echo "✅ wg-obfuscator package built successfully"
echo "Package: $PKG_FILE"
ls -lh "$PKG_FILE"
# Check package contents
echo ""
echo "Package contents:"
tar -tzf "$PKG_FILE" | grep -E "(data\.tar\.gz|control\.tar\.gz|debian-binary)"
echo ""
echo "Files in package:"
tar -xzOf "$PKG_FILE" ./data.tar.gz | tar -tz | head -20
# Verify key files
echo ""
if tar -xzOf "$PKG_FILE" ./data.tar.gz | tar -tz | grep -q "usr/bin/wg-obfuscator"; then
echo "✅ Binary file present in package"
else
echo "❌ Binary file missing from package"
exit 1
fi
if tar -xzOf "$PKG_FILE" ./data.tar.gz | tar -tz | grep -q "etc/init.d/wg-obfuscator"; then
echo "✅ Init script present in package"
else
echo "❌ Init script missing from package"
exit 1
fi
if tar -xzOf "$PKG_FILE" ./data.tar.gz | tar -tz | grep -q "etc/config/wg-obfuscator"; then
echo "✅ UCI config present in package"
else
echo "❌ UCI config missing from package"
exit 1
fi
else
echo "❌ wg-obfuscator package not found"
echo "Checking build directory..."
find build_dir -name "wg-obfuscator" -type f | head -5
exit 1
fi
echo ""
# Verify LuCI package if present
LUCI_PKG_FILE=$(find bin/packages -name "luci-app-wg-obfuscator*.ipk" -type f | head -1)
if [ -n "$LUCI_PKG_FILE" ]; then
echo "=== LuCI app verification ==="
echo "✅ luci-app-wg-obfuscator package built successfully"
echo "Package: $LUCI_PKG_FILE"
ls -lh "$LUCI_PKG_FILE"
echo ""
echo "Files in LuCI package:"
tar -xzOf "$LUCI_PKG_FILE" ./data.tar.gz | tar -tz | grep "luci" | head -20
# Verify key LuCI files
if tar -xzOf "$LUCI_PKG_FILE" ./data.tar.gz | tar -tz | grep -q "luci/controller/wg-obfuscator.lua"; then
echo "✅ LuCI controller present in package"
else
echo "⚠️ LuCI controller missing from package"
fi
if tar -xzOf "$LUCI_PKG_FILE" ./data.tar.gz | tar -tz | grep -q "luci/model/cbi/wg-obfuscator.lua"; then
echo "✅ LuCI CBI model present in package"
else
echo "⚠️ LuCI CBI model missing from package"
fi
else
echo "=== LuCI app ==="
echo "ℹ️ LuCI app was not built (this is optional)"
fi
- name: Clean up
if: always()
run: |
# Clean up to save space
if [ -d "${OPENWRT_DIR}" ]; then
rm -rf "${OPENWRT_DIR}/build_dir" "${OPENWRT_DIR}/staging_dir"
echo "Cleanup completed"
fi
test-openwrt-syntax:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test shell script syntax
run: |
echo "Testing shell script syntax..."
# Test main config generator
bash -n openwrt-main/files/wg-obfuscator-config.sh
echo "✅ wg-obfuscator-config.sh syntax OK"
# Test init script
bash -n openwrt-main/files/wg-obfuscator.init
echo "✅ wg-obfuscator.init syntax OK"
# Test build scripts
bash -n openwrt-main/build.sh
echo "✅ openwrt-main/build.sh syntax OK"
bash -n openwrt-luci/build.sh
echo "✅ openwrt-luci/build.sh syntax OK"
# Test LuCI defaults if present
if [ -f "openwrt-luci/root/etc/uci-defaults/luci-wg-obfuscator" ]; then
bash -n openwrt-luci/root/etc/uci-defaults/luci-wg-obfuscator
echo "✅ luci-wg-obfuscator defaults syntax OK"
fi
- name: Test Lua syntax
run: |
echo "Testing Lua syntax..."
sudo apt-get update -qq
sudo apt-get install -y -qq lua5.1 > /dev/null
# Test LuCI files if present (using luac -p for syntax check)
if [ -f "openwrt-luci/luasrc/controller/wg-obfuscator.lua" ]; then
luac -p openwrt-luci/luasrc/controller/wg-obfuscator.lua
echo "✅ LuCI controller syntax OK"
fi
if [ -f "openwrt-luci/luasrc/model/cbi/wg-obfuscator.lua" ]; then
luac -p openwrt-luci/luasrc/model/cbi/wg-obfuscator.lua
echo "✅ LuCI model syntax OK"
fi
- name: Test Makefile structure
run: |
echo "Testing Makefile structure..."
# Test main OpenWrt Makefile
if grep -q "include.*rules.mk" openwrt-main/Makefile; then
echo "✅ OpenWrt Makefile has correct structure"
else
echo "❌ OpenWrt Makefile missing required includes"
exit 1
fi
# Check for PKG_SOURCE_PROTO
if grep -q "PKG_SOURCE_PROTO:=git" openwrt-main/Makefile; then
echo "✅ Makefile uses git source protocol"
else
echo "⚠️ Makefile doesn't use git source protocol"
fi
# Check for Build/Compile section
if grep -q "define Build/Compile" openwrt-main/Makefile; then
echo "✅ Makefile has Build/Compile section"
else
echo "❌ Makefile missing Build/Compile section"
exit 1
fi
# Test LuCI Makefile if present
if [ -f "openwrt-luci/Makefile" ]; then
if grep -q "include.*rules.mk" openwrt-luci/Makefile; then
echo "✅ LuCI Makefile has correct structure"
else
echo "❌ LuCI Makefile missing required includes"
exit 1
fi
fi
- name: Validate file permissions
run: |
echo "Validating file permissions..."
# Check that scripts are executable
for script in \
"openwrt-main/files/wg-obfuscator-config.sh" \
"openwrt-main/files/wg-obfuscator.init" \
"openwrt-main/build.sh" \
"openwrt-luci/build.sh"
do
if [ -x "$script" ]; then
echo "✅ $(basename $script) is executable"
else
echo "❌ $(basename $script) is not executable"
exit 1
fi
done
# Check LuCI defaults if present
if [ -f "openwrt-luci/root/etc/uci-defaults/luci-wg-obfuscator" ]; then
if [ -x "openwrt-luci/root/etc/uci-defaults/luci-wg-obfuscator" ]; then
echo "✅ luci-wg-obfuscator defaults is executable"
else
echo "❌ luci-wg-obfuscator defaults is not executable"
exit 1
fi
fi
test-openwrt-config-generation:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test configuration generation (without UCI)
run: |
echo "Testing configuration file structure..."
# Check that config files have correct structure
if [ -f "openwrt-main/files/wg-obfuscator.config" ]; then
echo "✅ UCI config file exists"
cat openwrt-main/files/wg-obfuscator.config
else
echo "❌ UCI config file missing"
exit 1
fi
if [ -f "openwrt-main/files/wg-obfuscator.conf" ]; then
echo "✅ App config file exists"
head -10 openwrt-main/files/wg-obfuscator.conf
else
echo "❌ App config file missing"
exit 1
fi
- name: Test error handling in scripts
run: |
echo "Testing error handling..."
# Test init script with dry-run
if bash openwrt-main/files/wg-obfuscator.init help 2>&1 | grep -q "Usage"; then
echo "✅ Init script shows usage"
else
echo "ℹ️ Init script doesn't show usage (might be OK)"
fi