Slice 12: project management API and the vgl CLI

2977adf · gmorell · 2026-12-02 04:21

57 files +6413 -66
Message
{commit_body(@commit)}

Files changed

modified .dockerignore
+4 −0
@@ -34,3 +34,7 @@ cover/
34 34 .git/
35 35 .gitignore
36 36 .forgejo/
37 +
38 +# The vgl CLI (cli/Dockerfile builds it from source).
39 +cli/target/
40 +cli-dist/
modified .forgejo/workflows/audit.yml
+2 −1
@@ -1,6 +1,7 @@
1 1 name: audit
2 2 # Known vulnerabilities in what Vigil is built from: every lockfile in
3 −# the repository (mix.lock and the NIF crates' native/*/Cargo.lock)
3 +# the repository (mix.lock, the NIF crates' native/*/Cargo.lock and the
4 +# vgl CLI's cli/Cargo.lock)
4 5 # checked against the OSV database (https://osv.dev), which carries the
5 6 # Hex advisories and RustSec's (what `cargo audit` reads) both, so one
6 7 # scanner covers both ecosystems, as the sibling apps do (cartosnap,
modified .forgejo/workflows/checks.yml
+20 −3
@@ -2,7 +2,8 @@ name: checks
2 2 # A pull request's build and tests, as the sibling apps run them
3 3 # (cartosnap, gitgud):
4 4 #
5 −# rust — rustfmt and clippy (-D warnings) over each NIF crate in native/
5 +# rust — rustfmt and clippy (-D warnings) over each NIF crate in native/,
6 +# and rustfmt, clippy and the tests of the vgl CLI in cli/
6 7 # test — `mix precommit` (compile --warnings-as-errors, deps.unlock
7 8 # --unused, format, test) against a throwaway Postgres 17, the NIFs
8 9 # built from source by Rustler on the way, then a check that
@@ -37,7 +38,7 @@ jobs:
37 38 - name: Build dependencies
38 39 run: |
39 40 sudo apt-get update -q
40 − sudo apt-get install -y -q --no-install-recommends build-essential
41 + sudo apt-get install -y -q --no-install-recommends build-essential cmake
41 42
42 43 # The same toolchain as the Dockerfile (RUST_VERSION); move them together.
43 44 - name: Rust
@@ -63,6 +64,16 @@ jobs:
63 64 echo "::endgroup::"
64 65 done
65 66
67 + # The vgl CLI: the same three checks cli/Dockerfile runs before it
68 + # packages anything.
69 + - name: CLI (rustfmt, clippy, test)
70 + working-directory: cli
71 + run: |
72 + set -eu
73 + cargo fmt --check
74 + cargo clippy --all-targets --locked -- -D warnings
75 + cargo test --locked
76 +
66 77 test:
67 78 runs-on: self-hosted
68 79 services:
@@ -92,7 +103,7 @@ jobs:
92 103 - name: Build dependencies
93 104 run: |
94 105 sudo apt-get update -q
95 − sudo apt-get install -y -q --no-install-recommends build-essential git
106 + sudo apt-get install -y -q --no-install-recommends build-essential cmake git
96 107
97 108 # The same toolchain the Dockerfile builds with.
98 109 # OTP and Elixir from builds.hex.pm, the builds setup-beam would
@@ -125,6 +136,12 @@ jobs:
125 136 mix local.rebar --force
126 137 mix deps.get
127 138
139 + # The vgl CLI, so test/vigil_web/vgl_cli_test.exs drives the real
140 + # binary against the server rather than skipping.
141 + - name: Build the vgl CLI
142 + working-directory: cli
143 + run: cargo build --locked
144 +
128 145 # The `test` alias inside it creates and migrates the database first.
129 146 - name: Precommit
130 147 run: mix precommit
added .forgejo/workflows/cli.yml
+139 −0
@@ -0,0 +1,139 @@
1 +# The vgl CLI, packaged as .deb and .rpm (cli/Dockerfile) and published to
2 +# the forge's own apt and rpm repositories on every push to main, as
3 +# gitgud's `gg` is (its build.yml `cli` job).
4 +#
5 +# cli/Dockerfile builds the crate twice, once per packaging family, since
6 +# a Rust binary is linked against the glibc of whatever compiled it, and
7 +# runs the CLI's fmt/clippy/test gate before packaging anything.
8 +#
9 +# No secrets: the per-job token is authorized to publish to this
10 +# repository's own package registries (and to write the build cache).
11 +name: cli
12 +on:
13 + push:
14 + branches: [main]
15 + paths:
16 + - "cli/**"
17 + - "LICENSE"
18 + - ".forgejo/workflows/cli.yml"
19 + workflow_dispatch:
20 +
21 +concurrency:
22 + group: ${{ github.workflow }}-${{ github.ref }}
23 + cancel-in-progress: false
24 +
25 +jobs:
26 + packages:
27 + runs-on: self-hosted
28 + steps:
29 + - uses: actions/checkout@v4
30 +
31 + - uses: docker/setup-buildx-action@v3
32 +
33 + # --cache-to writes to the registry, with the same per-job token the
34 + # image workflow pushes with.
35 + - uses: docker/login-action@v3
36 + with:
37 + registry: ${{ vars.CI_REGISTRY }}
38 + username: ci
39 + password: ${{ github.token }}
40 +
41 + - name: Resolve the forge URL
42 + env:
43 + CI_FORGE_URL: ${{ vars.CI_FORGE_URL }}
44 + run: |
45 + set -euo pipefail
46 + forge_url=${CI_FORGE_URL:-${GITHUB_SERVER_URL:-}}
47 + if [ -z "$forge_url" ]; then
48 + echo "No forge URL available (set CI_FORGE_URL)." >&2
49 + exit 1
50 + fi
51 + echo "FORGE_URL=$forge_url" >> "$GITHUB_ENV"
52 +
53 + - name: Build the .deb and .rpm
54 + env:
55 + COMMIT: ${{ github.sha }}
56 + SUITES: trixie forky
57 + run: |
58 + set -euo pipefail
59 +
60 + # The commit's date, not the clock: the same commit builds the
61 + # same version, and the .deb and .rpm of one run agree.
62 + commit_date=$(git show -s --format=%cd --date=format:%Y%m%d%H%M%S "$COMMIT" 2>/dev/null \
63 + || date -u +%Y%m%d%H%M%S)
64 + epoch=$(git show -s --format=%ct "$COMMIT" 2>/dev/null || date -u +%s)
65 + short=$(echo "$COMMIT" | cut -c1-12)
66 + version=$(sed -n 's/^version = "\(.*\)"/\1/p' cli/Cargo.toml | head -1)
67 + host=${FORGE_URL#*://}
68 +
69 + docker buildx build \
70 + --target packages \
71 + --build-arg PKG_VERSION="${version}~ci${commit_date}.g${short}" \
72 + --build-arg RPM_RELEASE="0.ci${commit_date}.g${short}" \
73 + --build-arg MAINTAINER="Vigil CI <noreply@${host%%/*}>" \
74 + --build-arg SOURCE_DATE_EPOCH="$epoch" \
75 + --build-arg SUITES="$SUITES" \
76 + --cache-from type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:cli-buildcache \
77 + --cache-to type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:cli-buildcache,mode=max,ignore-error=true \
78 + --output type=local,dest=./cli-dist \
79 + --file cli/Dockerfile .
80 +
81 + ls -l cli-dist
82 +
83 + - name: Publish to the apt repository
84 + env:
85 + REPOSITORY: ${{ github.repository }}
86 + TOKEN: ${{ github.token }}
87 + SUITES: trixie forky
88 + run: |
89 + set -euo pipefail
90 + for suite in $SUITES; do
91 + package=$(echo cli-dist/vgl_*+"${suite}"_*.deb)
92 + echo "publishing $package to $suite"
93 + curl --fail-with-body -sS \
94 + -u "ci:$TOKEN" \
95 + -H "Content-Type: application/vnd.debian.binary-package" \
96 + --data-binary "@$package" \
97 + "$FORGE_URL/pkg/deb/$REPOSITORY/upload?dist=$suite&component=main"
98 + echo
99 + done
100 +
101 + # One rpm repository, no suites: the package's EVR orders it.
102 + - name: Publish to the rpm repository
103 + env:
104 + REPOSITORY: ${{ github.repository }}
105 + TOKEN: ${{ github.token }}
106 + run: |
107 + set -euo pipefail
108 + for package in cli-dist/vgl-*.rpm; do
109 + echo "publishing $package"
110 + curl --fail-with-body -sS \
111 + -u "ci:$TOKEN" \
112 + -H "Content-Type: application/octet-stream" \
113 + --data-binary "@$package" \
114 + "$FORGE_URL/pkg/rpm/$REPOSITORY/upload"
115 + echo
116 + done
117 +
118 + - name: How to install it
119 + env:
120 + REPOSITORY: ${{ github.repository }}
121 + OWNER: ${{ github.repository_owner }}
122 + run: |
123 + cat <<EOF
124 + # Debian / Ubuntu: \$(lsb_release -cs) is trixie or forky
125 + curl -fsSL $FORGE_URL/pkg/_keys/deb/$OWNER | sudo tee /etc/apt/keyrings/$OWNER.asc >/dev/null
126 + echo "deb [signed-by=/etc/apt/keyrings/$OWNER.asc] $FORGE_URL/pkg/deb/$REPOSITORY \$(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/vigil.list
127 + sudo apt update && sudo apt install vgl
128 +
129 + # Fedora / RHEL / openSUSE: /etc/yum.repos.d/$OWNER.repo
130 + [$OWNER]
131 + name=$OWNER
132 + baseurl=$FORGE_URL/pkg/rpm/$REPOSITORY
133 + enabled=1
134 + repo_gpgcheck=1
135 + gpgcheck=0
136 + gpgkey=$FORGE_URL/pkg/_keys/rpm/$OWNER
137 +
138 + sudo dnf install vgl
139 + EOF
modified .gitignore
+4 −0
@@ -45,3 +45,7 @@ npm-debug.log
45 45
46 46 # Uploaded files in development (Vigil.Storage.Local)
47 47 /storage/
48 +
49 +# The vgl CLI: its build output, and the packages cli/Dockerfile exports.
50 +/cli/target/
51 +/cli-dist/
modified ROADMAP.md
+3 −0

Click to load diff…

added cli/Cargo.lock
+2149 −0

Click to load diff…

added cli/Cargo.toml
+62 −0

Click to load diff…

added cli/Dockerfile
+147 −0

Click to load diff…

added cli/README.md
+94 −0

Click to load diff…

added cli/src/api/mod.rs
+520 −0

Click to load diff…

added cli/src/api/models.rs
+147 −0

Click to load diff…

added cli/src/cli.rs
+306 −0

Click to load diff…

added cli/src/commands/auth.rs
+176 −0

Click to load diff…

added cli/src/commands/issue.rs
+130 −0

Click to load diff…

added cli/src/commands/key.rs
+119 −0

Click to load diff…

added cli/src/commands/mod.rs
+72 −0

Click to load diff…

added cli/src/commands/org.rs
+52 −0

Click to load diff…

added cli/src/commands/project.rs
+177 −0

Click to load diff…

added cli/src/commands/release.rs
+144 −0

Click to load diff…

added cli/src/config.rs
+277 −0

Click to load diff…

added cli/src/main.rs
+81 −0

Click to load diff…

added cli/src/output.rs
+259 −0

Click to load diff…

modified lib/vigil/organizations.ex
+7 −0

Click to load diff…

modified lib/vigil/organizations/team.ex
+1 −1

Click to load diff…

modified lib/vigil/projects.ex
+25 −0

Click to load diff…

modified lib/vigil/projects/project.ex
+1 −1

Click to load diff…

modified lib/vigil_web/api/auth.ex
+14 −0

Click to load diff…

added lib/vigil_web/api/pagination.ex
+57 −0

Click to load diff…

added lib/vigil_web/api/v0/issue_controller.ex
+122 −0

Click to load diff…

modified lib/vigil_web/api/v0/organization_controller.ex
+5 −14

Click to load diff…

added lib/vigil_web/api/v0/project_controller.ex
+111 −0

Click to load diff…

added lib/vigil_web/api/v0/project_json.ex
+143 −0

Click to load diff…

added lib/vigil_web/api/v0/project_key_controller.ex
+86 −0

Click to load diff…

modified lib/vigil_web/api/v0/release_controller.ex
+4 −46

Click to load diff…

added lib/vigil_web/api/v0/team_controller.ex
+50 −0

Click to load diff…

added lib/vigil_web/api/v0/uptime_controller.ex
+47 −0

Click to load diff…

modified lib/vigil_web/router.ex
+16 −0

Click to load diff…

added test/vigil_web/api/project_api_test.exs
+362 −0

Click to load diff…

added test/vigil_web/sentry_cli_projects_test.exs
+98 −0

Click to load diff…

added test/vigil_web/vgl_cli_test.exs
+180 −0

Click to load diff…

Parents: a7fc868