diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 4c7fc2d..e1e13d0 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 }} @@ -55,6 +59,18 @@ jobs: options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5 steps: + - 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: Checkout server uses: actions/checkout@v4 with: @@ -75,17 +91,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: | @@ -102,9 +107,21 @@ 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: test + run: | + set -x + pwd + ls -la + - name: Setup python 3.11 uses: actions/setup-python@v5 with: @@ -116,13 +133,7 @@ jobs: - 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 & @@ -130,13 +141,18 @@ jobs: - 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 server logs if: always() run: | tail data/nextcloud.log