From 4fd75701c79a820dea5009ffd6f75d396983d236 Mon Sep 17 00:00:00 2001 From: CleverWild Date: Tue, 23 Jun 2026 20:41:41 +0200 Subject: [PATCH] ci(clippy): add auto-fix bot pipeline --- .woodpecker/server-clippy-fix.yaml | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .woodpecker/server-clippy-fix.yaml diff --git a/.woodpecker/server-clippy-fix.yaml b/.woodpecker/server-clippy-fix.yaml new file mode 100644 index 0000000..4793343 --- /dev/null +++ b/.woodpecker/server-clippy-fix.yaml @@ -0,0 +1,45 @@ +when: + - event: push + branch: main + path: + include: ['.woodpecker/server-*.yaml', 'server/**'] + +steps: + - name: clippy-fix + image: jdxcode/mise:latest + directory: server + environment: + CARGO_TERM_COLOR: always + CARGO_TARGET_DIR: /usr/local/cargo/target + CARGO_HOME: /usr/local/cargo/registry + GITEA_TOKEN: + from_secret: GITEA_TOKEN + GITEA_URL: + from_secret: GITEA_URL + volumes: + - cargo-target:/usr/local/cargo/target + - cargo-registry:/usr/local/cargo/registry + commands: + - apt-get update && apt-get install -y pkg-config curl + - mise install rust + - mise install protoc + - mise exec rust -- cargo clippy --fix --allow-dirty --all + - | + cd .. + if git diff --quiet HEAD; then + echo "No machine-applicable clippy fixes found, nothing to do." + exit 0 + fi + git config user.email "bot@arbiter" + git config user.name "Clippy Bot" + git add -A + git commit -m "fix(clippy): apply auto-fixable linting suggestions" + git config http.extraHeader "Authorization: token ${GITEA_TOKEN}" + git push --force origin HEAD:refs/heads/bot/clippy-fixes + HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ + -X POST "${GITEA_URL}/api/v1/repos/${CI_REPO}/pulls" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{\"title\":\"fix(clippy): apply auto-fixable linting suggestions\",\"head\":\"bot/clippy-fixes\",\"base\":\"main\",\"body\":\"Automated clippy fixes generated by CI bot.\"}") + echo "Gitea API response: ${HTTP_STATUS}" + [ "$HTTP_STATUS" = "201" ] || [ "$HTTP_STATUS" = "409" ] || [ "$HTTP_STATUS" = "422" ] || exit 1