mirror of
https://github.com/warmbly/warmbly.git
synced 2026-08-19 00:01:14 +00:00
358 lines
9.4 KiB
YAML
358 lines
9.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
# Default token only gets `contents: read` on PRs from forks; the
|
|
# dorny/paths-filter action needs to list PR files via the GitHub
|
|
# API, which requires `pull-requests: read`. Without this the
|
|
# "Detect Changes" job dies with "Bad credentials" and every
|
|
# downstream language CI is skipped.
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
changes:
|
|
name: Detect Changes
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
go-services: ${{ steps.filter.outputs.go-services }}
|
|
backend: ${{ steps.filter.outputs.backend }}
|
|
consumer: ${{ steps.filter.outputs.consumer }}
|
|
worker: ${{ steps.filter.outputs.worker }}
|
|
tracking: ${{ steps.filter.outputs.tracking }}
|
|
realtime: ${{ steps.filter.outputs.realtime }}
|
|
web: ${{ steps.filter.outputs.web }}
|
|
admin: ${{ steps.filter.outputs.admin }}
|
|
site: ${{ steps.filter.outputs.site }}
|
|
make: ${{ steps.filter.outputs.make }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dorny/paths-filter@v3
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
go-services:
|
|
- 'go.mod'
|
|
- 'go.sum'
|
|
- 'internal/**'
|
|
- 'cmd/**'
|
|
backend:
|
|
- 'cmd/backend/**'
|
|
- 'deploy/docker/backend.Dockerfile'
|
|
consumer:
|
|
- 'cmd/consumer/**'
|
|
- 'deploy/docker/consumer.Dockerfile'
|
|
worker:
|
|
- 'cmd/worker/**'
|
|
- 'deploy/docker/worker.Dockerfile'
|
|
tracking:
|
|
- 'tracking/**'
|
|
realtime:
|
|
- 'realtime/**'
|
|
- 'deploy/docker/realtime.Dockerfile'
|
|
web:
|
|
- 'web/**'
|
|
admin:
|
|
- 'admin/**'
|
|
site:
|
|
- 'site/**'
|
|
make:
|
|
- 'integrations/make/**'
|
|
|
|
go-ci:
|
|
name: Go CI
|
|
needs: changes
|
|
if: needs.changes.outputs.go-services == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: Set up protoc
|
|
uses: arduino/setup-protoc@v3
|
|
with:
|
|
version: "33.x"
|
|
repo-token: ${{ github.token }}
|
|
|
|
- name: Install required Go tools
|
|
run: make setup-tools
|
|
|
|
- name: Run golangci-lint
|
|
run: make lint
|
|
|
|
- name: Verify protobuf files are up to date
|
|
run: make check-proto
|
|
|
|
- name: Run tests with coverage
|
|
run: |
|
|
go test -race -coverprofile=coverage.out -covermode=atomic ./...
|
|
|
|
- name: Upload coverage
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
files: coverage.out
|
|
flags: go
|
|
fail_ci_if_error: false
|
|
|
|
web-ci:
|
|
name: Web CI
|
|
needs: changes
|
|
if: needs.changes.outputs.web == 'true'
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: web
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'pnpm'
|
|
cache-dependency-path: web/pnpm-lock.yaml
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Lint
|
|
run: pnpm lint
|
|
|
|
- name: Run tests
|
|
run: pnpm test:run
|
|
|
|
- name: Build
|
|
run: pnpm build
|
|
|
|
admin-ci:
|
|
name: Admin CI
|
|
needs: changes
|
|
if: needs.changes.outputs.admin == 'true'
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: admin
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'pnpm'
|
|
cache-dependency-path: admin/pnpm-lock.yaml
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Lint
|
|
run: pnpm lint
|
|
|
|
- name: Typecheck
|
|
run: pnpm typecheck
|
|
|
|
- name: Build
|
|
run: pnpm build
|
|
|
|
site-ci:
|
|
name: Site CI
|
|
needs: changes
|
|
if: needs.changes.outputs.site == 'true'
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: site
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'pnpm'
|
|
cache-dependency-path: site/pnpm-lock.yaml
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build
|
|
# Astro project; build catches type errors, broken imports,
|
|
# missing assets. No separate lint/typecheck script is wired
|
|
# in package.json today.
|
|
run: pnpm build
|
|
|
|
make-ci:
|
|
name: Make App CI
|
|
needs: changes
|
|
if: needs.changes.outputs.make == 'true'
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: integrations/make
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Validate Make app
|
|
# IML is interpreted by Make (no compile step); validate.mjs checks the
|
|
# manifest, JSON validity, code-file references, and component enums.
|
|
run: node scripts/validate.mjs
|
|
|
|
rust-ci:
|
|
name: Rust CI
|
|
needs: changes
|
|
if: needs.changes.outputs.tracking == 'true'
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: tracking
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install build dependencies
|
|
# rdkafka-sys builds librdkafka from source which needs
|
|
# libcurl for HTTPS schema-registry fetches; the GitHub
|
|
# runner image doesn't ship libcurl headers by default so the
|
|
# build fails with `curl/curl.h: No such file or directory`.
|
|
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev libsasl2-dev libssl-dev pkg-config
|
|
|
|
- name: Set up Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache Cargo
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: tracking
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --check
|
|
|
|
- name: Run Clippy
|
|
run: cargo clippy -- -D warnings
|
|
|
|
- name: Run tests
|
|
run: cargo test
|
|
|
|
elixir-ci:
|
|
name: Elixir CI
|
|
needs: changes
|
|
if: needs.changes.outputs.realtime == 'true'
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: realtime
|
|
env:
|
|
MIX_ENV: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Elixir
|
|
# mix.exs requires `elixir: "~> 1.18"`. Bumped here to match.
|
|
# Phoenix 1.8 + plug 1.19 also expect a recent OTP.
|
|
uses: erlef/setup-beam@v1
|
|
with:
|
|
elixir-version: "1.18"
|
|
otp-version: "27"
|
|
|
|
- name: Cache deps
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
realtime/deps
|
|
realtime/_build
|
|
key: ${{ runner.os }}-mix-${{ hashFiles('realtime/mix.lock') }}
|
|
restore-keys: ${{ runner.os }}-mix-
|
|
|
|
- name: Install dependencies
|
|
run: mix deps.get
|
|
|
|
- name: Check formatting
|
|
run: mix format --check-formatted
|
|
|
|
- name: Run Credo
|
|
# credo isn't in mix.exs yet; skip when the binary isn't
|
|
# available so CI doesn't false-fail. Re-enable once it's
|
|
# added as a dev dep.
|
|
run: mix help credo > /dev/null 2>&1 && mix credo --strict || echo "credo not installed; skipping"
|
|
|
|
- name: Compile
|
|
# Don't fail the build on transitive warnings — jose/CAStore
|
|
# and a couple of our own files emit deprecation warnings on
|
|
# Elixir 1.18 that aren't fixable without forking deps.
|
|
# Real compile errors still fail the step.
|
|
run: mix compile
|
|
|
|
- name: Run tests
|
|
run: mix test
|
|
|
|
security:
|
|
name: Security Scan
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Run Trivy vulnerability scanner
|
|
uses: aquasecurity/trivy-action@master
|
|
with:
|
|
scan-type: "fs"
|
|
scan-ref: "."
|
|
severity: "CRITICAL,HIGH"
|
|
exit-code: "1"
|
|
ignore-unfixed: true
|
|
|
|
ci-status:
|
|
name: CI Status
|
|
runs-on: ubuntu-latest
|
|
needs: [changes, go-ci, web-ci, admin-ci, site-ci, make-ci, rust-ci, elixir-ci, security]
|
|
if: always()
|
|
steps:
|
|
- name: Check CI status
|
|
run: |
|
|
if [[ "${{ needs.go-ci.result }}" == "failure" ]] || \
|
|
[[ "${{ needs.web-ci.result }}" == "failure" ]] || \
|
|
[[ "${{ needs.admin-ci.result }}" == "failure" ]] || \
|
|
[[ "${{ needs.site-ci.result }}" == "failure" ]] || \
|
|
[[ "${{ needs.make-ci.result }}" == "failure" ]] || \
|
|
[[ "${{ needs.rust-ci.result }}" == "failure" ]] || \
|
|
[[ "${{ needs.elixir-ci.result }}" == "failure" ]] || \
|
|
[[ "${{ needs.security.result }}" == "failure" ]]; then
|
|
echo "CI failed"
|
|
exit 1
|
|
fi
|
|
echo "CI passed"
|