Skip to content

Commit

Permalink
Get integration test status check from client repos (#973)
Browse files Browse the repository at this point in the history
* Add step to get token

* Send status checks back to spec PR

* Remove comments, details

* Regenerate client from commit 379360f of spec repo

Co-authored-by: Hippolyte HENRY <hippolyte.henry@datadoghq.com>
Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
3 people authored Jun 3, 2021
1 parent c269a7a commit 713b37b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.4.1.dev8",
"regenerated": "2021-06-03 07:59:24.677012",
"spec_repo_commit": "6c05087"
"regenerated": "2021-06-03 12:21:12.869496",
"spec_repo_commit": "379360f"
},
"v2": {
"apigentools_version": "1.4.1.dev8",
"regenerated": "2021-06-03 07:59:57.715981",
"spec_repo_commit": "6c05087"
"regenerated": "2021-06-03 12:21:46.073810",
"spec_repo_commit": "379360f"
}
}
}
24 changes: 24 additions & 0 deletions .github/workflows/scripts/test_integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const SPEC_REPO = "datadog-api-spec"

module.exports.post_status_check = async (github, context, status) => {
const pr_num = context.payload.pull_request.head.ref.split("/")[2]
const {data: pr} = await github.pulls.get({
owner: context.repo.owner,
repo: SPEC_REPO,
pull_number: pr_num,
});
const { data: jobs } = await github.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId
});
await github.repos.createCommitStatus({
owner: context.repo.owner,
repo: SPEC_REPO,
sha: pr.head.sha,
state: status,
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/pull/${context.payload.pull_request.number}/checks?check_run_id=${jobs.jobs[0].id}`,
description: `${context.repo.repo} integration tests`,
context: `${context.repo.repo}_integration_tests`
});
}
36 changes: 34 additions & 2 deletions .github/workflows/test_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,28 @@ jobs:
DD_HOSTNAME: "none"
DD_INSIDE_CI: "true"
steps:
- name: Get GitHub App token
if: github.event_name == 'pull_request'
id: get_token
uses: tibdex/github-app-token@v1.3.0
with:
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
repository: DataDog/datadog-api-spec
- name: Checkout code
uses: actions/checkout@v2
- name: Post pending status check
if: github.event_name == 'pull_request'
uses: actions/github-script@v4.0.2
with:
github-token: ${{ steps.get_token.outputs.token }}
script: |
const script = require('.github/workflows/scripts/test_integration.js')
await script.post_status_check(github, context, "pending")
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Checkout code
uses: actions/checkout@v2
- name: Run integration tests
shell: bash
run: ./run-tests.sh
Expand All @@ -50,3 +66,19 @@ jobs:
DD_TEST_CLIENT_API_KEY: ${{ secrets.DD_CLIENT_API_KEY }}
DD_TEST_CLIENT_APP_KEY: ${{ secrets.DD_CLIENT_APP_KEY }}
RECORD: "none"
- name: Post failure status check
if: failure() && github.event_name == 'pull_request'
uses: actions/github-script@v4.0.2
with:
github-token: ${{ steps.get_token.outputs.token }}
script: |
const script = require('./.github/workflows/scripts/test_integration.js')
await script.post_status_check(github, context, "failure")
- name: Post success status check
if: "!failure() && github.event_name == 'pull_request'"
uses: actions/github-script@v4.0.2
with:
github-token: ${{ steps.get_token.outputs.token }}
script: |
const script = require('./.github/workflows/scripts/test_integration.js')
await script.post_status_check(github, context, "success")

0 comments on commit 713b37b

Please sign in to comment.