Skip to content

Commit 6b75c58

Browse files
authored
Fix failing apt-get install in action for unit tests (#422)
1 parent fa32b6a commit 6b75c58

File tree

5 files changed

+30
-41
lines changed

5 files changed

+30
-41
lines changed

.github/workflows/run-unittests-py38-cov-report.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,9 @@ jobs:
5757
- uses: ./.github/workflows/set-dummy-conf
5858
name: "Test config setup"
5959

60-
- name: "Test env setup"
60+
- uses: ./.github/workflows/test-env-setup
61+
name: "Test env setup"
6162
timeout-minutes: 20
62-
shell: bash
63-
run: |
64-
set -x # print commands that are executed
65-
66-
sudo apt-get install libkrb5-dev graphviz
67-
$CONDA/bin/conda init
68-
source /home/runner/.bashrc
69-
70-
pip install -r dev-requirements.txt
7163

7264
- name: "Run unitary tests folder with maximum ADS dependencies"
7365
timeout-minutes: 60

.github/workflows/run-unittests-py39-py310.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,9 @@ jobs:
5858
- uses: ./.github/workflows/set-dummy-conf
5959
name: "Test config setup"
6060

61-
- name: "Test env setup"
61+
- uses: ./.github/workflows/test-env-setup
62+
name: "Test env setup"
6263
timeout-minutes: 20
63-
shell: bash
64-
run: |
65-
set -x # print commands that are executed
66-
67-
sudo apt-get install libkrb5-dev graphviz
68-
$CONDA/bin/conda init
69-
source /home/runner/.bashrc
70-
71-
pip install -r dev-requirements.txt
7264

7365
- name: "Run unitary tests folder with maximum ADS dependencies"
7466
timeout-minutes: 60
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This composite action is to avoid duplicating code across test actions.
2+
# Ref: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
3+
4+
name: "Test env setup"
5+
description: "Creates conda test env with optional dependencies to run all unit tests"
6+
runs:
7+
using: composite
8+
steps:
9+
- shell: bash
10+
run: |
11+
set -x # print commands that are executed
12+
13+
sudo apt update
14+
sudo apt-get install libkrb5-dev graphviz
15+
$CONDA/bin/conda init
16+
source /home/runner/.bashrc
17+
18+
pip install -r dev-requirements.txt

tests/unitary/with_extras/model/test_env_info.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,6 @@ def test_get_service_packs_bad_response():
128128
assert all(slug in slugs for slug, _ in service_pack_slug_mapping.items())
129129

130130

131-
@patch("requests.request", mocked_requests_request)
132-
def test_get_service_packs_cust_tenancy():
133-
service_pack_path_mapping, service_pack_slug_mapping = get_service_packs(
134-
"ociodsccust", "service-conda-packs", None
135-
)
136-
db_pack_path = "oci://service-conda-packs@ociodsccust/service_pack/cpu/Oracle_Database_for_CPU_Python_3.7/1.0/database_p37_cpu_v1"
137-
db_slug = "database_p37_cpu_v1"
138-
db_python_version = "3.7"
139-
assert service_pack_path_mapping[db_pack_path] == (db_slug, db_python_version)
140-
assert service_pack_slug_mapping[db_slug] == (db_pack_path, db_python_version)
141-
142-
143131
class TestTrainingEnvInfo:
144132
"""Test the TrainingEnvInfo class."""
145133

@@ -181,11 +169,11 @@ def test_from_slug_prod_sp(self):
181169
def test_from_slug_not_exist(self, mock_get_service_packs):
182170
mock_get_service_packs.return_value = (
183171
{
184-
"test_path" : ("mlcpuv1", "3.6"),
172+
"test_path": ("mlcpuv1", "3.6"),
185173
},
186174
{
187-
"mlcpuv1" : ("test_path", "3.6"),
188-
}
175+
"mlcpuv1": ("test_path", "3.6"),
176+
},
189177
)
190178
with pytest.warns(UserWarning, match="not a service pack"):
191179
TrainingEnvInfo.from_slug(
@@ -269,11 +257,11 @@ def test_from_slug_prod_sp(self):
269257
def test_from_slug_not_exist(self, mock_get_service_packs):
270258
mock_get_service_packs.return_value = (
271259
{
272-
"test_path" : ("mlcpuv1", "3.6"),
260+
"test_path": ("mlcpuv1", "3.6"),
273261
},
274262
{
275-
"mlcpuv1" : ("test_path", "3.6"),
276-
}
263+
"mlcpuv1": ("test_path", "3.6"),
264+
},
277265
)
278266
with pytest.warns(UserWarning, match="not a service pack"):
279267
InferenceEnvInfo.from_slug(

tests/unitary/with_extras/opctl/test_opctl_conda.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def test_conda_publish(
101101
mock_run_cmd,
102102
monkeypatch,
103103
):
104-
105104
with tempfile.TemporaryDirectory() as td:
106105
with pytest.raises(FileNotFoundError):
107106
publish(
@@ -161,7 +160,7 @@ def test_conda_publish(
161160
): {"bind": "/home/datascience/pack.py"},
162161
},
163162
env_vars={},
164-
command="python /home/datascience/pack.py /home/datascience/test",
163+
command="python /home/datascience/pack.py --conda-path /home/datascience/test",
165164
)
166165

167166
mock_uploader.assert_called_with(
@@ -187,7 +186,7 @@ def test_conda_publish(
187186
import ads
188187

189188
mock_run_cmd.assert_called_with(
190-
f"python {os.path.join(ads.__path__[0], 'opctl', 'conda', 'pack.py')} {os.path.join(td, 'conda', 'test')}",
189+
f"python {os.path.join(ads.__path__[0], 'opctl', 'conda', 'pack.py')} --conda-path {os.path.join(td, 'conda', 'test')}",
191190
shell=True,
192191
)
193192

0 commit comments

Comments
 (0)