fix: improve CI workflow for Gitea compatibility and test detection
Some checks failed
CI / Test (pull_request) Failing after 46s
CI / Lint (pull_request) Failing after 5s
CI / Build (pull_request) Successful in 14s
CI / Format Check (pull_request) Successful in 3s

- Improve test file detection with more robust find command
  - Use explicit variable assignment instead of pipe to grep
  - Add debug output to show found test files
  - Handle errors gracefully with 2>/dev/null || true

- Downgrade actions for Gitea compatibility
  - upload-artifact@v4 -> v3 (Gitea doesn't support v4+)
  - codecov-action@v4 -> v3 (preventive downgrade)

- Add Alpine Linux build dependencies installation step
  - Install build-base and musl-dev when running on Alpine
  - Required for CGO-enabled builds and race detector

- Disable CGO for verify build step when no tests exist
  - Avoids requiring C build tools for simple compilation check
This commit is contained in:
2025-11-05 12:57:04 +01:00
parent 0bfdb2c2d7
commit 6b0ba2edc7

View File

@@ -36,11 +36,15 @@ jobs:
- name: Check for test files
id: check-tests
run: |
if find . -name "*_test.go" -not -path "./vendor/*" -not -path "./.git/*" | grep -q .; then
echo "Checking for test files..."
TEST_FILES=$(find . -name "*_test.go" -not -path "./vendor/*" -not -path "./.git/*" 2>/dev/null || true)
if [ -n "$TEST_FILES" ]; then
echo "Found test files:"
echo "$TEST_FILES"
echo "tests_exist=true" >> $GITHUB_OUTPUT
else
echo "tests_exist=false" >> $GITHUB_OUTPUT
echo "No test files found. Skipping test execution."
echo "tests_exist=false" >> $GITHUB_OUTPUT
fi
- name: Run tests
@@ -51,7 +55,7 @@ jobs:
- name: Upload coverage
if: steps.check-tests.outputs.tests_exist == 'true'
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v3
with:
file: ./coverage.out
fail_ci_if_error: false
@@ -107,7 +111,7 @@ jobs:
run: go build -v -o bin/platform ./cmd/platform
- name: Upload build artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: platform-binary
path: bin/platform