Skip to content
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

Deploy a workflow to trigger our internal pipeline #6027

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/internal_sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Internal-CI

on:
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PR_NUMBER: ${{ github.event.number }}

jobs:
build:
strategy:
matrix:
include:
# Self-hosted falcor tests
- os: windows
runs-on: [Windows, self-hosted]
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
submodules: "false"
fetch-depth: "0"
- name: Setup jd tools to git-bash
shell: pwsh
run: |
Add-Content -Path $env:GITHUB_PATH -Value "C:\\Program Files\\Git\\bin"
Add-Content -Path $env:GITHUB_PATH -Value "C:\\Program Files\\Git\\usr\\bin"
Invoke-WebRequest https://github.com/jqlang/jq/releases/latest/download/jq-win64.exe -OutFile ".\\jq.exe"
echo $PWD

- name: Run Internal CI Pipeline
shell: bash
env:
PIPELINE_TRIGGER_TOKEN: ${{ secrets.INTERNAL_PIPELINE_TRIGGER_TOKEN }}
INTERNAL_PIPELINE_API_ENDPOINT: ${{ secrets.INTERNAL_PIPELINE_ENDPOINT }}
ACCESS_TOKEN: ${{ secrets.INTERNAL_PIPELINE_ACCESS_TOKEN }}
run: .github/workflows/internal_test.sh $PR_NUMBER
87 changes: 87 additions & 0 deletions .github/workflows/internal_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <PR id>"
exit 1
fi

export PATH=$PATH:$PWD

PR=$1

# # Trigger the pipeline
trigger_response=$(curl -s --request POST \
--form token=${PIPELINE_TRIGGER_TOKEN} \
--form ref=nv-master \
--form "variables[PR]=$PR" \
"$INTERNAL_PIPELINE_API_ENDPOINT/trigger/pipeline")

pipeline_id=$(echo "$trigger_response" | jq -r '.id')

if [[ -z "$pipeline_id" || "$pipeline_id" == "null" ]]; then
echo "Failed to trigger the pipeline. Response: $trigger_response"
exit 1
fi

echo "Pipeline triggered successfully. Pipeline ID: $pipeline_id"

start_time=$(date +%s)
running_timeout=$((10 * 60)) # 10 minutes in seconds
completion_timeout=$((30 * 60)) # 30 minutes in seconds

# Check pipeline status
pipeline_status=""
while true; do

current_time=$(date +%s)
elapsed_time=$((current_time - start_time))

# Check if the pipeline hasn't started running after 10 minutes
if [[ $elapsed_time -ge $running_timeout && "$pipeline_status" != "running" && "$pipeline_status" == "success" ]]; then
echo "Error: Pipeline did not start running within 10 minutes."
exit 1
fi

# Check if the pipeline hasn't finished after 30 minutes
if [[ $elapsed_time -ge $completion_timeout ]]; then
echo "Error: Pipeline did not finish within 30 minutes."
exit 1
fi

status_response=$(curl -s --header "PRIVATE-TOKEN: $ACCESS_TOKEN" "$INTERNAL_PIPELINE_API_ENDPOINT/pipelines/$pipeline_id")
pipeline_status=$(echo "$status_response" | jq -r '.status')

if [[ -z "$pipeline_status" || "$pipeline_status" == "null" ]]; then
echo "Failed to fetch pipeline status. Response: $status_response"
exit 1
fi

if [[ "$pipeline_status" == "success" ]]; then
echo "Pipeline finished successfully."
break
elif [[ "$pipeline_status" == "failed" || "$pipeline_status" == "canceled" ]]; then
echo "Pipeline finished with status: $pipeline_status"
break
fi

echo "Pipeline status: $pipeline_status. Checking again in 2 minutes..."
sleep 120
done

echo "Fetching test report for Pipeline ID: $pipeline_id..."
test_report_response=$(curl -s --header "PRIVATE-TOKEN: $ACCESS_TOKEN" "$INTERNAL_PIPELINE_API_ENDPOINT/pipelines/$pipeline_id/test_report_summary")
curl_exit_code=$?

if [[ $curl_exit_code -ne 0 ]]; then
echo "Error: Failed to execute curl command while fetching test report. Exit code: $curl_exit_code"
else
echo "Test Report:"
echo "$test_report_response" | jq --color-output
fi

# Exit with appropriate status code
if [[ "$pipeline_status" == "success" ]]; then
exit 0
else
exit 1
fi
Loading