Skip to content

Commit e83385c

Browse files
api-clients-generation-pipeline[bot]zippolyteci.datadog-api-spec
authored
Get integration test status check from client repos (#164)
* 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 e07d954 commit e83385c

File tree

4 files changed

+63
-5
lines changed

4 files changed

+63
-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:58:28.779340",
8-
"spec_repo_commit": "6c05087"
7+
"regenerated": "2021-06-03 12:21:48.506020",
8+
"spec_repo_commit": "379360f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev8",
12-
"regenerated": "2021-06-03 07:59:08.538870",
13-
"spec_repo_commit": "6c05087"
12+
"regenerated": "2021-06-03 12:22:38.149329",
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 Node 14
3653
uses: actions/setup-node@v2
3754
with:
@@ -49,3 +66,19 @@ jobs:
4966
DD_TEST_CLIENT_APP_KEY: ${{ secrets.DD_CLIENT_APP_KEY }}
5067
DD_TRACE_ANALYTICS_ENABLED: "true"
5168
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")

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ examples
1212
!cucumber.js
1313
!bin/check-licenses.js
1414
!.eslintrc.js
15+
!.github/workflows/scripts/*

0 commit comments

Comments
 (0)