Skip to content

Commit

Permalink
ci: run UI integration tests as part of every PR (#977)
Browse files Browse the repository at this point in the history
* ci: added execute_jenkins_ui_integration_tests_java.yml

* ci: enabled integration tests to run on release PR
  • Loading branch information
vanshaj-bhatia authored Oct 9, 2024
1 parent d229149 commit a3286c7
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/execute_jenkins_build_java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:

jobs:
jenkins-build-java:
if: (github.event.pull_request.head.ref != 'release-please--branches--main')
runs-on: ubuntu-latest
outputs:
BUILD_URL: ${{ steps.trigger.outputs.BUILD_URL }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/execute_jenkins_build_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:

jobs:
jenkins-build-python:
if: (github.event.pull_request.head.ref != 'release-please--branches--main')
runs-on: ubuntu-latest
outputs:
BUILD_URL: ${{ steps.trigger.outputs.BUILD_URL }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:

jobs:
jenkins-integration-tests-java:
if: (github.event.pull_request.head.ref != 'release-please--branches--main')
runs-on: ubuntu-latest
outputs:
BUILD_URL: ${{ steps.trigger.outputs.BUILD_URL }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:

jobs:
jenkins-integration-tests-python:
if: (github.event.pull_request.head.ref != 'release-please--branches--main')
runs-on: ubuntu-latest
outputs:
BUILD_URL: ${{ steps.trigger.outputs.BUILD_URL }}
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/execute_jenkins_ui_integration_tests_java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Java UI Integration

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
jenkins-ui-integration-tests-java:
runs-on: ubuntu-latest
outputs:
BUILD_URL: ${{ steps.trigger.outputs.BUILD_URL }}
EXECUTABLE_URL: ${{ steps.get_executable_url.outputs.POLLING_URL }}
env:
JENKINS_URL: https://dataproctemplatesci.com/job/dataproc-templates-build/job/ad-hoc/job/ui-integration-tests-java/buildWithParameters?token=GITHUB_TOKEN&branchName=origin/${{ github.head_ref }}
JOB_NAME: ui-integration-tests-java
CREDS: ${{ secrets.JENKINS_CREDS }}
steps:
- name: Trigger Jenkins Job
id: trigger
run: |
echo -n "BUILD_URL=$(curl -i -s -u $CREDS $JENKINS_URL | grep "location" | awk '{printf $2}' | tr -d '\r')" >> $GITHUB_OUTPUT
if [[ $? != 0 ]]; then
echo "API request failed. Please check the Jenkins URL and API token."
exit 1
fi
- name: Get the Jenkin job Execution URL
id: get_executable_url
env:
JOB_URL: ${{ steps.trigger.outputs.BUILD_URL }}api/json
run: |
echo "Build Job Queue URL received on Jenkins trigger: $JOB_URL"
EXECUTABLE_URL=$(curl -s -u $CREDS $JOB_URL | jq -r '.executable.url')
if [[ $? != 0 ]]; then
echo "API request failed. Please check the Jenkins URL and API token."
exit 1
fi
echo "Executable URL received on the first attempt: [$EXECUTABLE_URL]"
while [[ "$EXECUTABLE_URL" == null ]]; do
EXECUTABLE_URL=$(curl -s -u $CREDS $JOB_URL | jq -r '.executable.url')
if [[ $? != 0 ]]; then
echo "API request failed. Please check the Jenkins URL and API token."
exit 1
fi
done
echo "POLLING_URL=$EXECUTABLE_URL" >> $GITHUB_OUTPUT
- name: Wait for Jenkins Job to Complete
id: status_check
env:
POLLING_URL: ${{ steps.get_executable_url.outputs.POLLING_URL }}api/json
run: |
echo "Executable URL to be polled for the triggered Jenkins job: $POLLING_URL"
status="UNKNOWN"
while [[ $status != "SUCCESS" ]]; do
sleep 90
status=$(curl -s -u $CREDS $POLLING_URL | jq -r '.result')
if [[ $? != 0 ]]; then
echo "JSON data could not be parsed. Exiting..."
exit 1
fi
echo "Result Polled on Job Executable URL: [$status]"
[ "$status" == null ] && continue
if [[ $status == "FAILURE" || $status == "NOT_BUILT" || $status == "ABORTED" || $status == "UNSTABLE" ]]; then
echo "Jenkins job $JOB_NAME with Build URL $JOB_URL completed with status [$status]"
exit 99
fi
done
echo "Jenkins job $JOB_NAME with Build URL $JOB_URL completed with status $status"

0 comments on commit a3286c7

Please sign in to comment.