Skip to content

Commit

Permalink
ci: check translated test
Browse files Browse the repository at this point in the history
and some refactors/fixes

Signed-off-by: Anupam Kumar <[email protected]>
  • Loading branch information
kyteinsky committed Aug 5, 2024
1 parent bc1aaba commit 9d49ace
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ on:
- stable*

env:
APP_NAME: translate2
APP_ID: translate2
APP_HOST: 0.0.0.0
APP_PORT: 9081
APP_SECRET: 12345
NEXTCLOUD_URL: http://localhost:8080
COMPUTE_DEVICE: cpu

concurrency:
group: integration-test-${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -78,13 +83,14 @@ jobs:
- name: Checkout app
uses: actions/checkout@v4
with:
path: ${{ env.APP_NAME }}
path: ${{ env.APP_ID }}

- name: Checkout AppAPI
uses: actions/checkout@v4
with:
repository: cloud-py-api/app_api
path: apps/app_api
ref: v2.7.0

- name: Set up Nextcloud
if: ${{ matrix.databases != 'pgsql'}}
Expand All @@ -105,38 +111,48 @@ jobs:
- name: Enable app_api
run: ./occ app:enable -vvv -f app_api

- name: Get app version
id: appinfo
uses: skjnldsv/xpath-action@7e6a7c379d0e9abc8acaef43df403ab4fc4f770c # master
with:
filename: ${{ env.APP_ID }}/appinfo/info.xml
expression: "/info/version/text()"

- name: Setup python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
requirements.txt
${{ env.APP_ID }}/requirements.txt
- name: Install and start ex-app's server
env:
PYTHONUNBUFFERED: 1
APP_HOST: 0.0.0.0
APP_ID: translate2
APP_PORT: 9081
APP_SECRET: 12345
APP_VERSION: 1.0.0
NEXTCLOUD_URL: http://localhost:8080
working-directory: ${{ env.APP_NAME }}
working-directory: ${{ env.APP_ID }}
run: |
set -x
pip install --no-deps -r requirements.txt
python3 lib/main.py &
python3 lib/main.py 2&>1 | tee ex-app-logs &
- name: Register backend
run: |
set -x
./occ app_api:daemon:register --net host manual_install "Manual Install" manual-install http localhost http://localhost:8080
./occ app_api:app:register translate2 manual_install --json-info "{\"appid\":\"translate2\",\"name\":\"Local Machine Translation\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9081,\"scopes\":[\"AI_PROVIDERS\"],\"system_app\":0}" --force-scopes --wait-finish
./occ app_api:app:register ${{ env.APP_ID }} manual_install --json-info "{\"appid\":\"${{ env.APP_ID }}\",\"name\":\"Local Machine Translation\",\"daemon_config_name\":\"manual_install\",\"version\":\"${{ fromJson(steps.appinfo.outputs.result).version }}\",\"secret\":\"${{ env.APP_SECRET }}\",\"port\":${{ env.APP_PORT}},\"scopes\":[\"AI_PROVIDERS\"],\"system_app\":0}" --force-scopes --wait-finish
- name: Test translation
run: |
curl --header "OCS-APIRequest: true" --header "Content-Type: application/json" -X POST http://localhost:8080/ocs/v2.php/translation/translate --data '{"text":"Hallo Welt","fromLanguage":"de","toLanguage":"en"}'
set -x
response=$(curl --header "OCS-APIRequest: true" --header "Content-Type: application/json" -X POST http://localhost:8080/ocs/v2.php/translation/translate\?format\=json --data '{"text":"Hello World","fromLanguage":"null","toLanguage":"de"}')
[ "$(echo $response | jq -r '.ocs.meta.status')" == "OK" ]
translation=$(echo $response | jq -r '.ocs.data.text')
[ "$translation" == "Hallo Welt!" ]
- name: Show log on failure
- name: Show logs
if: always()
run: |
tail data/nextcloud.log
NC_debug=true ./occ migrations:status app_api
cat data/nextcloud.log
cat ex-app-logs

0 comments on commit 9d49ace

Please sign in to comment.