2.0 KiB · text History 6676b00
name: checks
# A pull request's build and tests: the forge compiled (NIFs included)
# and `mix test` against a throwaway Postgres. Every pull request — the
# security update PRs gg-security opens (dependency-updates.yml) most of
# all, since a bump that resolves isn't one that builds.
on:
  pull_request:
  workflow_dispatch:

permissions:
  contents: read

jobs:
  test:
    runs-on: self-hosted
    services:
      postgres:
        image: postgres:17
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        options: >-
          --health-cmd "pg_isready -U postgres"
          --health-interval 5s
          --health-timeout 5s
          --health-retries 20
    env:
      MIX_ENV: test
      GITGUD_TEST_DB_HOST: postgres
      GITGUD_TEST_DB_PORT: "5432"
    steps:
      - uses: actions/checkout@v4

      # As the Dockerfile's builder: what the NIFs need to compile.
      - name: Build dependencies
        run: |
          sudo apt-get update -q
          sudo apt-get install -y -q --no-install-recommends \
            build-essential git pkg-config libssl-dev libclang-dev

      # setup-beam picks its OTP build by ImageOS, which the runner sets to
      # "selfhosted"; given on the step itself, ours wins.
      - name: Say which Ubuntu this is, for setup-beam
        id: os
        run: echo "image_os=ubuntu$(. /etc/os-release && echo "${VERSION_ID%%.*}")" >> "$GITHUB_OUTPUT"

      - uses: erlef/setup-beam@v1
        env:
          ImageOS: ${{ steps.os.outputs.image_os }}
        with:
          otp-version: "28.5.0.2"
          elixir-version: "1.19.5"
          version-type: strict

      - name: Rust
        run: |
          curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.88.0
          echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"

      - name: Dependencies
        run: |
          mix local.hex --force
          mix local.rebar --force
          mix deps.get

      - name: Compile
        run: mix compile

      - name: Test
        run: mix test