diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 4c7fc2d..142e725 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -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 }} @@ -20,7 +24,7 @@ concurrency: jobs: transcription: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: # do not stop on another job's failure @@ -78,7 +82,7 @@ jobs: - name: Checkout app uses: actions/checkout@v4 with: - path: ${{ env.APP_NAME }} + path: ${{ env.APP_ID }} - name: Checkout AppAPI uses: actions/checkout@v4 @@ -105,38 +109,47 @@ 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 &> 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\":\"${{ steps.appinfo.outputs.result }}\",\"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