Skip to content

Commit 155c505

Browse files
api-clients-generation-pipeline[bot]zippolyteci.datadog-api-spec
authored
Get integration test status check from client repos (#462)
* Post integration test status to spec PR * 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 f105f7a commit 155c505

File tree

3 files changed

+62
-5
lines changed

3 files changed

+62
-5
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:57:56.613553",
8-
"spec_repo_commit": "6c05087"
7+
"regenerated": "2021-06-03 12:20:51.193086",
8+
"spec_repo_commit": "379360f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev8",
12-
"regenerated": "2021-06-03 07:58:23.253702",
13-
"spec_repo_commit": "6c05087"
12+
"regenerated": "2021-06-03 12:21:18.028212",
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,24 @@ jobs:
3131
DD_HOSTNAME: "none"
3232
DD_INSIDE_CI: "true"
3333
steps:
34-
- uses: actions/checkout@v2
34+
- name: Get GitHub App token
35+
if: github.event_name == 'pull_request'
36+
id: get_token
37+
uses: tibdex/[email protected]
38+
with:
39+
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
40+
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
41+
repository: DataDog/datadog-api-spec
42+
- name: Checkout code
43+
uses: actions/checkout@v2
44+
- name: Post pending status check
45+
if: github.event_name == 'pull_request'
46+
uses: actions/[email protected]
47+
with:
48+
github-token: ${{ steps.get_token.outputs.token }}
49+
script: |
50+
const script = require('.github/workflows/scripts/test_integration.js')
51+
await script.post_status_check(github, context, "pending")
3552
- name: Set up Python 3.8
3653
uses: actions/setup-python@v2
3754
with:
@@ -53,3 +70,19 @@ jobs:
5370
RECORD: "none"
5471
PYTEST_ADDOPTS: "--ddtrace"
5572
DD_PYTEST_OPERATION_NAME: "test"
73+
- name: Post failure status check
74+
if: failure() && github.event_name == 'pull_request'
75+
uses: actions/[email protected]
76+
with:
77+
github-token: ${{ steps.get_token.outputs.token }}
78+
script: |
79+
const script = require('./.github/workflows/scripts/test_integration.js')
80+
await script.post_status_check(github, context, "failure")
81+
- name: Post success status check
82+
if: "!failure() && github.event_name == 'pull_request'"
83+
uses: actions/[email protected]
84+
with:
85+
github-token: ${{ steps.get_token.outputs.token }}
86+
script: |
87+
const script = require('./.github/workflows/scripts/test_integration.js')
88+
await script.post_status_check(github, context, "success")

0 commit comments

Comments
 (0)