Skip to content

Commit 3112582

Browse files
committed
Add strategy matrix to test GitHub Action
1 parent c8d1a07 commit 3112582

File tree

2 files changed

+57
-30
lines changed

2 files changed

+57
-30
lines changed

.github/workflows/tests.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,41 @@ name: Tests
22
on:
33
workflow_call:
44
workflow_dispatch:
5+
56
jobs:
67
test:
78
runs-on: ubuntu-latest
8-
container:
9-
image: python:3.12-slim
10-
env:
11-
YEPCODE_API_TOKEN: ${{ secrets.TEST_YEPCODE_API_TOKEN }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
python-version: ["3.11", "3.12", "3.13"]
13+
1214
steps:
1315
- uses: actions/checkout@v4
16+
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Install system dependencies
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y curl gcc g++
26+
1427
- name: Configure poetry
15-
run: |-
16-
apt update && apt install -y curl gcc g++ && curl -sSL https://install.python-poetry.org | python3 -
28+
run: |
29+
curl -sSL https://install.python-poetry.org | python3 -
1730
export PATH="${PATH}:${HOME}/.local/bin"
1831
echo "${HOME}/.local/bin" >> $GITHUB_PATH
1932
poetry install
33+
env:
34+
YEPCODE_API_TOKEN: ${{ secrets.TEST_YEPCODE_API_TOKEN }}
35+
2036
- name: Run pytest
2137
run: "poetry run pytest"
38+
env:
39+
YEPCODE_API_TOKEN: ${{ secrets.TEST_YEPCODE_API_TOKEN }}
40+
2241
- name: Build
2342
run: "poetry build"

tests/test_yepcode_run.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ def test_manage_env_vars(yep_code_env):
4545

4646

4747
def test_run_javascript_code(yep_code_run):
48+
random_comment = f"// random comment to avoid parallel executions conflict {random_hex()}"
4849
execution = yep_code_run.run(
49-
"""async function main() {
50-
const message = `Hello, ${process.env.WORLD_ENV_VAR}!`
50+
f"""async function main() {{
51+
{random_comment}
52+
const message = `Hello, ${{process.env.WORLD_ENV_VAR}}!`
5153
console.log(message)
52-
return { message }
53-
}
54+
return {{ message }}
55+
}}
5456
55-
module.exports = {
57+
module.exports = {{
5658
main,
57-
};""",
59+
}};""",
5860
{"removeOnDone": True},
5961
)
6062
execution.wait_for_done()
@@ -63,13 +65,15 @@ def test_run_javascript_code(yep_code_run):
6365

6466

6567
def test_run_python_code(yep_code_run):
68+
random_comment = f"# random comment to avoid parallel executions conflict {random_hex()}"
6669
execution = yep_code_run.run(
67-
"""import os
70+
f"""import os
6871
6972
def main():
70-
message = f"Hello, {os.getenv('WORLD_ENV_VAR')}!"
73+
{random_comment}
74+
message = f"Hello, {{os.getenv('WORLD_ENV_VAR')}}!"
7175
print(message)
72-
return {"message": message}""",
76+
return {{"message": message}}""",
7377
{"removeOnDone": True},
7478
)
7579
execution.wait_for_done()
@@ -79,14 +83,16 @@ def main():
7983

8084
def test_trigger_on_log(yep_code_run):
8185
logs = []
86+
random_comment = f"// random comment to avoid parallel executions conflict {random_hex()}"
8287
execution = yep_code_run.run(
83-
"""async function main() {
88+
f"""async function main() {{
89+
{random_comment}
8490
console.log("Log message 1")
8591
console.log("Log message 2")
86-
return { success: true }
87-
}
92+
return {{ success: true }}
93+
}}
8894
89-
module.exports = { main };""",
95+
module.exports = {{ main }};""",
9096
{
9197
"removeOnDone": True,
9298
"onLog": lambda log_entry: logs.append(log_entry.message),
@@ -106,11 +112,11 @@ def on_finish(return_value):
106112
finish_value = return_value
107113

108114
execution = yep_code_run.run(
109-
"""async function main() {
110-
return { data: "test data" }
111-
}
115+
f"""async function main() {{
116+
return {{ data: "test data" }}
117+
}}
112118
113-
module.exports = { main };""",
119+
module.exports = {{ main }};""",
114120
{"removeOnDone": True, "onFinish": on_finish},
115121
)
116122

@@ -120,17 +126,18 @@ def on_finish(return_value):
120126

121127
def test_trigger_on_error(yep_code_run):
122128
error_message = None
123-
129+
random_comment = f"// random comment to avoid parallel executions conflict {random_hex()}"
124130
def on_error(error):
125131
nonlocal error_message
126132
error_message = error["message"]
127133

128134
execution = yep_code_run.run(
129-
"""async function main() {
135+
f"""async function main() {{
136+
{random_comment}
130137
throw new Error("Test error");
131-
}
138+
}}
132139
133-
module.exports = { main };""",
140+
module.exports = {{ main }};""",
134141
{"removeOnDone": True, "onError": on_error},
135142
)
136143

@@ -141,16 +148,17 @@ def on_error(error):
141148
def test_handle_all_events_python(yep_code_run):
142149
logs = []
143150
finish_value = None
144-
151+
random_comment = f"# random comment to avoid parallel executions conflict {random_hex()}"
145152
def on_finish(return_value):
146153
nonlocal finish_value
147154
finish_value = return_value
148155

149156
execution = yep_code_run.run(
150-
"""def main():
157+
f"""def main():
158+
{random_comment}
151159
print("Log message 1")
152160
print("Log message 2")
153-
return {"data": "python test"}""",
161+
return {{"data": "python test"}}""",
154162
{
155163
"language": "python",
156164
"removeOnDone": True,

0 commit comments

Comments
 (0)