Remove auto-merge, test [benchmark chore] non-trigger #164
Workflow file for this run
This file contains 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
name: Run Benchmarks | ||
Check failure on line 1 in .github/workflows/ucc-benchmarks.yml
|
||
on: | ||
push: | ||
branches: | ||
- PR-auto-merge-GH-Action | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: 'Branch to run benchmarks on' | ||
required: false | ||
default: 'PR-auto-merge-GH-Action' | ||
jobs: | ||
run-benchmarks: | ||
runs-on: ucc-benchmarks-8-core-U22.04 | ||
if: ! contains(github.event.head_commit.message, '[benchmark chore') | ||
steps: | ||
# Checkout the latest main branch | ||
- name: Checkout main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Ensure the full history is fetched | ||
# Create and switch to a temporary branch | ||
- name: Create temporary branch | ||
run: | | ||
git checkout main | ||
git pull origin main | ||
git switch -c auto-benchmark-$(date +%Y%m%d%H%M%S) | ||
# Build the Docker image | ||
- name: Build Docker image | ||
run: docker build -t ucc-benchmark . | ||
# Run the benchmarks in the Docker container | ||
- name: Run benchmarks | ||
run: | | ||
docker run --rm \ | ||
-v "${{ github.workspace }}:/ucc" \ | ||
ucc-benchmark bash -c " | ||
source /venv/bin/activate && \ | ||
./benchmarks/scripts/small_test.sh | ||
" | ||
# Commit and push benchmark results | ||
- name: Configure Git for commit | ||
run: | | ||
git config --global user.email "actions@github.com" | ||
git config --global user.name "GitHub Actions" | ||
# Commit and push results to a new branch (temporary) | ||
- name: Commit and push results to new branch | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git add benchmarks/* | ||
git status | ||
git commit -m "Update benchmark results" || echo "No changes to commit" | ||
git push origin HEAD | ||
# Create a pull request (PR) to main | ||
- name: Create Pull Request | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
PR_TITLE="Update benchmark results" | ||
HEAD_BRANCH=$(git rev-parse --abbrev-ref HEAD) # Get the current branch name (auto-benchmark-*) | ||
RESPONSE=$(curl -X POST \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/pulls \ | ||
-d "$(jq -n \ | ||
--arg title "$PR_TITLE" \ | ||
--arg head "$HEAD_BRANCH" \ | ||
--arg base "main" \ | ||
'{title: $title, head: $head, base: $base}')") | ||
echo "$RESPONSE" > pr_response.json | ||
PR_NUMBER=$(jq -r '.number' <<< "$RESPONSE") | ||
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV | ||