updating github runners #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: | |
push: | |
branches: ["*"] | |
pull_request: | |
branches: ["*"] | |
jobs: | |
test-backend: | |
name: Test Go Backend | |
runs-on: [self-hosted, home] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21' | |
cache: true | |
- name: Install dependencies | |
run: go mod download | |
- name: Run tests | |
run: go test -v -race -coverprofile=coverage.out ./... | |
- name: Generate coverage report | |
run: go tool cover -html=coverage.out -o coverage.html | |
- name: Upload coverage reports | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: | | |
coverage.out | |
coverage.html | |
- name: Build simulator binary | |
run: | | |
CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o bin/simulator ./cmd/simulator | |
CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o bin/test-charger ./cmd/test-charger | |
- name: Upload backend artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: backend-binaries | |
path: bin/ | |
test-frontend: | |
name: Test Frontend | |
runs-on: [self-hosted, home] | |
defaults: | |
run: | |
working-directory: ./frontend | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '24' | |
cache: 'npm' | |
cache-dependency-path: './frontend/package-lock.json' | |
- name: Install dependencies | |
run: npm ci | |
- name: Run linter | |
run: npm run lint | |
- name: Build frontend | |
run: npm run build | |
- name: Upload frontend build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: frontend-build | |
path: frontend/.next/ | |
integration-test: | |
name: Integration Tests | |
runs-on: [self-hosted, home] | |
needs: [test-backend, test-frontend] | |
services: | |
docker: | |
image: docker:24-dind | |
options: --privileged | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21' | |
- name: Build Docker image for testing | |
run: | | |
docker build -f deployments/Dockerfile -t ocpp-simulator:test . | |
- name: Run integration tests | |
run: | | |
# Start the service in background | |
docker run -d --name simulator-test -p 8080:8080 ocpp-simulator:test | |
sleep 10 | |
# Run integration tests | |
go test -v ./tests/... | |
# Cleanup | |
docker stop simulator-test | |
docker rm simulator-test |