Skip to content

Commit 3a99de8

Browse files
api-clients-generation-pipeline[bot]jirikuncarci.datadog-api-spec
authored
ci: report status of unit tests (#498)
* ci: report status for unit tests * format * use job status * add missing test type * Regenerate client from commit 6fd5e2f of spec repo Co-authored-by: Jiri Kuncar <[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 e2f322d commit 3a99de8

File tree

4 files changed

+110
-85
lines changed

4 files changed

+110
-85
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-28 16:37:38.437354",
8-
"spec_repo_commit": "49e5f63"
7+
"regenerated": "2021-06-29 10:15:19.603968",
8+
"spec_repo_commit": "6fd5e2f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev8",
12-
"regenerated": "2021-06-28 16:38:06.418638",
13-
"spec_repo_commit": "49e5f63"
12+
"regenerated": "2021-06-29 10:15:47.477187",
13+
"spec_repo_commit": "6fd5e2f"
1414
}
1515
}
1616
}

.github/workflows/scripts/test_integration.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const SPEC_REPO = "datadog-api-spec"
22

3-
module.exports.post_status_check = async (github, context, status) => {
3+
module.exports.post_status_check = async (github, context, test, status) => {
44
const pr_num = context.payload.pull_request.head.ref.split("/")[2]
55
const {data: pr} = await github.pulls.get({
66
owner: context.repo.owner,
@@ -18,7 +18,7 @@ module.exports.post_status_check = async (github, context, status) => {
1818
sha: pr.head.sha,
1919
state: status,
2020
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`
21+
description: `${context.repo.repo} ${test} tests`,
22+
context: `${context.repo.repo}_${test}_tests`
2323
});
2424
}

.github/workflows/test.yml

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ jobs:
1414
runs-on: ubuntu-latest
1515
if: false == startsWith(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && !contains(github.event.pull_request.labels.*.name, 'ci/skip/pre-commit')
1616
steps:
17-
- uses: actions/checkout@v1
18-
- uses: actions/setup-python@v1
19-
- name: Install pre-commit
20-
run: python -m pip install pre-commit
21-
- name: set PY
22-
run: echo "PY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
23-
- uses: actions/cache@v1
24-
with:
25-
path: ~/.cache/pre-commit
26-
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
27-
- name: Run pre-commit
28-
run: pre-commit run --all-files --source ${{ github.event.pull_request.base.sha }} --origin ${{ github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
17+
- uses: actions/checkout@v1
18+
- uses: actions/setup-python@v1
19+
- name: Install pre-commit
20+
run: python -m pip install pre-commit
21+
- name: set PY
22+
run: echo "PY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
23+
- uses: actions/cache@v1
24+
with:
25+
path: ~/.cache/pre-commit
26+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
27+
- name: Run pre-commit
28+
run: pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
2929

3030
test:
3131
strategy:
3232
matrix:
3333
python-version: [3.6, 3.7, 3.8]
34-
platform: [ubuntu-latest, macos-latest] # windows-latest
34+
platform: [ubuntu-latest, macos-latest] # windows-latest
3535
# test only latest version on macos and windows
3636
exclude:
3737
- platform: macos-latest
@@ -46,13 +46,38 @@ jobs:
4646
runs-on: ${{ matrix.platform }}
4747
if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci/skip') && !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/')
4848
steps:
49-
- uses: actions/checkout@v2
50-
- name: Set up Python ${{ matrix.python-version }}
51-
uses: actions/setup-python@v2
52-
with:
53-
python-version: ${{ matrix.python-version }}
54-
- name: Install
55-
run: pip install --disable-pip-version-check -e .[tests]
56-
- name: Test
57-
run: ./run-tests.sh
58-
shell: bash
49+
- uses: actions/checkout@v2
50+
- name: Set up Python ${{ matrix.python-version }}
51+
uses: actions/setup-python@v2
52+
with:
53+
python-version: ${{ matrix.python-version }}
54+
- name: Install
55+
run: pip install --disable-pip-version-check -e .[tests]
56+
- name: Test
57+
run: ./run-tests.sh
58+
shell: bash
59+
60+
report:
61+
runs-on: ubuntu-latest
62+
if: always() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
63+
needs: test
64+
steps:
65+
- name: Get GitHub App token
66+
if: github.event_name == 'pull_request'
67+
id: get_token
68+
uses: tibdex/[email protected]
69+
with:
70+
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
71+
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
72+
repository: DataDog/datadog-api-spec
73+
- name: Checkout code
74+
uses: actions/checkout@v2
75+
- name: Post status check
76+
uses: actions/[email protected]
77+
env:
78+
JOB_STATUS: ${{ needs.test.result }}
79+
with:
80+
github-token: ${{ steps.get_token.outputs.token }}
81+
script: |
82+
const script = require('./.github/workflows/scripts/test_integration.js')
83+
await script.post_status_check(github, context, "unit", process.env.JOB_STATUS)

.github/workflows/test_integration.yml

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -31,58 +31,58 @@ jobs:
3131
DD_HOSTNAME: "none"
3232
DD_INSIDE_CI: "true"
3333
steps:
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' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
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")
52-
- name: Set up Python 3.8
53-
uses: actions/setup-python@v2
54-
with:
55-
python-version: 3.8
56-
- name: Install
57-
run: pip install --disable-pip-version-check -e .[apm,tests]
58-
- name: Test
59-
run: ./run-tests.sh
60-
shell: bash
61-
env:
62-
CI: "true"
63-
DD_AGENT_HOST: localhost
64-
DD_ENV: prod
65-
DD_SERVICE: datadog-api-client-python
66-
DD_TAGS: "team:integration-tools-and-libraries"
67-
DD_TEST_CLIENT_API_KEY: ${{ secrets.DD_CLIENT_API_KEY }}
68-
DD_TEST_CLIENT_APP_KEY: ${{ secrets.DD_CLIENT_APP_KEY }}
69-
DD_TRACE_ANALYTICS_ENABLED: "true"
70-
RECORD: "none"
71-
PYTEST_ADDOPTS: "--ddtrace"
72-
DD_PYTEST_OPERATION_NAME: "test"
73-
- name: Post failure status check
74-
if: failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
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' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')"
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")
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' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
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, "integration", "pending")
52+
- name: Set up Python 3.8
53+
uses: actions/setup-python@v2
54+
with:
55+
python-version: 3.8
56+
- name: Install
57+
run: pip install --disable-pip-version-check -e .[apm,tests]
58+
- name: Test
59+
run: ./run-tests.sh
60+
shell: bash
61+
env:
62+
CI: "true"
63+
DD_AGENT_HOST: localhost
64+
DD_ENV: prod
65+
DD_SERVICE: datadog-api-client-python
66+
DD_TAGS: "team:integration-tools-and-libraries"
67+
DD_TEST_CLIENT_API_KEY: ${{ secrets.DD_CLIENT_API_KEY }}
68+
DD_TEST_CLIENT_APP_KEY: ${{ secrets.DD_CLIENT_APP_KEY }}
69+
DD_TRACE_ANALYTICS_ENABLED: "true"
70+
RECORD: "none"
71+
PYTEST_ADDOPTS: "--ddtrace"
72+
DD_PYTEST_OPERATION_NAME: "test"
73+
- name: Post failure status check
74+
if: failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
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, "integration", "failure")
81+
- name: Post success status check
82+
if: "!failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')"
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, "integration", "success")

0 commit comments

Comments
 (0)