Skip to content

fix: correct release file format & add ci controls #270

fix: correct release file format & add ci controls

fix: correct release file format & add ci controls #270

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 [ -f dist/*_linux_amd64.zip ]; then
echo "✓ Linux amd64 zip found"
file dist/*_linux_amd64.zip
unzip -l dist/*_linux_amd64.zip | head -5
else
echo "✗ Linux amd64 zip not found"
exit 1
fi
echo -e "\n=== Validating Windows builds ==="
if [ -f dist/*_windows_amd64.zip ]; then
echo "✓ Windows amd64 zip found"
file dist/*_windows_amd64.zip
unzip -l dist/*_windows_amd64.zip | head -10
else
echo "✗ Windows amd64 zip not found"
exit 1
fi
echo -e "\n=== Testing binary execution ==="
# Extract and test a binary
LINUX_BINARY=$(find dist -name "*_linux_amd64" -type f | head -1)
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=== Build validation completed successfully! ==="