Skip to content

fix CI controls

fix CI controls #272

Workflow file for this run

name: CI Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
permissions:
contents: read
checks: write # For test reporting
pull-requests: write # For PR comments
env:
CGO_ENABLED: 1 # Required for race detection in tests
jobs:
# Matrix strategy for testing multiple Go versions efficiently
test:
name: Test Go ${{ matrix.go-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ['1.23', '1.24']
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
check-latest: true
cache: true # Enable caching for better performance
cache-dependency-path: |
go.sum
go.mod
- name: Download dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Build
run: go build -v ./...
- name: Run tests
env:
CGO_ENABLED: 1
run: |
go test -v -race -coverprofile=coverage-${{ matrix.go-version }}.out -covermode=atomic ./...
# Codecov upload disabled due to token issues with protected branches
# - name: Upload coverage to Codecov
# if: matrix.go-version == '1.23' # Only upload once
# uses: codecov/codecov-action@v5
# with:
# file: ./coverage-${{ matrix.go-version }}.out
# fail_ci_if_error: false
# Integration tests (if you have any)
integration:
name: Integration Tests
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
cache: true
- name: Run integration tests
run: |
# Add integration test commands here when available
echo "Integration tests would run here"
# Test build artifacts
build-validation:
name: Validate Build Artifacts
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0 # Full history needed for GoReleaser
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
cache: true
- name: Test GoReleaser build
uses: goreleaser/goreleaser-action@v6.4.0
with:
version: v2.12.0
args: build --snapshot --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate built artifacts
run: |
echo "=== Checking built artifacts ==="
ls -la dist/
echo -e "\n=== Validating Linux builds ==="
if [ -d "dist/terraform-provider-wallix-bastion_linux_amd64_v1" ]; then
echo "✓ Linux amd64 build directory found"
ls -la "dist/terraform-provider-wallix-bastion_linux_amd64_v1/"
# Check if binary exists
LINUX_BINARY=$(find "dist/terraform-provider-wallix-bastion_linux_amd64_v1" -name "*" -type f | head -1)
if [ -n "$LINUX_BINARY" ]; then
echo "✓ Linux binary found: $LINUX_BINARY"
file "$LINUX_BINARY"
ls -lh "$LINUX_BINARY"
else
echo "✗ No binary found in Linux build directory"
exit 1
fi
else
echo "✗ Linux amd64 build directory not found"
exit 1
fi
echo -e "\n=== Validating Windows builds ==="
if [ -d "dist/terraform-provider-wallix-bastion_windows_amd64_v1" ]; then
echo "✓ Windows amd64 build directory found"
ls -la "dist/terraform-provider-wallix-bastion_windows_amd64_v1/"
# Check if binary exists
WINDOWS_BINARY=$(find "dist/terraform-provider-wallix-bastion_windows_amd64_v1" -name "*" -type f | head -1)
if [ -n "$WINDOWS_BINARY" ]; then
echo "✓ Windows binary found: $WINDOWS_BINARY"
file "$WINDOWS_BINARY"
ls -lh "$WINDOWS_BINARY"
else
echo "✗ No binary found in Windows build directory"
exit 1
fi
else
echo "✗ Windows amd64 build directory not found"
exit 1
fi
echo -e "\n=== Testing binary execution ==="
# Test Linux binary
if [ -n "$LINUX_BINARY" ]; then
echo "Testing binary: $LINUX_BINARY"
chmod +x "$LINUX_BINARY"
if $LINUX_BINARY version 2>/dev/null || $LINUX_BINARY --help 2>/dev/null || $LINUX_BINARY -h 2>/dev/null; then
echo "✓ Binary executes successfully"
else
echo "⚠ Binary execution test (expected for Terraform providers without CLI)"
fi
fi
echo -e "\n=== Testing GoReleaser archive creation ==="
# Test that GoReleaser can create archives (dry run)
echo "Testing archive creation with GoReleaser..."
if which goreleaser >/dev/null 2>&1; then
# Check the config is valid
goreleaser check
echo "✓ GoReleaser configuration is valid"
else
echo "⚠ GoReleaser not available for config check"
fi
echo -e "\n=== Build validation completed successfully! ==="