CI: build and test every pull request

f72becf · Gabriel Morell · 2026-10-22 21:31

6 files +70 -3
Message
{commit_body(@commit)}

Files changed

added .forgejo/workflows/checks.yml
+65 −0
@@ -0,0 +1,65 @@
1 +name: checks
2 +# A pull request's build and tests: the forge compiled (NIFs included)
3 +# and `mix test` against a throwaway Postgres. Every pull request — the
4 +# security update PRs gg-security opens (dependency-updates.yml) most of
5 +# all, since a bump that resolves isn't one that builds.
6 +on:
7 + pull_request:
8 + workflow_dispatch:
9 +
10 +permissions:
11 + contents: read
12 +
13 +jobs:
14 + test:
15 + runs-on: self-hosted
16 + services:
17 + postgres:
18 + image: postgres:17
19 + env:
20 + POSTGRES_USER: postgres
21 + POSTGRES_PASSWORD: postgres
22 + options: >-
23 + --health-cmd "pg_isready -U postgres"
24 + --health-interval 5s
25 + --health-timeout 5s
26 + --health-retries 20
27 + env:
28 + MIX_ENV: test
29 + GITGUD_TEST_DB_HOST: postgres
30 + GITGUD_TEST_DB_PORT: "5432"
31 + steps:
32 + - uses: actions/checkout@v4
33 +
34 + # As the Dockerfile's builder: what the NIFs need to compile.
35 + - name: Build dependencies
36 + run: |
37 + sudo apt-get update -q
38 + sudo apt-get install -y -q --no-install-recommends \
39 + build-essential git pkg-config libssl-dev libclang-dev
40 +
41 + - name: Say which Ubuntu this is, for setup-beam
42 + run: echo "ImageOS=ubuntu$(. /etc/os-release && echo "${VERSION_ID%%.*}")" >> "$GITHUB_ENV"
43 +
44 + - uses: erlef/setup-beam@v1
45 + with:
46 + otp-version: "28.5.0.2"
47 + elixir-version: "1.19.5"
48 + version-type: strict
49 +
50 + - name: Rust
51 + run: |
52 + curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.88.0
53 + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
54 +
55 + - name: Dependencies
56 + run: |
57 + mix local.hex --force
58 + mix local.rebar --force
59 + mix deps.get
60 +
61 + - name: Compile
62 + run: mix compile
63 +
64 + - name: Test
65 + run: mix test
modified .forgejo/workflows/dependency-updates.yml
+1 −1
@@ -44,7 +44,7 @@ jobs:
44 44
45 45 - name: Rust
46 46 run: |
47 − curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
47 + curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.88.0
48 48 echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
49 49
50 50 # Pinned and checked, as in audit.yml; bump both together.
modified config/test.exs
+4 −2
@@ -11,11 +11,13 @@ config :bcrypt_elixir, :log_rounds, 1
11 11 config :git_gud, GitGud.Repo,
12 12 username: "postgres",
13 13 password: "postgres",
14 − hostname: "localhost",
14 + # A local database by default; CI points these at its service
15 + # container (.forgejo/workflows/checks.yml).
16 + hostname: System.get_env("GITGUD_TEST_DB_HOST", "localhost"),
15 17 database: "git_gud_test#{System.get_env("MIX_TEST_PARTITION")}",
16 18 pool: Ecto.Adapters.SQL.Sandbox,
17 19 pool_size: System.schedulers_online() * 2,
18 − port: 54328
20 + port: String.to_integer(System.get_env("GITGUD_TEST_DB_PORT", "54328"))
19 21
20 22 # We don't run a server during test. If one is required,
21 23 # you can enable the server option below.

Parents: 9c7f1f9