-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (62 loc) · 2.7 KB
/
Copy pathdeploy.yml
File metadata and controls
72 lines (62 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# CI + CD: test → multi-arch build → deploy to Oracle Cloud E1 Micro on push to main.
#
# Flow:
# 1. Run `dune build` and `dune runtest` (matching correctness +
# perf regression guards). Gates the rest of the pipeline.
# 2. Build linux/amd64 + linux/arm64 in parallel on architecture-
# native GHA runners (ubuntu-24.04 + ubuntu-24.04-arm). Each
# arch pushes its image by digest only — no tag clutter.
# 3. Merge the two per-arch digests into a single multi-platform
# manifest list tagged :latest and :sha-<short> on GHCR.
# 4. SSH into the Oracle VM, pull the new image (Docker auto-picks
# the amd64 variant), restart the container.
# 5. Smoke-test the local endpoint inside the VM.
#
# Caddy in front handles WSS termination, so the brief restart shows
# up to a recruiter as a sub-second 502 — acceptable for a demo.
# For zero-downtime, see the comments at the bottom.
#
# Required secrets (Settings → Secrets and variables → Actions):
# SSH_HOST public IP or hostname of the VM
# SSH_USER usually "ubuntu" on Oracle's Ubuntu image
# SSH_PRIVATE_KEY the matching private key for the public key in ~ubuntu/.ssh/authorized_keys
#
# One-time setup after the first successful push:
# GitHub → your repo → Packages → ocaml_lob → Package settings → Change visibility → Public.
# This lets the VM `docker pull` without authenticating to GHCR.
name: Deploy
on:
push:
branches: [main]
workflow_dispatch: # manual trigger from the Actions UI
# Don't run two deploys at the same time — they'd race on the VM.
concurrency:
group: deploy-prod
cancel-in-progress: false
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
# OCaml-side CI. Catches type errors (`dune build`), matching-
# correctness regressions (`test_engine.ml`), and perf regressions
# (`perf_test.ml`'s bytes/order + throughput + p99 guards) before
# anything ships. ~3-5 min cache-warm; ~6-8 min on first run.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: '5.2'
opam-pin: false # skip pinning the package — saves ~30s
# Only install what test/ and bench/ actually need. dream + yojson
# + lwt_ppx are server-only and their dep trees are slow to compile
# on a clean opam switch; the Docker build catches server-side
# type errors anyway.
- name: Install test deps
run: opam install --yes alcotest
- name: Build (lib + tests + bench)
run: opam exec -- dune build lib/ test/
- name: Run tests
run: opam exec -- dune runtest --force