Skip to content

Commit 713b37b

Browse files
api-clients-generation-pipeline[bot]zippolyteci.datadog-api-spec
authored
Get integration test status check from client repos (#973)
* 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 <[email protected]> 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 <[email protected]>
1 parent c269a7a commit 713b37b

File tree

3 files changed

+62
-6
lines changed

3 files changed

+62
-6
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.4.1.dev8",
7-
"regenerated": "2021-06-03 07:59:24.677012",
8-
"spec_repo_commit": "6c05087"
7+
"regenerated": "2021-06-03 12:21:12.869496",
8+
"spec_repo_commit": "379360f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev8",
12-
"regenerated": "2021-06-03 07:59:57.715981",
13-
"spec_repo_commit": "6c05087"
12+
"regenerated": "2021-06-03 12:21:46.073810",
13+
"spec_repo_commit": "379360f"
1414
}
1515
}
1616
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const SPEC_REPO = "datadog-api-spec"
2+
3+
module.exports.post_status_check = async (github, context, status) => {
4+
const pr_num = context.payload.pull_request.head.ref.split("/")[2]
5+
const {data: pr} = await github.pulls.get({
6+
owner: context.repo.owner,
7+
repo: SPEC_REPO,
8+
pull_number: pr_num,
9+
});
10+
const { data: jobs } = await github.actions.listJobsForWorkflowRun({
11+
owner: context.repo.owner,
12+
repo: context.repo.repo,
13+
run_id: context.runId
14+
});
15+
await github.repos.createCommitStatus({
16+
owner: context.repo.owner,
17+
repo: SPEC_REPO,
18+
sha: pr.head.sha,
19+
state: status,
20+
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}`,
21+
description: `${context.repo.repo} integration tests`,
22+
context: `${context.repo.repo}_integration_tests`
23+
});
24+
}

.github/workflows/test_integration.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,28 @@ jobs:
3232
DD_HOSTNAME: "none"
3333
DD_INSIDE_CI: "true"
3434
steps:
35+
- name: Get GitHub App token
36+
if: github.event_name == 'pull_request'
37+
id: get_token
38+
uses: tibdex/[email protected]
39+
with:
40+
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
41+
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
42+
repository: DataDog/datadog-api-spec
43+
- name: Checkout code
44+
uses: actions/checkout@v2
45+
- name: Post pending status check
46+
if: github.event_name == 'pull_request'
47+
uses: actions/[email protected]
48+
with:
49+
github-token: ${{ steps.get_token.outputs.token }}
50+
script: |
51+
const script = require('.github/workflows/scripts/test_integration.js')
52+
await script.post_status_check(github, context, "pending")
3553
- name: Install Go
3654
uses: actions/setup-go@v2
3755
with:
3856
go-version: 1.16.x
39-
- name: Checkout code
40-
uses: actions/checkout@v2
4157
- name: Run integration tests
4258
shell: bash
4359
run: ./run-tests.sh
@@ -50,3 +66,19 @@ jobs:
5066
DD_TEST_CLIENT_API_KEY: ${{ secrets.DD_CLIENT_API_KEY }}
5167
DD_TEST_CLIENT_APP_KEY: ${{ secrets.DD_CLIENT_APP_KEY }}
5268
RECORD: "none"
69+
- name: Post failure status check
70+
if: failure() && github.event_name == 'pull_request'
71+
uses: actions/[email protected]
72+
with:
73+
github-token: ${{ steps.get_token.outputs.token }}
74+
script: |
75+
const script = require('./.github/workflows/scripts/test_integration.js')
76+
await script.post_status_check(github, context, "failure")
77+
- name: Post success status check
78+
if: "!failure() && github.event_name == 'pull_request'"
79+
uses: actions/[email protected]
80+
with:
81+
github-token: ${{ steps.get_token.outputs.token }}
82+
script: |
83+
const script = require('./.github/workflows/scripts/test_integration.js')
84+
await script.post_status_check(github, context, "success")

0 commit comments

Comments
 (0)