Skip to content

*changing gh actions #1

*changing gh actions

*changing gh actions #1

Workflow file for this run

name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
GO_VERSION: '1.21'
CGO_ENABLED: '0'
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Verify dependencies
run: go mod verify
- name: Run tests
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
build:
name: Build
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashfiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build for multiple platforms
run: |
# Build for current platform
go build -o kalco .
# Build for other platforms
GOOS=linux GOARCH=amd64 go build -o kalco-linux-amd64 .
GOOS=linux GOARCH=arm64 go build -o kalco-linux-arm64 .
GOOS=darwin GOARCH=amd64 go build -o kalco-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build -o kalco-darwin-arm64 .
GOOS=windows GOARCH=amd64 go build -o kalco-windows-amd64.exe .
GOOS=windows GOARCH=arm64 go build -o kalco-windows-arm64.exe .
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: binaries
path: |
kalco
kalco-*
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=5m
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'