From: Christophe Lyon <[email protected]>
Add a sample workflow for Forgejo, as an example of integrated CI.
To keep it lightweight, we run only two small checks on each patch of
the series:
- contrib/check_GNU_style.py
which catches common mistakes (spaces vs tab, missing spaces, ...)
but has some false positive warnings.
- contrib/gcc-changelog/git_check_commit.py
which checks the commit message and ChangeLog entry
In order to run both checks even if the other fails, we use two steps
with 'continue-on-error: true', and we need a 'final-result'
consolidation step to generate the global status.
ChangeLog:
* .forgejo/workflows/sanity-checks.yaml: New file.
---
.forgejo/workflows/sanity-checks.yaml | 47 +++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 .forgejo/workflows/sanity-checks.yaml
diff --git a/.forgejo/workflows/sanity-checks.yaml b/.forgejo/workflows/sanity-checks.yaml
new file mode 100644
index 00000000000..21967e6f748
--- /dev/null
+++ b/.forgejo/workflows/sanity-checks.yaml
@@ -0,0 +1,47 @@
+on:
+ pull_request:
+ types: [opened, synchronize, reopened]
+
+jobs:
+ testjob:
+ runs-on: sourceware-runner
+ outputs:
+ styleoutput: ${{ steps.check_gnu_style.outputs.styleresult }}
+ verifyoutput: ${{ steps.gcc_verify.outputs.verifyresult }}
+ steps:
+ - name: install dependencies
+ run: |
+ echo "Installing node.js"
+ apt-get update
+ apt-get install -qq -y nodejs git python3 python3-git python3-termcolor python3-unidiff
+
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 100
+
+ - name: check GNU style
+ id: check_gnu_style
+ continue-on-error: true
+ run: |
+ echo "Running check_GNU_style.py"
+ git fetch origin ${FORGEJO_BASE_REF}:${FORGEJO_BASE_REF}
+ for sha in $(git rev-list ${FORGEJO_BASE_REF}..${FORGEJO_SHA})
+ do
+ echo "Checking GNU style for $sha"
+ git show $sha | ./contrib/check_GNU_style.py -
+ done
+ echo "styleresult=pass" | tee -a $FORGEJO_OUTPUT
+
+ - name: gcc-verify
+ id: gcc_verify
+ continue-on-error: true
+ run: |
+ echo "Running gcc-verify check"
+ ./contrib/gcc-changelog/git_check_commit.py ${FORGEJO_BASE_REF}..${FORGEJO_SHA}
+ echo "verifyresult=pass" | tee -a $FORGEJO_OUTPUT
+
+ - name: final-result
+ run: |
+ echo "Computing final result"
+ test "${{ steps.check_gnu_style.outputs.styleresult }}" = "pass"
+ test "${{ steps.gcc_verify.outputs.verifyresult }}" = "pass"