modularize workflow
This commit is contained in:
parent
b0c8f2f969
commit
9855142340
3 changed files with 201 additions and 183 deletions
40
.github/actions/trigger-hydra-build.yml
vendored
Normal file
40
.github/actions/trigger-hydra-build.yml
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
name: 'Trigger Hydra Build'
|
||||
description: 'Triggers a build on a Hydra CI server'
|
||||
inputs:
|
||||
hydra_instance:
|
||||
description: 'URL of the Hydra instance'
|
||||
required: true
|
||||
hydra_project:
|
||||
description: 'Name of the Hydra project'
|
||||
required: true
|
||||
hydra_jobset:
|
||||
description: 'Name of the Hydra jobset'
|
||||
required: true
|
||||
hydra_username:
|
||||
description: 'Username for Hydra authentication'
|
||||
required: true
|
||||
hydra_password:
|
||||
description: 'Password for Hydra authentication'
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Trigger Hydra build
|
||||
shell: bash
|
||||
run: |
|
||||
AUTH_HEADER="Authorization: Basic $(echo -n '${{ inputs.hydra_username }}:${{ inputs.hydra_password }}' | base64)"
|
||||
response=$(curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "$AUTH_HEADER" \
|
||||
-H "Origin: ${{ inputs.hydra_instance }}" \
|
||||
-d '{"jobsets": ["${{ inputs.hydra_project }}:${{ inputs.hydra_jobset }}"]}' \
|
||||
"${{ inputs.hydra_instance }}/api/push")
|
||||
|
||||
if [[ $response == *"\"submitted\":true"* ]]; then
|
||||
echo "Hydra build triggered successfully"
|
||||
else
|
||||
echo "Failed to trigger Hydra build"
|
||||
echo "Response: $response"
|
||||
exit 1
|
||||
fi
|
||||
91
.github/actions/wait-for-hydra-build.yml
vendored
Normal file
91
.github/actions/wait-for-hydra-build.yml
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
name: 'Wait for Hydra Build'
|
||||
description: 'Waits for a Hydra build to complete and returns the build status'
|
||||
inputs:
|
||||
hydra_instance:
|
||||
description: 'URL of the Hydra instance'
|
||||
required: true
|
||||
hydra_project:
|
||||
description: 'Name of the Hydra project'
|
||||
required: true
|
||||
hydra_jobset:
|
||||
description: 'Name of the Hydra jobset'
|
||||
required: true
|
||||
hydra_username:
|
||||
description: 'Username for Hydra authentication'
|
||||
required: true
|
||||
hydra_password:
|
||||
description: 'Password for Hydra authentication'
|
||||
required: true
|
||||
max_attempts:
|
||||
description: 'Maximum number of attempts to check build status'
|
||||
required: false
|
||||
default: '60'
|
||||
wait_interval:
|
||||
description: 'Interval in seconds between status checks'
|
||||
required: false
|
||||
default: '120'
|
||||
|
||||
outputs:
|
||||
build_success:
|
||||
description: 'Whether the build succeeded (true) or failed (false)'
|
||||
value: ${{ steps.wait-for-build.outputs.build_success }}
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Wait for Hydra build
|
||||
id: wait-for-build
|
||||
shell: bash
|
||||
run: |
|
||||
AUTH_HEADER="Authorization: Basic $(echo -n '${{ inputs.hydra_username }}:${{ inputs.hydra_password }}' | base64)"
|
||||
attempt=0
|
||||
max_attempts=${{ inputs.max_attempts }}
|
||||
wait_interval=${{ inputs.wait_interval }}
|
||||
|
||||
while [ $attempt -lt $max_attempts ]; do
|
||||
echo "Attempt $((attempt + 1))/$max_attempts"
|
||||
|
||||
response=$(curl -s -H "$AUTH_HEADER" \
|
||||
"${{ inputs.hydra_instance }}/api/jobsets?project=${{ inputs.hydra_project }}")
|
||||
|
||||
jobset=$(echo "$response" | jq -r '.[] | select(.name == "${{ inputs.hydra_jobset }}")')
|
||||
|
||||
if [ -z "$jobset" ]; then
|
||||
echo "Jobset ${{ inputs.hydra_jobset }} not found. Waiting..."
|
||||
sleep $wait_interval
|
||||
attempt=$((attempt + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
nrscheduled=$(echo "$jobset" | jq -r '.nrscheduled')
|
||||
nrfailed=$(echo "$jobset" | jq -r '.nrfailed')
|
||||
nrsucceeded=$(echo "$jobset" | jq -r '.nrsucceeded')
|
||||
nrtotal=$(echo "$jobset" | jq -r '.nrtotal')
|
||||
|
||||
echo "Status: nrscheduled=$nrscheduled, nrfailed=$nrfailed, nrsucceeded=$nrsucceeded, nrtotal=$nrtotal"
|
||||
|
||||
if [ "$nrtotal" = "0" ]; then
|
||||
echo "Build not started yet. Waiting..."
|
||||
elif [ "$nrfailed" != "0" ]; then
|
||||
echo "build_success=false" >> $GITHUB_OUTPUT
|
||||
echo "Build failed"
|
||||
exit 0
|
||||
elif [ "$nrsucceeded" = "$nrtotal" ] && [ "$nrtotal" != "0" ]; then
|
||||
echo "build_success=true" >> $GITHUB_OUTPUT
|
||||
echo "Build succeeded"
|
||||
exit 0
|
||||
elif [ "$nrscheduled" = "0" ] && [ "$nrsucceeded" != "0" ] && [ "$nrsucceeded" = "$nrtotal" ]; then
|
||||
echo "build_success=true" >> $GITHUB_OUTPUT
|
||||
echo "Build succeeded"
|
||||
exit 0
|
||||
else
|
||||
echo "Build in progress. Waiting..."
|
||||
fi
|
||||
|
||||
sleep $wait_interval
|
||||
attempt=$((attempt + 1))
|
||||
done
|
||||
|
||||
echo "build_success=false" >> $GITHUB_OUTPUT
|
||||
echo "Timeout reached. Build considered failed."
|
||||
exit 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue