mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-02 18:19:07 +01:00
183 lines
5.5 KiB
YAML
183 lines
5.5 KiB
YAML
name: Build and Test
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- pulse/v6-release
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- pulse/v6-release
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
secret-scan:
|
|
name: Secret Scan
|
|
runs-on: ubuntu-24.04
|
|
env:
|
|
GITLEAKS_VERSION: "8.30.1"
|
|
GITLEAKS_LINUX_X64_SHA256: "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb"
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install gitleaks
|
|
run: |
|
|
set -euo pipefail
|
|
archive="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
|
|
url="https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${archive}"
|
|
curl -fsSLo "/tmp/${archive}" "$url"
|
|
echo "${GITLEAKS_LINUX_X64_SHA256} /tmp/${archive}" | sha256sum -c -
|
|
tar -xzf "/tmp/${archive}" -C /tmp gitleaks
|
|
install /tmp/gitleaks /usr/local/bin/gitleaks
|
|
|
|
- name: Run gitleaks
|
|
run: |
|
|
set -euo pipefail
|
|
gitleaks detect \
|
|
--source . \
|
|
--log-opts=-1 \
|
|
--no-banner \
|
|
--redact \
|
|
--exit-code 2 \
|
|
--report-format sarif \
|
|
--report-path results.sarif
|
|
|
|
build:
|
|
name: Frontend & Backend
|
|
runs-on: ubuntu-24.04
|
|
env:
|
|
FRONTEND_DIR: frontend-modern
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
with:
|
|
node-version: '20'
|
|
cache: npm
|
|
cache-dependency-path: frontend-modern/package-lock.json
|
|
|
|
- name: Install frontend dependencies
|
|
working-directory: frontend-modern
|
|
run: npm ci
|
|
|
|
- name: Lint frontend
|
|
working-directory: frontend-modern
|
|
run: npm run lint
|
|
|
|
- name: Audit header composition
|
|
working-directory: frontend-modern
|
|
run: npm run lint:headers
|
|
|
|
- name: Check frontend copy-paste duplication
|
|
working-directory: frontend-modern
|
|
run: npm run lint:cpd
|
|
|
|
- name: Frontend unit tests
|
|
working-directory: frontend-modern
|
|
run: npm run test
|
|
|
|
- name: Type-check frontend
|
|
working-directory: frontend-modern
|
|
run: npm run type-check
|
|
|
|
- name: Build frontend bundle (with embed copy)
|
|
run: make frontend
|
|
|
|
- name: Check frontend bundle size budget
|
|
working-directory: frontend-modern
|
|
run: npm run check:bundlesize
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: Script smoke tests
|
|
run: scripts/tests/run.sh
|
|
|
|
- name: Go unit tests
|
|
env:
|
|
PULSE_DATA_DIR: /tmp/pulse-test-data
|
|
# internal/api alone takes ~10m under -race on a fast machine; CI
|
|
# runners need the larger per-binary budget.
|
|
run: go test -race -timeout 25m ./...
|
|
|
|
- name: Go benchmarks
|
|
timeout-minutes: 20
|
|
env:
|
|
PULSE_DATA_DIR: /tmp/pulse-bench-data
|
|
run: |
|
|
set -o pipefail
|
|
go test -bench=. -benchmem -count=5 -run=^$ -benchtime=100ms -timeout=5m \
|
|
./pkg/metrics/ \
|
|
./pkg/auth/ \
|
|
./internal/api/ \
|
|
./internal/monitoring/ \
|
|
./internal/unifiedresources/ \
|
|
./internal/dockeragent/ \
|
|
./cmd/pulse-agent/ \
|
|
./internal/hostagent/ \
|
|
./internal/hostmetrics/ \
|
|
| tee bench-results.txt
|
|
|
|
- name: Upload benchmark results
|
|
if: always()
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: bench-results
|
|
path: bench-results.txt
|
|
retention-days: 7
|
|
|
|
- name: Install benchstat
|
|
run: go install golang.org/x/perf/cmd/benchstat@v0.0.0-20260211190930-8161c38c6cdc
|
|
|
|
- name: Save benchmark baseline (main branch)
|
|
if: github.ref == 'refs/heads/main'
|
|
run: cp bench-results.txt bench-baseline.txt
|
|
|
|
- name: Cache benchmark baseline (main branch)
|
|
if: github.ref == 'refs/heads/main'
|
|
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: bench-baseline.txt
|
|
key: go-bench-baseline-${{ github.sha }}
|
|
|
|
- name: Restore benchmark baseline (PRs)
|
|
if: github.event_name == 'pull_request'
|
|
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: bench-baseline.txt
|
|
key: go-bench-baseline-
|
|
restore-keys: go-bench-baseline-
|
|
|
|
- name: Compare benchmarks against baseline
|
|
if: github.event_name == 'pull_request'
|
|
run: |
|
|
set -eo pipefail
|
|
if [ ! -f bench-baseline.txt ]; then
|
|
echo "No benchmark baseline found (first PR against main?). Skipping comparison."
|
|
exit 0
|
|
fi
|
|
echo "=== Benchmark comparison (baseline vs current) ==="
|
|
benchstat bench-baseline.txt bench-results.txt | tee bench-comparison.txt
|
|
echo ""
|
|
bash scripts/check-bench-regression.sh bench-comparison.txt
|
|
|
|
- name: Build Pulse backend
|
|
run: go build ./cmd/pulse
|