-
Notifications
You must be signed in to change notification settings - Fork 8
164 lines (160 loc) · 6.17 KB
/
ci-test-tlm.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
156
157
158
159
160
161
162
163
164
name: /test-tlm CI
on:
issue_comment:
types: [created]
jobs:
test:
name: "TLM Test: Python ${{ matrix.python }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
if: github.event.comment.body == '/test-tlm' # Only run if the comment is "/test-tlm"
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- name: Checkout latest commit to pull request
uses: actions/checkout@v3
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install .
pip install -r tests/requirements_test.txt
- name: Install Cleanlab Studio client
run: pip install -e .
- name: Set env variables (Linux/macOS/Windows)
run: |
echo "CLEANLAB_API_BASE_URL=${{ secrets.CLEANLAB_API_BASE_URL }}" >> $GITHUB_ENV
shell: bash
- name: Cleanlab login
run: cleanlab login --key "${{ secrets.CLEANLAB_STUDIO_CI_API_KEY }}"
- name: Run tests
run: |
pytest tests/tlm/ --ignore=tests/tlm/test_properties.py --verbose
propertytest:
name: "TLM Property Test: Python ${{ matrix.python }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
if: github.event.comment.body == '/test-tlm' # Only run if the comment is "/test-tlm"
strategy:
matrix:
os:
- macos-latest
python:
- "3.11"
steps:
- name: Checkout latest commit to pull request
uses: actions/checkout@v3
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install .
pip install -r tests/requirements_test.txt
- name: Restore pytest cache
uses: actions/cache@v2
with:
path: .pytest_cache
key: pytest-cache-${{ github.run_id }}
restore-keys: pytest-cache-
- name: Install Cleanlab Studio client
run: pip install -e .
- name: Set env variables (Linux/macOS/Windows)
run: |
echo "CLEANLAB_API_BASE_URL=${{ secrets.CLEANLAB_API_BASE_URL }}" >> $GITHUB_ENV
shell: bash
- name: Cleanlab login
run: cleanlab login --key "${{ secrets.CLEANLAB_STUDIO_CI_API_KEY }}"
- name: Run tests
run: |
pytest -n auto tests/tlm/test_properties.py --verbose
- name: Cache pytest results
if: always() && github.event.comment.body == '/test-tlm' # Ensure this runs even if tests above fail
uses: actions/cache@v2
with:
path: .pytest_cache
key: pytest-cache-${{ github.run_id }}
launch-tlm-test-notif:
name: Comment TLM test start on PR
runs-on: ubuntu-latest
if: github.event.comment.body == '/test-tlm' # Only run if the comment is "/test-tlm"
steps:
- name: Log PR Number and Pull request ref
run: echo "PR Number is ${{ github.event.issue.number }}. PR ref is refs/pull/${{ github.event.issue.number }}/head."
- name: Find Comment
id: fc
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.issue.number }}
body-regex: '^/test-tlm$'
direction: last
- name: Update comment
uses: peter-evans/create-or-update-comment@v4
if: steps.fc.outputs.comment-id != ''
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
:sparkles: **Starting TLM tests...** :sparkles:
If you want to run all the TLM tests again (because TLM code is ready for review), comment '/test-tlm' on this PR.
If you want to re-run only the failed tests (you are still developing), comment '/rerun-failed-test-tlm' on this PR.
[View full GitHub Actions run log](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: rocket
finish-tlm-test-notif:
name: Comment TLM test completion on PR
runs-on: ubuntu-latest
needs:
- launch-tlm-test-notif
- test
- propertytest
if: always() && github.event.comment.body == '/test-tlm' # Only run if the comment is "/test-tlm" but still run if needs failed
continue-on-error: true
steps:
- name: Find Comment
id: fc
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.issue.number }}
body-includes: Starting TLM tests
direction: last
- name: Build Comment Body
run: |
# Set up emojis based on test results
if [[ "${{ needs.test.result }}" == "success" ]]; then
TLM_TEST_RESULT="✅"
else
TLM_TEST_RESULT="❌"
fi
if [[ "${{ needs.propertytest.result }}" == "success" ]]; then
PROPERTY_TEST_RESULT="✅"
else
PROPERTY_TEST_RESULT="❌"
fi
echo "PROPERTY_TEST_RESULT=$PROPERTY_TEST_RESULT" >> $GITHUB_ENV
echo "TLM_TEST_RESULT=$TLM_TEST_RESULT" >> $GITHUB_ENV
- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
:sparkles: **Tests completed!** :sparkles:
TLM Tests Results: ${{ env.TLM_TEST_RESULT }}${{ env.TLM_TEST_RESULT }}${{ env.TLM_TEST_RESULT }}${{ env.TLM_TEST_RESULT }}${{ env.TLM_TEST_RESULT }}
TLM Property Tests Results: ${{ env.PROPERTY_TEST_RESULT }}${{ env.PROPERTY_TEST_RESULT }}${{ env.PROPERTY_TEST_RESULT }}${{ env.PROPERTY_TEST_RESULT }}${{ env.PROPERTY_TEST_RESULT }}
Click the Github Actions run log for more information.