Skip to content

Feature/docs

Feature/docs #44

Workflow file for this run

name: KSM Dev CI/CD Pipeline
on:
pull_request:
branches:
- alpha
- "beta/*"
- dev
push:
branches:
- alpha
- "beta/*"
- dev
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
platform:
- ubuntu
- macOS
go:
- 21
- 22
- 23
runs-on: ${{ matrix.platform }}-latest
name: Build and Test on ${{ matrix.platform }} with Go 1.${{ matrix.go }}.x
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2 # Fetch the last two commits for better context
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go }}-
- name: Set up Go environment
uses: actions/setup-go@v5
with:
go-version: 1.${{ matrix.go }}.x # Specify Go version based on the matrix
- name: Install dependencies
run: go mod tidy # Ensure dependencies are tidy
- name: Lint code
uses: golangci/[email protected]
with:
args: "--timeout=5m"
- name: Run unit tests
run: |
go test -v ./... | tee tests.log
continue-on-error: true # Continue to report coverage even if tests fail
- name: Generate Coverage Report
run: |
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
continue-on-error: false # Fail the job if coverage generation fails
- name: Upload Coverage Report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage.out
- name: Upload Test Results
uses: actions/upload-artifact@v3
with:
name: test-results
path: tests.log