-
Notifications
You must be signed in to change notification settings - Fork 16
Migrate llm-judge detector to TrustyAI #17
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
Open
saichandrapandraju
wants to merge
5
commits into
trustyai-explainability:main
Choose a base branch
from
saichandrapandraju:migrate-image-judge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9c86fef
migrate llm-judge detector to TrustyAI
saichandrapandraju b020e2f
Merge branch 'trustyai-explainability:main' into migrate-image-judge
saichandrapandraju 7292ede
Integrate LLM Judge CI workflow to main build-and-push & reemove old …
saichandrapandraju 63c2c0f
address sourcery comment to prevent injection vulnerabilities
saichandrapandraju b1e5ac6
address sourcery comments regarding repeated env vars + passing --lab…
saichandrapandraju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: Build and Push - LLM Judge Detector | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
paths: | ||
- 'detectors/llm_judge/*' | ||
- 'detectors/Dockerfile.judge' | ||
pull_request_target: | ||
paths: | ||
- 'detectors/llm_judge/*' | ||
- 'detectors/Dockerfile.judge' | ||
types: [labeled, opened, synchronize, reopened] | ||
jobs: | ||
# Ensure that tests pass before publishing a new image. | ||
build-and-push-ci: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
security-events: write | ||
steps: # Assign context variable for various action contexts (tag, main, CI) | ||
- name: Assigning CI context | ||
if: github.head_ref != '' && github.head_ref != 'main' && !startsWith(github.ref, 'refs/tags/v') | ||
run: echo "BUILD_CONTEXT=ci" >> $GITHUB_ENV | ||
- name: Assigning tag context | ||
if: github.head_ref == '' && startsWith(github.ref, 'refs/tags/v') | ||
run: echo "BUILD_CONTEXT=tag" >> $GITHUB_ENV | ||
- name: Assigning main context | ||
if: github.head_ref == '' && github.ref == 'refs/heads/main' | ||
run: echo "BUILD_CONTEXT=main" >> $GITHUB_ENV | ||
# | ||
# Run checkouts | ||
- uses: mheap/github-action-required-labels@v4 | ||
if: env.BUILD_CONTEXT == 'ci' | ||
with: | ||
mode: minimum | ||
count: 1 | ||
labels: "ok-to-test, lgtm, approved" | ||
- uses: actions/checkout@v3 | ||
if: env.BUILD_CONTEXT == 'ci' | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- uses: actions/checkout@v3 | ||
if: env.BUILD_CONTEXT == 'main' || env.BUILD_CONTEXT == 'tag' | ||
# | ||
# Print variables for debugging | ||
- name: Log reference variables | ||
run: | | ||
echo "CONTEXT: ${{ env.BUILD_CONTEXT }}" | ||
echo "GITHUB.REF: ${{ github.ref }}" | ||
echo "GITHUB.HEAD_REF: ${{ github.head_ref }}" | ||
echo "SHA: ${{ github.event.pull_request.head.sha }}" | ||
echo "MAIN IMAGE AT: quay.io/trustyai/guardrails-detector-llm-judge:latest" | ||
echo "CI IMAGE AT: quay.io/trustyai/guardrails-detector-llm-judge-ci:${{ github.event.pull_request.head.sha }}" | ||
|
||
# Set environments depending on context | ||
- name: Set CI environment | ||
if: env.BUILD_CONTEXT == 'ci' | ||
run: | | ||
echo "TAG=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV | ||
echo "IMAGE_NAME=quay.io/trustyai/guardrails-detector-llm-judge-ci" >> $GITHUB_ENV | ||
- name: Set main-branch environment | ||
if: env.BUILD_CONTEXT == 'main' | ||
run: | | ||
echo "TAG=latest" >> $GITHUB_ENV | ||
echo "IMAGE_NAME=quay.io/trustyai/guardrails-detector-llm-judge" >> $GITHUB_ENV | ||
- name: Set tag environment | ||
if: env.BUILD_CONTEXT == 'tag' | ||
run: | | ||
echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV | ||
echo "IMAGE_NAME=quay.io/trustyai/guardrails-detector-llm-judge" >> $GITHUB_ENV | ||
# | ||
# Run docker commands | ||
- name: Put expiry date on CI-tagged image | ||
if: env.BUILD_CONTEXT == 'ci' | ||
run: echo 'LABEL quay.expires-after=7d#' >> detectors/Dockerfile.judge | ||
- name: Build image | ||
run: docker build -t ${{ env.IMAGE_NAME }}:$TAG -f detectors/Dockerfile.judge detectors | ||
- name: Log in to Quay | ||
run: docker login -u ${{ secrets.QUAY_ROBOT_USERNAME }} -p ${{ secrets.QUAY_ROBOT_SECRET }} quay.io | ||
- name: Push to Quay CI repo | ||
run: docker push ${{ env.IMAGE_NAME }}:$TAG | ||
|
||
# Leave comment | ||
- uses: peter-evans/find-comment@v3 | ||
name: Find Comment | ||
if: env.BUILD_CONTEXT == 'ci' | ||
id: fc | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: PR image build completed successfully | ||
- uses: peter-evans/create-or-update-comment@v4 | ||
if: env.BUILD_CONTEXT == 'ci' | ||
name: Generate/update success message comment | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
edit-mode: replace | ||
body: | | ||
PR image build completed successfully! | ||
|
||
📦 [PR image](https://quay.io/repository/trustyai/guardrails-detector-llm-judge-ci?tab=tags): `quay.io/trustyai/guardrails-detector-llm-judge-ci:${{ github.event.pull_request.head.sha }}` | ||
- name: Trivy scan | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: 'image' | ||
image-ref: "${{ env.IMAGE_NAME }}:${{ env.TAG }}" | ||
format: 'sarif' | ||
output: 'trivy-results.sarif' | ||
severity: 'MEDIUM,HIGH,CRITICAL' | ||
exit-code: '0' | ||
sourcery-ai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ignore-unfixed: false | ||
vuln-type: 'os,library' | ||
|
||
- name: Update Security tab | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: 'trivy-results.sarif' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.