From 000cf3559343635cb491874c76ff32e4f3c4f039 Mon Sep 17 00:00:00 2001 From: zhenghaoz Date: Sat, 6 Aug 2022 08:14:26 +0800 Subject: [PATCH] publish on release (#1) --- .github/workflows/ci.yml | 2 +- .github/workflows/pypi-release.yml | 5 +-- tests/docker-compose.yml | 50 ++---------------------------- tests/test_gorse.py | 14 +++++---- 4 files changed, 12 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c0c324..73d3438 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 12698b5..d6ff85f 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -1,8 +1,5 @@ name: Publish to PyPI -on: - push: - branches: - - main +on: release jobs: publish: runs-on: ubuntu-latest diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 10f5e8f..b5047ee 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -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 @@ -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: diff --git a/tests/test_gorse.py b/tests/test_gorse.py index c52606f..ae0a90f 100644 --- a/tests/test_gorse.py +++ b/tests/test_gorse.py @@ -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 @@ -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( @@ -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) @@ -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'] @@ -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}] @@ -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()},