Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add Commit Checker github action #38

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/build-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,36 @@ env:
GH_USER_EMAIL: [email protected]
GH_USER_NAME: dsp-developers
jobs:
commit_checker:
name: Run Commit Checker report
runs-on: ubuntu-latest
needs: build-pr-images
steps:
- name: Get Commits
id: get-commits
run: |
master_commit=$(cat .git/refs/remotes/origin/master)
echo "master_commit_hash=$master_commit" >> $GITHUB_OUTPUT
last_commit=$(cat .git/refs/remotes/pull/${{ github.event.pull_request.number }}/merge)
echo "last_commit_hash=$last_commit" >> $GITHUB_OUTPUT
- name: Run Commit Checker
shell: bash
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_PROJECT_EDIT }}
continue-on-error: true
run: |
git config user.email "${{ env.GH_USER_EMAIL }}"
git config user.name "${{ env.GH_USER_NAME }}"

cat <<"EOF" >> /tmp/body-file.txt
Commit Checker results:
==== These are the results of the commit checker scans ====
==== If these are not commits from upstream kfp, then ====
==== please ensure you adhere to the commit checker formatting ====
$(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 }})
EOF

gh pr comment ${{ github.event.pull_request.number }} --body-file /tmp/body-file.txt
fetch-data:
name: Fetch workflow payload
runs-on: ubuntu-latest
Expand Down
28 changes: 28 additions & 0 deletions tools/commit_checker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM registry.access.redhat.com/ubi8/go-toolset:1.20 as builder

WORKDIR /tmp
RUN git clone https://github.com/openshift/build-machinery-go.git && \
cd /tmp/build-machinery-go/commitchecker && \
go build

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9

WORKDIR /bin

COPY --from=builder /tmp/build-machinery-go/commitchecker/commitchecker /bin/commitchecker
RUN microdnf install git && \
chmod +x /bin/commitchecker && \
mkdir -p /src/app-root

WORKDIR /src/app-root
ENTRYPOINT ["commitchecker"]

VOLUME ["/src/app-root"]

LABEL name="Commit Checker tool" \
summary="commitchecker validates a range of commits in a git repository and ensures they meet specific requirements: \
1. The author's email address does not start with "root@". \
2. The message starts with one of: \
i. UPSTREAM: <PR number|carry|drop>: description \
ii. UPSTREAM: revert: \
This is useful for repositories that are downstream forks of upstream repositories."
Loading