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

[WIP] Run Integration Tests on PR #315

Open
wants to merge 4 commits into
base: main
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
48 changes: 48 additions & 0 deletions .github/workflows/integration-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Integration Tests Check

on:
pull_request:
branches: [ "main" ]

jobs:
start-check:
runs-on: ubuntu-latest
permissions:
checks: write # Permission to create a Check Run
actions: write # Permission to run another workflow
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Create Check
id: checkrun
env:
GH_TOKEN: ${{ github.token }} # Expose the token for GH CLI
run: |
# Due to GitHub limitations, the check is assigned randomly to a check suit
# https://github.com/orgs/community/discussions/24616
CHECKID=$(gh api -X POST -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f name='Integration Tests' \
-f head_sha='${{ github.event.pull_request.head.sha }}' \
-f status='queued' \
-f 'output[title]=Run Integration Tests' \
-f 'output[summary]=Running Integration Tests for Java SDK' \
--jq '.id' \
/repos/${{ github.repository }}/check-runs)

# Put the ID into a step variable
echo "checkId=$CHECKID" >> $GITHUB_OUTPUT

- name: Trigger Workflow
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api -X POST -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'inputs[check_run_id]=${{ steps.checkrun.outputs.checkId }}' \
-f 'inputs[pull_request_number]=${{ github.events.pull_request.number }}' \
-f "ref=${{ steps.extract_branch.outputs.branch }}" \
/repos/${{ github.repository }}/actions/workflows/sdk-nightly.yml/dispatches
93 changes: 93 additions & 0 deletions .github/workflows/sdk-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Integration Tests
on:
workflow_dispatch:
inputs:
check_run_id:
description: "ID for the Check Run in a PR"
type: string
required: false
pull_request_number:
description: "Pull request number to test (if empty, tests run against main)"
required: false


jobs:
acknowledge-request:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.check_run_id }} != ""
steps:
- name: Acknowledge Request
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'status=in_progress' \
-f 'output[title]=Run Integration Tests' \
-f 'output[summary]=Running Integration Tests for Java SDK' \
/repos/${{ github.repository }}/check-runs/${{ github.event.inputs.check_run_id }}

####################################################
# Actually, we'll just sleep to simulate some work
####################################################
integration-tests-prod:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.check_run_id }} != ""
steps:
- name: Processing
run: sleep 10

# publish-lkg:
# if: ${{ github.ref == 'refs/heads/main' && inputs.pull_request_number == '' }}
# needs: [integration-tests-prod]
# uses: ./.github/workflows/publish-lkg.yml
# secrets: inherit
# with:
# lkg_sha: ${{ needs.integration-tests-prod.outputs.lkg_sha}}
# repository_name: "databricks-sdk-go"
# repository_org: "databricks"

complete-notification:
runs-on: ubuntu-latest
needs: [ integration-tests-prod ]
steps:
- name: Send Complete Notification
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/check-runs/${{ github.event.inputs.check_run_id }} \
--input - <<- EOF
{
"conclusion": "success",
"output": {
"title": "Run Integration Tests",
"summary": "[Execution Details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})",
"text": "Successful execution of Integration Tests for Java SDK"
}
}
EOF

failure-notification:
runs-on: ubuntu-latest
if: failure()
needs: [integration-tests-prod]
steps:
- name: Send Failure Notification
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/check-runs/${{ github.event.inputs.check_run_id }} \
--input - <<- EOF
{
"conclusion": "failure",
"output": {
"title": "Run Integration Tests",
"summary": "[Execution Details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})",
"text": "Failed execution of Integration Tests for Java SDK"
}
}
EOF
Loading