diff --git a/.github/workflows/integration-pr.yml b/.github/workflows/integration-pr.yml new file mode 100644 index 00000000..45a24fe9 --- /dev/null +++ b/.github/workflows/integration-pr.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/sdk-nightly.yml b/.github/workflows/sdk-nightly.yml new file mode 100644 index 00000000..2d319613 --- /dev/null +++ b/.github/workflows/sdk-nightly.yml @@ -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 \ No newline at end of file