Skip to content

Commit

Permalink
publish on release (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaoz authored Aug 6, 2022
1 parent 3d045d3 commit 000cf35
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: jtalk/url-health-check-action@v2
with:
# Check the following URLs one by one sequentially
url: http://127.0.0.1:8088/metrics|http://127.0.0.1:8087/metrics|http://127.0.0.1:8089/metrics
url: http://127.0.0.1:8088/metrics
# Fail this action after this many failed attempts
max-attempts: 5
# Delay between retries
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Publish to PyPI
on:
push:
branches:
- main
on: release
jobs:
publish:
runs-on: ubuntu-latest
Expand Down
50 changes: 2 additions & 48 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,9 @@ services:
MYSQL_DATABASE: gorse
MYSQL_USER: gorse
MYSQL_PASSWORD: gorse_pass
volumes:
- mysql_data:/var/lib/mysql

worker:
image: zhenghaoz/gorse-worker:nightly
restart: unless-stopped
ports:
- 8089:8089
command: >
--master-host master --master-port 8086
--http-host 0.0.0.0 --http-port 8089
--log-path /var/log/gorse/worker.log
--cache-path /var/lib/gorse/worker_cache.data
volumes:
- gorse_log:/var/log/gorse
- worker_data:/var/lib/gorse
depends_on:
- master

server:
image: zhenghaoz/gorse-server:nightly
restart: unless-stopped
ports:
- 8087:8087
environment:
GORSE_CACHE_STORE: redis://redis:6379
GORSE_DATA_STORE: mysql://gorse:gorse_pass@tcp(mysql:3306)/gorse?parseTime=true
command: >
--master-host master --master-port 8086
--http-host 0.0.0.0 --http-port 8087
--log-path /var/log/gorse/server.log
--cache-path /var/lib/gorse/server_cache.data
volumes:
- gorse_log:/var/log/gorse
- server_data:/var/lib/gorse
depends_on:
- master

master:
image: zhenghaoz/gorse-master:nightly
gorse:
image: zhenghaoz/gorse-in-one:nightly
restart: unless-stopped
ports:
- 8086:8086
Expand All @@ -69,15 +32,6 @@ services:
--cache-path /var/lib/gorse/master_cache.data
volumes:
- ./config.toml:/etc/gorse/config.toml
- gorse_log:/var/log/gorse
- master_data:/var/lib/gorse
depends_on:
- redis
- mysql

volumes:
mysql_data:
worker_data:
server_data:
master_data:
gorse_log:
14 changes: 8 additions & 6 deletions tests/test_gorse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import redis
from gorse import Gorse, GorseException

GORSE_ENDPOINT = 'http://127.0.0.1:8088'


def test_users():
client = Gorse('http://127.0.0.1:8087', 'zhenghaoz')
client = Gorse(GORSE_ENDPOINT, 'zhenghaoz')
# Insert a user.
r = client.insert_user({'UserId': '100', 'Labels': ['a', 'b', 'c'], 'Subscribe': ['d', 'e'], 'Comment': 'comment'})
assert r['RowAffected'] == 1
Expand All @@ -23,7 +25,7 @@ def test_users():


def test_items():
client = Gorse('http://127.0.0.1:8087', 'zhenghaoz')
client = Gorse(GORSE_ENDPOINT, 'zhenghaoz')
timestamp = datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
# Insert an item.
r = client.insert_item(
Expand All @@ -46,7 +48,7 @@ def test_items():


def test_feedback():
client = Gorse('http://127.0.0.1:8087', 'zhenghaoz')
client = Gorse(GORSE_ENDPOINT, 'zhenghaoz')
timestamp = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
# Insert a feedback
r = client.insert_feedback('like', '100', '100', timestamp)
Expand All @@ -69,7 +71,7 @@ def test_recommend():
r = redis.Redis(host='127.0.0.1', port=6379, db=0)
r.zadd('offline_recommend/100', {'1': 1, '2': 2, '3': 3})

client = Gorse('http://127.0.0.1:8087', 'zhenghaoz')
client = Gorse(GORSE_ENDPOINT, 'zhenghaoz')
recommend = client.get_recommend('100')
assert recommend == ['3', '2', '1']

Expand All @@ -78,7 +80,7 @@ def test_neighbors():
r = redis.Redis(host='127.0.0.1', port=6379, db=0)
r.zadd('item_neighbors/100', {'1': 1, '2': 2, '3': 3})

client = Gorse('http://127.0.0.1:8087', 'zhenghaoz')
client = Gorse(GORSE_ENDPOINT, 'zhenghaoz')
items = client.get_neighbors('100')
assert items == [{'Id': '3', 'Score': 3}, {'Id': '2', 'Score': 2}, {'Id': '1', 'Score': 1}]

Expand All @@ -90,7 +92,7 @@ def test_session_recommend():
r.zadd('item_neighbors/3', {"4": 100000, "7": 1, "8": 1, "9": 1})
r.zadd('item_neighbors/4', {"1": 100000, "6": 1, "7": 1, "8": 1, "9": 1})

client = Gorse('http://127.0.0.1:8087', 'zhenghaoz')
client = Gorse(GORSE_ENDPOINT, 'zhenghaoz')
recommend = client.session_recommend([
{"FeedbackType": "like", "UserId": "0", "ItemId": "1",
"Timestamp": datetime(2010, 1, 1, 1, 1, 1, 1).isoformat()},
Expand Down

0 comments on commit 000cf35

Please sign in to comment.