Skip to content

Commit

Permalink
Merge pull request #127 from dipankardas011/iterate/121
Browse files Browse the repository at this point in the history
[Implementation] (Proposal 2)  Add Benchmark Pipeline
  • Loading branch information
nikimanoledaki authored Nov 28, 2024
2 parents 229982a + 35d0d7d commit 9c058d0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
49 changes: 41 additions & 8 deletions .github/workflows/benchmark-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ on:
cncf_project:
description: Project to be deployed e.g. falco
required: true
type: string
config:
description: Configuration if project has multiple variants they wish to test
required: false
type: string
version:
description: Version of project to be tested e.g. 0.37.0
required: true
benchmark_path:
description: Path to the benchmark action
required: false # TODO: change to `true` when `"benchmark_path"` is specified in `projects/projects.json`
type: string
benchmark_job_url:
description: URL of the benchmark job
required: true
type: string
benchmark_job_duration_mins:
description: Duration of the benchmark job
required: true
type: number

concurrency:
group: benchmark
Expand All @@ -31,10 +39,12 @@ jobs:
echo "| cncf_project | ${{ github.event.inputs.cncf_project }} |" >> $GITHUB_STEP_SUMMARY
echo "| config | ${{ github.event.inputs.config }} |" >> $GITHUB_STEP_SUMMARY
echo "| version | ${{ github.event.inputs.version }} |" >> $GITHUB_STEP_SUMMARY
echo "| benchmark_path | ${{ github.event.inputs.benchmark_path }} |" >> $GITHUB_STEP_SUMMARY
echo "| benchmark_job_url | ${{ github.event.inputs.benchmark_job_url }} |" >> $GITHUB_STEP_SUMMARY
echo "| benchmark_job_duration_mins | ${{ github.event.inputs.benchmark_job_duration_mins }} |" >> $GITHUB_STEP_SUMMARY
deploy:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: azure/setup-kubectl@v4
Expand Down Expand Up @@ -76,11 +86,34 @@ jobs:
--namespace=benchmark
benchmark-job:
uses: ${{ inputs.benchmark_path }}
runs-on: ubuntu-24.04
needs: deploy
steps:
- uses: actions/checkout@v4
- uses: azure/setup-kubectl@v4
with:
version: v1.30.2
id: install
- run: mkdir ~/.kube && echo "${{ secrets.KUBECONFIG }}" > ~/.kube/config
- name: Run the benchmark job
run: |
kubectl apply -f ${{ inputs.benchmark_job_url }}
kubectl wait pod \
--all \
--for=condition=Ready
- name: Wait for the benchmark job to complete
run: |
sleep ${{ inputs.benchmark_job_duration_mins }}m
- name: Delete the benchmark job
run: |
kubectl delete -f ${{ inputs.benchmark_job_url }} --wait
delete:
runs-on: ubuntu-22.04
needs: deploy
runs-on: ubuntu-24.04
needs: benchmark-job
if: ${{ always() }}
steps:
- uses: actions/checkout@v4
Expand Down
5 changes: 4 additions & 1 deletion projects/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
{
"name": "falco",
"organization": "falcosecurity",
"benchmark_path": "",
"benchmark": {
"k8s_manifest_url": "https://raw.githubusercontent.com/falcosecurity/cncf-green-review-testing/e93136094735c1a52cbbef3d7e362839f26f4944/benchmark-tests/falco-benchmark-tests.yaml",
"duration_mins": 15
},
"configs": [
"ebpf",
"modern-ebpf",
Expand Down
10 changes: 6 additions & 4 deletions scripts/project-trigger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ fi
jq -c '.projects[]' "$json_file" | while read -r project; do
proj_name=$(echo "$project" | jq -r '.name')
proj_organization=$(echo "$project" | jq -r '.organization')
proj_benchmark_path=$(echo "$project" | jq -r '.benchmark_path')
proj_benchmark_manifest_url=$(echo "$project" | jq -r '.benchmark.k8s_manifest_url')
proj_benchmark_duration_mins=$(echo "$project" | jq -r '.benchmark.duration_mins')
configs=$(echo "$project" | jq -r '.configs')

echo "Project Name: $proj_name"
echo "Organization: $proj_organization"
echo "Benchmark Path: $proj_benchmark_path"
echo "Benchmark Manifest URL: $proj_benchmark_manifest_url"
echo "Benchmark Duration (Minutes): $proj_benchmark_duration_mins"
echo "Configs: $configs"

release_url="https://api.github.com/repos/${proj_organization}/${proj_name}/releases/latest"
Expand Down Expand Up @@ -50,7 +52,7 @@ jq -c '.projects[]' "$json_file" | while read -r project; do
-H "Authorization: Bearer $gh_token" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$workflow_organization_name/$workflow_project_name/actions/workflows/$workflow_dispatcher_file_name/dispatches" \
-d "{\"ref\":\"${git_ref}\",\"inputs\":{\"cncf_project\":\"${proj_name}\",\"config\":\"\",\"version\":\"${latest_proj_version}\"}}")
-d "{\"ref\":\"${git_ref}\",\"inputs\":{\"cncf_project\":\"${proj_name}\",\"benchmark_job_url\":\"${proj_benchmark_manifest_url}\",\"benchmark_job_duration_mins\":\"${proj_benchmark_duration_mins}\",\"version\":\"${latest_proj_version}\"}}")

status_code=$?
if [ $status_code -ne 0 ]; then
Expand All @@ -68,7 +70,7 @@ jq -c '.projects[]' "$json_file" | while read -r project; do
-H "Authorization: Bearer $gh_token" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$workflow_organization_name/$workflow_project_name/actions/workflows/$workflow_dispatcher_file_name/dispatches" \
-d "{\"ref\":\"${git_ref}\",\"inputs\":{\"cncf_project\":\"${proj_name}\",\"config\":\"${config}\",\"version\":\"${latest_proj_version}\"}}")
-d "{\"ref\":\"${git_ref}\",\"inputs\":{\"cncf_project\":\"${proj_name}\",\"benchmark_job_url\":\"${proj_benchmark_manifest_url}\",\"benchmark_job_duration_mins\":\"${proj_benchmark_duration}\",\"config\":\"${config}\",\"version\":\"${latest_proj_version}\"}}")

status_code=$?
if [ $status_code -ne 0 ]; then
Expand Down

0 comments on commit 9c058d0

Please sign in to comment.