Skip to content

Commit 3c5170b

Browse files
authored
Merge pull request #38 from rimolive/rmartine
chore: Add Commit Checker github action
2 parents 7bd866d + 56ecc37 commit 3c5170b

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

.github/workflows/build-prs.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,36 @@ env:
1111
GH_USER_EMAIL: [email protected]
1212
GH_USER_NAME: dsp-developers
1313
jobs:
14+
commit_checker:
15+
name: Run Commit Checker report
16+
runs-on: ubuntu-latest
17+
needs: build-pr-images
18+
steps:
19+
- name: Get Commits
20+
id: get-commits
21+
run: |
22+
master_commit=$(cat .git/refs/remotes/origin/master)
23+
echo "master_commit_hash=$master_commit" >> $GITHUB_OUTPUT
24+
last_commit=$(cat .git/refs/remotes/pull/${{ github.event.pull_request.number }}/merge)
25+
echo "last_commit_hash=$last_commit" >> $GITHUB_OUTPUT
26+
- name: Run Commit Checker
27+
shell: bash
28+
env:
29+
GH_TOKEN: ${{ secrets.GH_TOKEN_PROJECT_EDIT }}
30+
continue-on-error: true
31+
run: |
32+
git config user.email "${{ env.GH_USER_EMAIL }}"
33+
git config user.name "${{ env.GH_USER_NAME }}"
34+
35+
cat <<"EOF" >> /tmp/body-file.txt
36+
Commit Checker results:
37+
==== These are the results of the commit checker scans ====
38+
==== If these are not commits from upstream kfp, then ====
39+
==== please ensure you adhere to the commit checker formatting ====
40+
$(podman run -q -v ${{ github.workspace }}:/src/app-root quay.io/rmartine/commitchecker:latest --start ${{ steps.get-commits.outputs.master_commit_hash }} --end ${{ steps.get-commits.outputs.last_commit_hash }})
41+
EOF
42+
43+
gh pr comment ${{ github.event.pull_request.number }} --body-file /tmp/body-file.txt
1444
fetch-data:
1545
name: Fetch workflow payload
1646
runs-on: ubuntu-latest

tools/commit_checker/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM registry.access.redhat.com/ubi8/go-toolset:1.20 as builder
2+
3+
WORKDIR /tmp
4+
RUN git clone https://github.com/openshift/build-machinery-go.git && \
5+
cd /tmp/build-machinery-go/commitchecker && \
6+
go build
7+
8+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9
9+
10+
WORKDIR /bin
11+
12+
COPY --from=builder /tmp/build-machinery-go/commitchecker/commitchecker /bin/commitchecker
13+
RUN microdnf install git && \
14+
chmod +x /bin/commitchecker && \
15+
mkdir -p /src/app-root
16+
17+
WORKDIR /src/app-root
18+
ENTRYPOINT ["commitchecker"]
19+
20+
VOLUME ["/src/app-root"]
21+
22+
LABEL name="Commit Checker tool" \
23+
summary="commitchecker validates a range of commits in a git repository and ensures they meet specific requirements: \
24+
1. The author's email address does not start with "root@". \
25+
2. The message starts with one of: \
26+
i. UPSTREAM: <PR number|carry|drop>: description \
27+
ii. UPSTREAM: revert: \
28+
This is useful for repositories that are downstream forks of upstream repositories."

0 commit comments

Comments
 (0)