Skip to content

Removed Colours

Removed Colours #24

Workflow file for this run

name: Continuous Integration
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
GO_VERSION: '1.21'
jobs:
lint:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
- name: Run golangci-lint
run: |
cd src
$(go env GOPATH)/bin/golangci-lint run --timeout=5m
- name: Check formatting
run: |
cd src
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "The following files need formatting:"
gofmt -s -l .
exit 1
fi
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Install gosec
run: go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest
- name: Run gosec
run: |
cd src
gosec -fmt json -out ../security-report.json ./...
- name: Upload security report
uses: actions/upload-artifact@v3
with:
name: security-report
path: security-report.json
test:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.20', '1.21']
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Download dependencies
run: |
cd src
go mod download
- name: Run tests
run: |
cd src
go test -race -coverprofile=coverage.out ./...
- name: Generate coverage report
run: |
cd src
go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report-go${{ matrix.go-version }}
path: src/coverage.html
integration-test:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Build EntityDB
run: |
cd src
make build
- name: Run integration tests
run: |
cd src
# Start server in background
./bin/entitydb &
SERVER_PID=$!
# Wait for server to start
sleep 5
# Run integration tests
make test-integration || true
# Cleanup
kill $SERVER_PID || true
build:
name: Build Check
runs-on: ubuntu-latest
needs: [lint, security, test]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Build binary
run: |
cd src
make build
- name: Test binary
run: |
cd src
./bin/entitydb --version
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: entitydb-binary
path: src/bin/entitydb
docker:
name: Docker Build
runs-on: ubuntu-latest
needs: [lint, security, test]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: false
tags: entitydb:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test Docker image
run: |
docker run --rm entitydb:${{ github.sha }} --version