Skip to content

Commit f3f537d

Browse files
authored
ci: Gha 9895 (#809)
* ci: fix * ci: fix * ci : fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix
1 parent f9a32d4 commit f3f537d

14 files changed

+361
-22
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support documentation.
4+
# This workflow will download a prebuilt Python version, install dependencies and run integration tests
5+
6+
name: Run Integration Tests
7+
8+
on:
9+
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
jobs:
14+
integration_test:
15+
name: Build and Run Integration Tests on Python ${{ matrix.python-version }} and ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
python-version: ['3.8']
20+
os: [ubuntu-latest]
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v2
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Install Python dependencies (ubuntu)
31+
run: |
32+
pip3 install -r requirements.txt
33+
pip3 install -r requirements-dev.txt
34+
pip3 install --editable .
35+
36+
- name: Execute Python integration tests
37+
# continue-on-error: true
38+
env:
39+
NATURAL_LANGUAGE_CLASSIFIER_URL: "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com"
40+
NATURAL_LANGUAGE_CLASSIFIER_APIKEY: ${{ secrets.NLC_APIKEY }}
41+
LANGUAGE_TRANSLATOR_APIKEY: ${{ secrets.LT_APIKEY }}
42+
LANGUAGE_TRANSLATOR_URL: "https://api.us-south.language-translator.watson.cloud.ibm.com"
43+
NATURAL_LANGUAGE_UNDERSTANDING_APIKEY: ${{ secrets.NLU_APIKEY }}
44+
NATURAL_LANGUAGE_UNDERSTANDING_URL: "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com"
45+
PERSONALITY_INSIGHTS_APIKEY: ${{ secrets.PI_APIKEY }}
46+
PERSONALITY_INSIGHTS_URL: "https://api.us-south.personality-insights.watson.cloud.ibm.com"
47+
TONE_ANALYZER_APIKEY: ${{ secrets.TA_APIKEY }}
48+
TONE_ANALYZER_URL: "https://api.us-south.tone-analyzer.watson.cloud.ibm.com"
49+
SPEECH_TO_TEXT_APIKEY: ${{ secrets.STT_APIKEY }}
50+
SPEECH_TO_TEXT_URL: "https://api.us-south.speech-to-text.watson.cloud.ibm.com"
51+
TEXT_TO_SPEECH_APIKEY: ${{ secrets.TTS_APIKEY }}
52+
TEXT_TO_SPEECH_URL: "https://api.us-south.text-to-speech.watson.cloud.ibm.com"
53+
VISUAL_RECOGNITION_APIKEY: ${{ secrets.VR_APIKEY }}
54+
VISUAL_RECOGNITION_COLLECTION_ID: ${{ secrets.VR_COLLECTION_ID }}
55+
VISUAL_RECOGNITION_URL: "https://api.us-south.visual-recognition.watson.cloud.ibm.com"
56+
COMPARE_COMPLY_APIKEY: ${{ secrets.CC_APIKEY }}
57+
COMPARE_COMPLY_FEEDBACK_ID: ${{ secrets.CC_FEEDBACK_ID }}
58+
COMPARE_COMPLY_URL: "https://api.us-south.compare-comply.watson.cloud.ibm.com"
59+
ASSISTANT_APIKEY: ${{ secrets.WA_APIKEY }}
60+
ASSISTANT_WORKSPACE_ID: ${{ secrets.WA_WORKSPACE_ID }}
61+
ASSISTANT_ASSISTANT_ID: ${{ secrets.WA_ASSISTANT_ID }}
62+
ASSISTANT_URL: "https://api.us-south.assistant.watson.cloud.ibm.com"
63+
DISCOVERY_APIKEY: ${{ secrets.D1_APIKEY }}
64+
DISCOVERY_ENVIRONMENT_ID: ${{ secrets.D1_ENVIRONMENT_ID }}
65+
DISCOVERY_COLLECTION_ID: ${{ secrets.D1_COLLECTION_ID }}
66+
DISCOVERY_URL: "https://api.us-south.discovery.watson.cloud.ibm.com"
67+
DISCOVERY_V2_APIKEY: ${{ secrets.D2_APIKEY }}
68+
DISCOVERY_V2_PROJECT_ID: ${{ secrets.D2_PROJECT_ID }}
69+
DISCOVERY_V2_COLLECTION_ID: ${{ secrets.D2_COLLECTION_ID }}
70+
DISCOVERY_V2_URL: "https://api.us-south.discovery.watson.cloud.ibm.com"
71+
run: |
72+
pip3 install -U python-dotenv
73+
pytest test/integration/test_assistant_v1.py -rap
74+
pytest test/integration/test_compare_comply_v1.py -rap
75+
pytest test/integration/test_discovery_v1.py -rap
76+
pytest test/integration/test_discovery_v2.py -rap
77+
pytest test/integration/test_language_translator_v3.py -rap
78+
pytest test/integration/test_natural_language_classifier_v1.py -rap
79+
pytest test/integration/test_natural_language_understanding_v1.py -rap
80+
pytest test/integration/test_personality_insights_v3.py -rap
81+
pytest test/integration/test_speech_to_text_v1.py -rap
82+
pytest test/integration/test_text_to_speech_v1.py -rap
83+
pytest test/integration/test_tone_analyzer_v3.py -rap
84+
pytest test/integration/test_visual_recognition_v3.py -rap
85+
pytest test/integration/test_visual_recognition_v4.py -rap
86+
87+
# Do not notify on success. We will leave the code here just in case we decide to switch gears
88+
- name: Notify slack on success
89+
if: false # success()
90+
env:
91+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
92+
uses: voxmedia/github-action-slack-notify-build@v1
93+
with:
94+
channel: watson-e2e-tests
95+
status: SUCCESS
96+
color: good
97+
98+
- name: Notify slack on failure
99+
if: false # failure()
100+
env:
101+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
102+
uses: voxmedia/github-action-slack-notify-build@v1
103+
with:
104+
channel: watson-e2e-tests
105+
status: FAILED
106+
color: danger
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# coding: utf-8
2+
from unittest import TestCase
3+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator, BearerTokenAuthenticator
4+
from os.path import abspath
5+
import os
6+
import ibm_watson
7+
import pytest
8+
import json
9+
10+
@pytest.mark.skipif(os.getenv('ASSISTANT_APIKEY') is None,
11+
reason='requires ASSISTANT_APIKEY')
12+
class TestAssistantV1(TestCase):
13+
14+
@classmethod
15+
def setup_class(cls):
16+
17+
create_workspace_data = {
18+
"name":
19+
"test_workspace",
20+
"description":
21+
"integration tests",
22+
"language":
23+
"en",
24+
"intents": [{
25+
"intent": "hello",
26+
"description": "string",
27+
"examples": [{
28+
"text": "good morning"
29+
}]
30+
}],
31+
"entities": [{
32+
"entity": "pizza_toppings",
33+
"description": "Tasty pizza toppings",
34+
"metadata": {
35+
"property": "value"
36+
}
37+
}],
38+
"counterexamples": [{
39+
"text": "string"
40+
}],
41+
"metadata": {},
42+
}
43+
44+
authenticator = IAMAuthenticator(os.getenv('ASSISTANT_APIKEY'))
45+
cls.assistant = ibm_watson.AssistantV1(
46+
version='2018-07-10',
47+
authenticator=authenticator
48+
)
49+
cls.assistant.set_default_headers({
50+
'X-Watson-Learning-Opt-Out': '1',
51+
'X-Watson-Test': '1'
52+
})
53+
54+
response = cls.assistant.create_workspace(
55+
name=create_workspace_data['name'],
56+
description=create_workspace_data['description'],
57+
language='en',
58+
intents=create_workspace_data['intents'],
59+
entities=create_workspace_data['entities'],
60+
counterexamples=create_workspace_data['counterexamples'],
61+
metadata=create_workspace_data['metadata']).get_result()
62+
63+
cls.workspace_id = response['workspace_id']
64+
65+
examples = [{"text": "good morning"}]
66+
response = cls.assistant.create_intent(
67+
workspace_id=cls.workspace_id,
68+
intent='test_intent',
69+
description='Test intent.',
70+
examples=examples).get_result()
71+
72+
@classmethod
73+
def teardown_class(cls):
74+
response = cls.assistant.delete_intent(workspace_id=cls.workspace_id, intent='updated_test_intent').get_result()
75+
assert response is not None
76+
77+
response = cls.assistant.delete_workspace(cls.workspace_id).get_result()
78+
assert response is not None
79+
80+
def test_workspace(self):
81+
response = self.assistant.get_workspace(self.workspace_id, export=True).get_result()
82+
assert response is not None
83+
84+
response = self.assistant.list_workspaces().get_result()
85+
assert response is not None
86+
print(json.dumps(response, indent=2))
87+
88+
response = self.assistant.message(self.workspace_id,
89+
input={
90+
'text': 'What\'s the weather like?'
91+
},
92+
context={
93+
'metadata': {
94+
'deployment': 'myDeployment'
95+
}
96+
}).get_result()
97+
assert response is not None
98+
99+
response = self.assistant.update_workspace(workspace_id=self.workspace_id, description='Updated test workspace.').get_result()
100+
assert response is not None
101+
102+
def test_intent(self):
103+
response = self.assistant.get_intent(
104+
workspace_id=self.workspace_id, intent='test_intent', export=True).get_result()
105+
assert response is not None
106+
107+
response = self.assistant.update_intent(
108+
workspace_id=self.workspace_id,
109+
intent='test_intent',
110+
new_intent='updated_test_intent',
111+
new_description='Updated test intent.').get_result()
112+
assert response is not None
113+
114+
response = self.assistant.list_intents(
115+
workspace_id=self.workspace_id, export=True).get_result()
116+
assert response is not None
117+
print(json.dumps(response, indent=2))

test/integration/test_compare_comply_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from ibm_watson.compare_comply_v1 import TableReturn
88

99

10-
@pytest.mark.skipif(os.getenv('VCAP_SERVICES') is None,
11-
reason='requires VCAP_SERVICES')
10+
@pytest.mark.skipif(os.getenv('COMPARE_COMPLY_APIKEY') is None,
11+
reason='requires COMPARE_COMPLY_APIKEY')
1212
class IntegrationTestCompareComplyV1(TestCase):
1313
compare_comply = None
1414

test/integration/test_discovery_v1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import pytest
77

88

9-
@pytest.mark.skipif(os.getenv('VCAP_SERVICES') is None,
10-
reason='requires VCAP_SERVICES')
9+
@pytest.mark.skipif(os.getenv('DISCOVERY_APIKEY') is None,
10+
reason='requires DISCOVERY_APIKEY')
1111
class Discoveryv1(TestCase):
1212
discovery = None
13-
environment_id = '62b0dd87-eefa-40bf-81d6-cf9bc82692ab' # This environment is created for integration testing
13+
environment_id = os.getenv('DISCOVERY_ENVIRONMENT_ID') # This environment is created for integration testing
1414
collection_id = None
1515
collection_name = 'FOR-PYTHON-DELETE-ME'
1616

test/integration/test_discovery_v2.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
import pytest
99

1010

11-
@pytest.mark.skipif(os.getenv('TEST_DISCO_V2') is None,
12-
reason='only test in cpd and prem')
11+
@pytest.mark.skipif(os.getenv('DISCOVERY_V2_APIKEY') is None,
12+
reason='requires DISCOVERY_V2_APIKEY')
1313
class Discoveryv2(TestCase):
1414
discovery = None
15-
project_id = 'f0b9920b-caa8-4b89-abf7-e250989eee5a' # This project is created for integration testing
15+
project_id = os.getenv('DISCOVERY_V2_PROJECT_ID') # This project is created for integration testing
1616
collection_id = None
1717
collection_name = 'python_test_collection'
1818

1919
@classmethod
2020
def setup_class(cls):
21-
authenticator = IAMAuthenticator('apikey')
21+
authenticator = IAMAuthenticator(os.getenv('DISCOVERY_V2_APIKEY'))
2222
cls.discovery = ibm_watson.DiscoveryV2(
2323
version='2020-08-12',
2424
authenticator=authenticator
2525
)
26-
cls.discovery.set_service_url('url')
26+
cls.discovery.set_service_url(os.getenv('DISCOVERY_V2_URL'))
2727
cls.discovery.set_default_headers({
2828
'X-Watson-Learning-Opt-Out': '1',
2929
'X-Watson-Test': '1'
@@ -111,6 +111,7 @@ def test_enrichments(self):
111111
)
112112

113113
# can only test in CPD
114+
@pytest.mark.skip(reason="can only test in CPD")
114115
def test_analyze(self):
115116
authenticator = BearerTokenAuthenticator('<bearer_token>')
116117
discovery_cpd = ibm_watson.DiscoveryV2(

test/integration/test_language_translator_v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import os
77

88

9-
@pytest.mark.skipif(os.getenv('VCAP_SERVICES') is None,
10-
reason='requires VCAP_SERVICES')
9+
@pytest.mark.skipif(os.getenv('LANGUAGE_TRANSLATOR_APIKEY') is None,
10+
reason='requires LANGUAGE_TRANSLATOR_APIKEY')
1111
class TestIntegrationLanguageTranslatorV3(unittest.TestCase):
1212

1313
@classmethod

test/integration/test_natural_language_classifier_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
FIVE_SECONDS = 5
1010

1111

12-
@pytest.mark.skipif(os.getenv('VCAP_SERVICES') is None,
13-
reason='requires VCAP_SERVICES')
12+
@pytest.mark.skipif(os.getenv('NATURAL_LANGUAGE_CLASSIFIER_APIKEY') is None,
13+
reason='requires NATURAL_LANGUAGE_CLASSIFIER_APIKEY')
1414
class TestNaturalLanguageClassifierV1(TestCase):
1515

1616
def setUp(self):
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# coding: utf-8
2+
from unittest import TestCase
3+
import os
4+
import ibm_watson
5+
import pytest
6+
import json
7+
import time
8+
from ibm_watson.natural_language_understanding_v1 import Features, EntitiesOptions, KeywordsOptions
9+
10+
@pytest.mark.skipif(os.getenv('NATURAL_LANGUAGE_UNDERSTANDING_APIKEY') is None,
11+
reason='requires NATURAL_LANGUAGE_UNDERSTANDING_APIKEY')
12+
class TestNaturalLanguageUnderstandingV1(TestCase):
13+
14+
def setUp(self):
15+
self.natural_language_understanding = ibm_watson.NaturalLanguageUnderstandingV1(version='2018-03-16')
16+
self.natural_language_understanding.set_default_headers({
17+
'X-Watson-Learning-Opt-Out': '1',
18+
'X-Watson-Test': '1'
19+
})
20+
21+
def test_analyze(self):
22+
response = self.natural_language_understanding.analyze(
23+
text='Bruce Banner is the Hulk and Bruce Wayne is BATMAN! '
24+
'Superman fears not Banner, but Wayne.',
25+
features=Features(entities=EntitiesOptions(), keywords=KeywordsOptions())).get_result()
26+
assert response is not None
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# coding: utf-8
2+
from unittest import TestCase
3+
import os
4+
import ibm_watson
5+
import pytest
6+
import json
7+
import time
8+
from os.path import join
9+
10+
@pytest.mark.skipif(os.getenv('PERSONALITY_INSIGHTS_APIKEY') is None,
11+
reason='requires PERSONALITY_INSIGHTS_APIKEY')
12+
class TestPersonalityInsightsV3(TestCase):
13+
14+
def setUp(self):
15+
self.personality_insights = ibm_watson.PersonalityInsightsV3(version='2017-10-13')
16+
self.personality_insights.set_default_headers({
17+
'X-Watson-Learning-Opt-Out': '1',
18+
'X-Watson-Test': '1'
19+
})
20+
21+
def test_profile1(self):
22+
with open(join(os.getcwd(), 'resources/personality-v3.json')) as \
23+
profile_json:
24+
profile = self.personality_insights.profile(
25+
profile_json.read(),
26+
'application/json',
27+
raw_scores=True,
28+
consumption_preferences=True).get_result()
29+
assert profile is not None

test/integration/test_speech_to_text_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import threading
77

88

9-
@pytest.mark.skipif(os.getenv('VCAP_SERVICES') is None,
10-
reason='requires VCAP_SERVICES')
9+
@pytest.mark.skipif(os.getenv('SPEECH_TO_TEXT_APIKEY') is None,
10+
reason='requires SPEECH_TO_TEXT_APIKEY')
1111
class TestSpeechToTextV1(TestCase):
1212
text_to_speech = None
1313
custom_models = None

0 commit comments

Comments
 (0)