ci(release): automate tag-driven publishing #41
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: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| checks: | |
| name: format, credo, unit tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: '1.19.0' | |
| otp-version: '27.3' | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Mix | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| deps | |
| _build | |
| key: ${{ runner.os }}-mix-${{ hashFiles('mix.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix- | |
| - name: Cache Cargo | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/bin | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('mix.lock', 'native/moqx_native/Cargo.lock', '.moq-dev/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Run fast checks | |
| run: mix ci | |
| relay-integration: | |
| # The moqtail relay needs TLS cert/key files produced by | |
| # scripts/generate_integration_certs.sh. GitHub Actions `services:` | |
| # containers start before `actions/checkout` runs, so they cannot mount | |
| # repo-generated files — hence we start the relay manually as a step | |
| # after checkout + cert generation. See also: host networking is used | |
| # to side-step UDP/QUIC port-mapping quirks on the runner. | |
| name: relay-backed integration tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: '1.19.0' | |
| otp-version: '27.3' | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Mix | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| deps | |
| _build | |
| key: ${{ runner.os }}-mix-${{ hashFiles('mix.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix- | |
| - name: Cache Cargo | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/bin | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('mix.lock', 'native/moqx_native/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install Elixir dependencies | |
| run: mix deps.get | |
| - name: Generate integration relay certificates | |
| run: scripts/generate_integration_certs.sh .tmp/integration-certs | |
| - name: Start pinned relay image | |
| env: | |
| MOQX_RELAY_IMAGE: ghcr.io/moqtail/relay:sha-190e502@sha256:36c929b71140a83158da383721f1d59f199a9f643ab5d033910258f5aa2903ee | |
| run: | | |
| docker run -d --name moqx-relay --network host \ | |
| -v "$PWD/.tmp/integration-certs/cert.pem:/certs/cert.pem:ro" \ | |
| -v "$PWD/.tmp/integration-certs/key.pem:/certs/key.pem:ro" \ | |
| "$MOQX_RELAY_IMAGE" \ | |
| --host 0.0.0.0 --port 4433 --cert-file /certs/cert.pem --key-file /certs/key.pem | |
| - name: Wait for relay to be ready | |
| run: | | |
| for i in $(seq 1 30); do | |
| if ! docker ps --filter name=moqx-relay --filter status=running \ | |
| --format '{{.Names}}' | grep -q '^moqx-relay$'; then | |
| echo "relay container is not running" | |
| docker logs moqx-relay || true | |
| exit 1 | |
| fi | |
| if docker logs moqx-relay 2>&1 | grep -qF 'is running at'; then | |
| echo "relay ready after ${i}s" | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| echo "relay did not report readiness within 30s; last logs:" | |
| docker logs moqx-relay || true | |
| exit 1 | |
| - name: Run relay-backed integration tests | |
| env: | |
| MOQX_EXTERNAL_RELAY_URL: https://127.0.0.1:4433 | |
| MOQX_RELAY_CACERTFILE: .tmp/integration-certs/ca.pem | |
| run: mix test.integration | |
| - name: Dump relay logs on failure | |
| if: failure() | |
| run: docker logs moqx-relay || true | |
| - name: Stop relay image | |
| if: always() | |
| run: docker rm -f moqx-relay || true |