forked from airbytehq/airbyte-python-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (142 loc) · 5.08 KB
/
test-command.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: On-Demand Test
on:
workflow_dispatch:
inputs:
pr:
description: "PR Number"
type: string
required: true
comment-id:
description: "Comment ID (Optional)"
type: string
required: false
jobs:
start-workflow:
name: Append 'Starting' Comment
runs-on: ubuntu-24.04
steps:
- name: Get PR JSON
id: pr-info
env:
GH_TOKEN: ${{ github.token }}
run: |
PR_JSON=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.inputs.pr }}")
echo "$PR_JSON" > pr-info.json
echo "sha=$(jq -r .head.sha < pr-info.json)" >> "$GITHUB_OUTPUT"
echo "run-url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_OUTPUT"
- name: Upload PR details as artifact
uses: actions/upload-artifact@v4
with:
name: pr-info
path: pr-info.json
- name: Append comment with job run link
id: first-comment-action
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ github.event.inputs.comment-id }}
issue-number: ${{ github.event.inputs.pr }}
body: |
> PR test job started... [Check job output.][1]
[1]: ${{ steps.pr-info.outputs.run-url }}
# This is copied from the `python_pytest.yml` file.
# Only the first two steps of the job are different, and they check out the PR's branch.
pytest-on-demand:
name: On-Demand PR Pytest (All, Python ${{ matrix.python-version }}, ${{ matrix.os }})
needs: [start-workflow]
strategy:
matrix:
python-version: ["3.10", "3.11"]
os: [
Ubuntu,
# Windows, # For now, we don't include Windows in the test matrix.
]
fail-fast: false
runs-on: "${{ matrix.os }}-latest"
env:
# Enforce UTF-8 encoding so Windows runners don't fail inside the connector code.
# TODO: See if we can fully enforce this within PyAirbyte itself.
PYTHONIOENCODING: utf-8
steps:
# Custom steps to fetch the PR and checkout the code:
- name: Download PR info
# This puts the `pr-info.json` file in the current directory.
# We need this to get the PR's SHA at the time of the workflow run.
uses: actions/download-artifact@v4
with:
name: pr-info
- name: Checkout PR
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PR (${{ github.event.inputs.pr }})
uses: dawidd6/action-checkout-pr@v1
with:
pr: ${{ github.event.inputs.pr }}
# Same as the `python_pytest.yml` file:
- name: Set up Poetry
uses: Gr1N/setup-poetry@v9
with:
poetry-version: "2.0.1"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: poetry install --all-extras
- name: Run Pytest
timeout-minutes: 60
env:
GCP_GSM_CREDENTIALS: ${{ secrets.GCP_GSM_CREDENTIALS }}
run: >
poetry run pytest
--verbose
-m "not super_slow and not flaky"
- name: Run Pytest (Flaky Only)
continue-on-error: true
timeout-minutes: 60
env:
GCP_GSM_CREDENTIALS: ${{ secrets.GCP_GSM_CREDENTIALS }}
run: >
poetry run pytest
--verbose
-m "flaky and not super_slow"
- name: Post CI Success to GitHub
run: |
curl --request POST \
--url "https://api.github.com/repos/${{ github.repository }}/statuses/$(jq -r .head.sha < pr-info.json)" \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"state": "success",
"context": "Pytest (All, Python ${{ matrix.python-version }}, ${{ matrix.os }})",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
}' \
log-success-comment:
name: Append 'Success' Comment
needs: [pytest-on-demand]
runs-on: ubuntu-24.04
steps:
- name: Append success comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.inputs.pr }}
comment-id: ${{ github.event.inputs.comment-id }}
reactions: hooray
body: |
> ✅ Tests passed.
log-failure-comment:
name: Append 'Failure' Comment
# This job will only run if the workflow fails
needs: [pytest-on-demand, start-workflow]
if: always() && needs.pytest-on-demand.result == 'failure'
runs-on: ubuntu-24.04
steps:
- name: Append failure comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.inputs.pr }}
comment-id: ${{ github.event.inputs.comment-id }}
reactions: confused
body: |
> ❌ Tests failed.