feat(ci,doctor,export): add Gitea CI/CD, verification scripts, doctor and export commands
This commit is contained in:
1 parent
d1475e7141
commit
db2cdc03ef
15 files changed
+1406
-168
No files matched your search
@@ -0,0 +1,17 @@
|
||||
name: Report a bug
|
||||
description: Something did not work as expected
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes: { label: "What happened?", description: "Steps to reproduce, expected behavior, and actual behavior." }
|
||||
validations: { required: true }
|
||||
- type: input
|
||||
id: system
|
||||
attributes: { label: "Operating system and Xexéu version", placeholder: "Ubuntu 24.04 / xexeu 0.1.0" }
|
||||
- type: input
|
||||
id: input
|
||||
attributes: { label: "Target or configuration", placeholder: "CIDR / target specification, xexeu.toml configuration snippet, or scan profile" }
|
||||
- type: textarea
|
||||
id: log
|
||||
attributes: { label: "Terminal output (xexeu doctor / scan / serve)", render: shell }
|
||||
@@ -0,0 +1,9 @@
|
||||
## What changes and why
|
||||
|
||||
## Checklist
|
||||
- [ ] `cargo fmt --all` and `cargo clippy --workspace --all-targets` pass without warnings
|
||||
- [ ] `cargo test --workspace` passes
|
||||
- [ ] Scan and detection changes carry deterministic evidence and preserve fixed-order output
|
||||
- [ ] Commits follow Conventional Commits in English and code/comments are in English
|
||||
- [ ] CHANGELOG updated (if there is a user-visible change)
|
||||
- [ ] Documentation kept in the English/Portuguese pair
|
||||
@@ -0,0 +1,75 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
# Documentation-only or local agent state changes do not trigger CI jobs.
|
||||
pull_request:
|
||||
paths-ignore: ['**.md', 'docs/**', 'LICENSE*', '.gitignore', '.githooks/**', '.wolf/**', '.claude/**', '.opencode/**', '.codex/**', '.cursor/**', '.superpowers/**', '.superset/**', '.gitea/ISSUE_TEMPLATE/**', 'scripts/release-notes.sh', '.gitea/workflows/release.yml']
|
||||
workflow_call:
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ gitea.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUSTFLAGS: -D warnings
|
||||
CARGO_HOME: /opt/hostedtoolcache/cargo
|
||||
RUSTUP_HOME: /opt/hostedtoolcache/rustup
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Format and clippy
|
||||
runs-on: linux-arm64
|
||||
env:
|
||||
CARGO_TARGET_DIR: /opt/hostedtoolcache/cargo-target/xexeu-lint
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: rustfmt, clippy
|
||||
- name: Workflows and templates (valid YAML)
|
||||
run: |
|
||||
python3 -c "
|
||||
import glob, yaml
|
||||
for f in glob.glob('.gitea/**/*.yml', recursive=True):
|
||||
yaml.safe_load(open(f))
|
||||
"
|
||||
- name: Docker compose config
|
||||
run: docker compose config --quiet
|
||||
- run: cargo fmt --all -- --check
|
||||
- run: cargo clippy --workspace --all-targets
|
||||
|
||||
test:
|
||||
name: Tests (Linux)
|
||||
runs-on: linux-arm64
|
||||
env:
|
||||
CARGO_TARGET_DIR: /opt/hostedtoolcache/cargo-target/xexeu-test
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- run: cargo test --workspace
|
||||
|
||||
audit:
|
||||
name: Dependency audit
|
||||
runs-on: linux-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: cargo audit
|
||||
run: |
|
||||
command -v cargo-audit >/dev/null || cargo install cargo-audit --locked
|
||||
cargo audit
|
||||
|
||||
image:
|
||||
name: Docker image (build and smoke test)
|
||||
if: ${{ gitea.event_name == 'pull_request' }}
|
||||
runs-on: linux-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- name: Build
|
||||
run: docker build -t "xexeu-ci:${{ gitea.run_id }}" .
|
||||
- name: Smoke test
|
||||
run: scripts/smoke-image.sh "xexeu-ci:${{ gitea.run_id }}"
|
||||
- name: Clean up
|
||||
if: always()
|
||||
run: docker rmi -f "xexeu-ci:${{ gitea.run_id }}" >/dev/null 2>&1 || true
|
||||
@@ -0,0 +1,180 @@
|
||||
name: Release
|
||||
|
||||
# Publishes the multi-arch Xexéu image (linux/amd64 + linux/arm64) to the Gitea
|
||||
# container registry. A merge into main publishes `edge`; a v* tag re-points the
|
||||
# image already built for the same inputs to X.Y.Z, X.Y and latest (no rebuild)
|
||||
# and creates the Gitea Release. Needs the secret REGISTRY_TOKEN (Gitea token
|
||||
# with write:package) visible to this repository.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['v*']
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: release-${{ gitea.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
REGISTRY: git.lucasrguerra.dev.br
|
||||
|
||||
jobs:
|
||||
# The image is built only from these paths, so their tree hashes identify it.
|
||||
# When inputs-<hash> already exists (docs-only merge, workflow change, or a tag
|
||||
# on a commit main already published), nothing is built or tested again.
|
||||
plan:
|
||||
name: Plan (reuse the published image?)
|
||||
runs-on: linux-arm64
|
||||
outputs:
|
||||
inputs: ${{ steps.plan.outputs.inputs }}
|
||||
reuse: ${{ steps.plan.outputs.reuse }}
|
||||
image: ${{ steps.plan.outputs.image }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- id: plan
|
||||
env:
|
||||
REPO: ${{ gitea.repository }}
|
||||
run: |
|
||||
inputs=$(git rev-parse HEAD:Dockerfile HEAD:.dockerignore HEAD:Cargo.toml HEAD:Cargo.lock \
|
||||
HEAD:crates HEAD:apps/gui/ui HEAD:logo.png | sha256sum | cut -c1-16)
|
||||
ns="${REPO,,}"
|
||||
token=$(curl -fsS "https://$REGISTRY/v2/token?service=container_registry&scope=repository:$ns:pull" | jq -r .token)
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' -I \
|
||||
-H "Authorization: Bearer $token" \
|
||||
-H 'Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json' \
|
||||
"https://$REGISTRY/v2/$ns/manifests/inputs-$inputs")
|
||||
echo "inputs-$inputs -> HTTP $code"
|
||||
reuse=false; [ "$code" = 200 ] && reuse=true
|
||||
echo "inputs=$inputs" >> "$GITHUB_OUTPUT"
|
||||
echo "reuse=$reuse" >> "$GITHUB_OUTPUT"
|
||||
echo "image=$REGISTRY/$ns" >> "$GITHUB_OUTPUT"
|
||||
|
||||
ci:
|
||||
needs: plan
|
||||
if: ${{ needs.plan.outputs.reuse != 'true' }}
|
||||
uses: ./.gitea/workflows/ci.yml
|
||||
|
||||
# Each architecture is built on a native runner (no QEMU) and pushed under a
|
||||
# per-architecture tag; publish joins them into one manifest list.
|
||||
build:
|
||||
name: Build image (${{ matrix.arch }})
|
||||
needs: [plan, ci]
|
||||
if: ${{ needs.plan.outputs.reuse != 'true' }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { arch: amd64, platform: linux/amd64, runner: linux-amd64 }
|
||||
- { arch: arm64, platform: linux/arm64, runner: linux-arm64 }
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: docker/setup-buildx-action@v4
|
||||
- uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
# Plain `docker buildx build` instead of docker/build-push-action: that
|
||||
# action's upstream repo (~260MB of git history) reliably hangs the
|
||||
# act runner's Go-based clone on the Hostinger host, even when curl/git
|
||||
# to github.com are both fast. Same end result, no action to clone.
|
||||
- name: Build and push (per architecture)
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform "${{ matrix.platform }}" \
|
||||
--push \
|
||||
-t "${{ needs.plan.outputs.image }}:build-${{ gitea.sha }}-${{ matrix.arch }}" \
|
||||
--cache-from "type=registry,ref=${{ needs.plan.outputs.image }}:buildcache-${{ matrix.arch }}" \
|
||||
--cache-to "type=registry,ref=${{ needs.plan.outputs.image }}:buildcache-${{ matrix.arch }},mode=max" \
|
||||
.
|
||||
# Runs the image that was just pushed, on its own architecture.
|
||||
- name: Smoke test
|
||||
run: scripts/smoke-image.sh "${{ needs.plan.outputs.image }}:build-${{ gitea.sha }}-${{ matrix.arch }}"
|
||||
|
||||
publish:
|
||||
name: Publish tags
|
||||
needs: [plan, build]
|
||||
# build is skipped, not successful, when the image is reused.
|
||||
if: ${{ !cancelled() && needs.plan.result == 'success' && (needs.build.result == 'success' || needs.plan.outputs.reuse == 'true') }}
|
||||
runs-on: linux-arm64
|
||||
steps:
|
||||
- uses: docker/setup-buildx-action@v4
|
||||
- uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
- name: Tags
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: ${{ needs.plan.outputs.image }}
|
||||
flavor: latest=false
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest,enable=${{ startsWith(gitea.ref, 'refs/tags/v') && !contains(gitea.ref_name, '-') }}
|
||||
type=raw,value=edge,enable=${{ gitea.ref == 'refs/heads/main' }}
|
||||
type=sha,format=long
|
||||
- name: Apply tags
|
||||
run: |
|
||||
image='${{ needs.plan.outputs.image }}'
|
||||
tags=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< '${{ steps.meta.outputs.json }}')
|
||||
inputs='${{ needs.plan.outputs.inputs }}'
|
||||
if [ '${{ needs.plan.outputs.reuse }}' = true ]; then
|
||||
docker buildx imagetools create $tags "$image:inputs-$inputs"
|
||||
else
|
||||
docker buildx imagetools create $tags -t "$image:inputs-$inputs" \
|
||||
"$image:build-${{ gitea.sha }}-amd64" "$image:build-${{ gitea.sha }}-arm64"
|
||||
fi
|
||||
- name: Check architectures
|
||||
run: |
|
||||
docker buildx imagetools inspect "${{ needs.plan.outputs.image }}:inputs-${{ needs.plan.outputs.inputs }}" \
|
||||
--format '{{json .Manifest}}' \
|
||||
| jq -r '.manifests[] | select(.platform.os == "linux") | "\(.platform.os)/\(.platform.architecture)"' \
|
||||
| tee platforms.txt
|
||||
grep -qx linux/amd64 platforms.txt && grep -qx linux/arm64 platforms.txt
|
||||
- name: Summary
|
||||
run: |
|
||||
{ echo "### Xexéu image published (linux/amd64, linux/arm64)"; echo; echo '```'
|
||||
echo "${{ steps.meta.outputs.tags }}"; echo '```'; } >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
gitea-release:
|
||||
name: Gitea release
|
||||
needs: [plan, publish]
|
||||
if: ${{ !cancelled() && needs.publish.result == 'success' && startsWith(gitea.ref, 'refs/tags/v') }}
|
||||
runs-on: linux-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Build release CLI binary
|
||||
run: |
|
||||
cargo build --release --locked -p xexeu-cli
|
||||
- name: Release
|
||||
env:
|
||||
TAG: ${{ gitea.ref_name }}
|
||||
TOKEN: ${{ gitea.token }}
|
||||
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
|
||||
IMAGE: ${{ needs.plan.outputs.image }}
|
||||
run: |
|
||||
if curl -fsS -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG" >/dev/null 2>&1; then
|
||||
echo "release $TAG already exists"; exit 0
|
||||
fi
|
||||
{ scripts/release-notes.sh "$TAG"; echo; echo '```bash'; echo "docker pull $IMAGE:${TAG#v}"; echo '```'; } > notes.md
|
||||
pre=false; case "$TAG" in *-*) pre=true ;; esac
|
||||
jq -n --arg tag "$TAG" --arg name "Xexéu ${TAG#v}" --rawfile body notes.md --argjson pre "$pre" \
|
||||
'{tag_name:$tag, name:$name, body:$body, prerelease:$pre}' > release.json
|
||||
rel=$(curl -fsS -X POST "$API/releases" -H "Authorization: token $TOKEN" \
|
||||
-H 'Content-Type: application/json' -d @release.json)
|
||||
rel_id=$(echo "$rel" | jq -r .id)
|
||||
if [ -n "$rel_id" ] && [ "$rel_id" != "null" ]; then
|
||||
asset_name="xexeu-${TAG#v}-linux-arm64"
|
||||
cp target/release/xexeu "$asset_name"
|
||||
curl -fsS -X POST "$API/releases/$rel_id/assets?name=$asset_name" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"$asset_name" >/dev/null || true
|
||||
fi
|
||||
Reference in new issue
Block a user