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 2, 2024
1 parent bc1aaba commit b8cb723
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ 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

concurrency:
group: integration-test-${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -75,17 +79,6 @@ jobs:
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_mysql, pdo_sqlite, pgsql, pdo_pgsql, gd, zip

- name: Checkout app
uses: actions/checkout@v4
with:
path: ${{ env.APP_NAME }}

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

- name: Set up Nextcloud
if: ${{ matrix.databases != 'pgsql'}}
run: |
Expand All @@ -102,41 +95,59 @@ jobs:
./occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$PGSQL_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
php -S localhost:8080 &
- name: Checkout AppAPI
uses: actions/checkout@v4
with:
repository: cloud-py-api/app_api
path: apps/app_api

- name: Enable app_api
run: ./occ app:enable -vvv -f app_api

- name: Checkout app
uses: actions/checkout@v4
with:
path: ${{ env.APP_ID }}

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

- 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: |
pip install --no-deps -r requirements.txt
python3 lib/main.py &
python3 lib/main.py &> ex-app-logs &
- name: Register backend
run: |
./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
tail -n25 data/nextcloud.log
cat ex-app-logs

0 comments on commit b8cb723

Please sign in to comment.