Skip to content
2 changes: 1 addition & 1 deletion .github/workflows/audio-command-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
Expand Down
40 changes: 39 additions & 1 deletion .github/workflows/backgroundjob-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ jobs:
php-versions: ['7.3']
databases: ['sqlite', 'mysql', 'pgsql']
server-versions: ['stable20', 'stable21', 'stable22', 'stable23']
container: ['']
include:
- server-versions: stable22
php-versions: 7.4
databases: sqlite
- server-versions: stable23
php-versions: 8.0
databases: sqlite
- server-versions: stable23
php-versions: 8.0
databases: sqlite
container: nextcloud:fpm-alpine

name: Test classify job on ${{ matrix.databases }}-${{ matrix.server-versions }}-php${{ matrix.php-versions }}

container: ${{ matrix.container }}

env:
MYSQL_PORT: 4444
PGSQL_PORT: 4445
Expand All @@ -51,6 +58,20 @@ jobs:
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5

steps:
- name: Get Alpine Linux ready
if: ${{ matrix.container != ''}}
run: |
apk update
apk upgrade
apk add bash
apk add git
apk add composer
apk add nodejs
apk add npm
apk add make
apk add curl
apk add grep

- name: Checkout server
uses: actions/checkout@v2
with:
Expand All @@ -65,7 +86,8 @@ jobs:
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v1
if: ${{ matrix.container == ''}}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
Expand All @@ -85,6 +107,7 @@ jobs:
fallbackNpm: '^6'

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
if: ${{ matrix.container == ''}}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}
Expand All @@ -93,11 +116,21 @@ jobs:
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"

- name: Install app
if: ${{ matrix.container == ''}}
working-directory: apps/${{ env.APP_NAME }}
run: |
composer install --ignore-platform-req=php --no-dev
make all

- name: Install app on Alpine
if: ${{ matrix.container != ''}}
working-directory: apps/${{ env.APP_NAME }}
run: |
composer install --ignore-platform-req=php --no-dev
npm ci --ignore-scripts
npm run build
mkdir -p bin

- name: Set up Nextcloud and install app
if: ${{ matrix.databases != 'pgsql'}}
run: |
Expand All @@ -121,6 +154,7 @@ jobs:
./occ app:enable -vvv ${{ env.APP_NAME }}

- name: Set pure-js mode
if: ${{ matrix.container == ''}}
run: |
./occ config:app:set --value false recognize tensorflow.purejs

Expand All @@ -144,6 +178,10 @@ jobs:
run: |
php cron.php

- name: Show log
run: |
tail -50 data/nextcloud.log

- name: Check log
run: |
! tail -50 data/nextcloud.log | grep -q 'Classifier process error'
2 changes: 1 addition & 1 deletion .github/workflows/command-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
Expand Down
57 changes: 34 additions & 23 deletions lib/Migration/InstallDeps.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

class InstallDeps implements IRepairStep {
public const NODE_VERSION = 'v14.18.2';
public const NODE_SERVER_OFFICIAL = 'https://nodejs.org/dist/';
public const NODE_SERVER_UNOFFICIAL = 'https://unofficial-builds.nodejs.org/download/release/';

/** @var IConfig */
protected $config;
Expand All @@ -51,33 +53,38 @@ public function getName(): string {

public function run(IOutput $output): void {
$isARM = false;
if (PHP_INT_SIZE === 8) {
$binaryPath = $this->downloadBinary(self::NODE_VERSION, 'arm64');
$version = $this->testBinary($binaryPath);
$isMusl = false;

if (PHP_INT_SIZE === 8) {
$binaryPath = $this->downloadNodeBinary(self::NODE_SERVER_OFFICIAL, self::NODE_VERSION, 'arm64');
$version = $this->testBinary($binaryPath);
$isARM = true;
if ($version === null) {
$binaryPath = $this->downloadBinary(self::NODE_VERSION, 'x64');
$version = $this->testBinary($binaryPath);
if ($version === null) {
$binaryPath = $this->downloadNodeBinary(self::NODE_SERVER_OFFICIAL, self::NODE_VERSION, 'x64');
$version = $this->testBinary($binaryPath);
$isARM = false;
if ($version === null) {
$output->warning('Failed to install node binary');
return;
}
}
} else {
$binaryPath = $this->downloadBinary(self::NODE_VERSION, 'armv7l');
$version = $this->testBinary($binaryPath);
}
} else {
$binaryPath = $this->downloadNodeBinary(self::NODE_SERVER_OFFICIAL, self::NODE_VERSION, 'armv7l');
$version = $this->testBinary($binaryPath);
$isARM = true;
}

if ($version === null) {
$output->warning('Failed to install node binary');
return;
}
}
if ($version === null && PHP_INT_SIZE === 8) {
$binaryPath = $this->downloadNodeBinary(self::NODE_SERVER_UNOFFICIAL, self::NODE_VERSION, 'x64', 'musl');
$version = $this->testBinary($binaryPath);
$isARM = false;
$isMusl = true;
}

if ($version === null) {
$output->warning('Failed to install node binary');
return;
}

// Write the app config
$this->config->setAppValue('recognize', 'node_binary', $binaryPath);
if ($isARM) {
if ($isARM || $isMusl) {
$this->config->setAppValue('recognize', 'tensorflow.purejs', 'true');
}

Expand Down Expand Up @@ -117,8 +124,12 @@ protected function runTfjsInstall($nodeBinary) : void {
}
}

protected function downloadBinary(string $version, string $arch) : string {
$url = 'https://nodejs.org/dist/'.$version.'/node-'.$version.'-linux-'.$arch.'.tar.gz';
protected function downloadNodeBinary(string $server, string $version, string $arch, string $flavor = '') : string {
$name = 'node-'.$version.'-linux-'.$arch;
if ($flavor !== '') {
$name = $name . '-'.$flavor;
}
$url = $server.$version.'/'.$name.'.tar.gz';
$file = $this->binaryDir.'/'.$arch.'.tar.gz';
$archive = file_get_contents($url);
if ($archive === false) {
Expand All @@ -129,7 +140,7 @@ protected function downloadBinary(string $version, string $arch) : string {
throw new \Exception('Saving of node binary failed');
}
$tar = new TAR($file);
$tar->extractFile('node-'.$version.'-linux-'.$arch.'/bin/node', $this->binaryDir.'/node');
$tar->extractFile($name.'/bin/node', $this->binaryDir.'/node');
return $this->binaryDir.'/node';
}

Expand Down