diff --git a/.github/examples/ci-cd.yml b/.github/examples/ci-cd.yml new file mode 100644 index 00000000..35b9ddd8 --- /dev/null +++ b/.github/examples/ci-cd.yml @@ -0,0 +1,93 @@ +name: CI-CD + +on: [push] + +jobs: + ci: + runs-on: ubuntu-latest + env: + APP_ENV: testing + BROADCAST_DRIVER: log + services: + database: + image: ankane/pgvector:latest + env: + POSTGRES_PASSWORD: password + POSTGRES_USER: root + POSTGRES_DB: testing + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + strategy: + fail-fast: false + matrix: + php-versions: ["8.1"] + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: ${{ matrix.php-versions }} + tools: phpmd + extensions: mbstring, dom, fileinfo, grpc + coverage: xdebug #optional + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: | + composer install --no-progress --prefer-dist --optimize-autoloader + + - name: PHP Code Style (phpcs) + run: | + composer fix + + - name: PHP Code Style (phpcs) + run: | + composer stan + + - name: Setup application + run: | + cp .env.github .env + php artisan storage:link + + - name: Test with phpunit + run: | + npm install && npm run build + XDEBUG_MODE=coverage php artisan test --coverage --min=50 + + + cd: + runs-on: ubuntu-latest + needs: ci + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + tools: composer:v2 + coverage: none + - name: Require Vapor CLI + run: composer global require laravel/vapor-cli + - name: Install Project Dependencies + run: | + curl https://envoyer.io/deploy/${{ secrets.ENVOYER }} diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a9502d8c..566aaee6 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -30,12 +30,13 @@ jobs: - uses: actions/checkout@v4 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} tools: phpmd - extensions: mbstring, dom, fileinfo, pgsql, grpc, :psr - coverage: xdebug + extensions: mbstring, dom, fileinfo, grpc + coverage: xdebug #optional + - name: Get composer cache directory id: composer-cache diff --git a/app/Domains/Collections/CollectionStatusEnum.php b/app/Domains/Collections/CollectionStatusEnum.php new file mode 100644 index 00000000..d6a04876 --- /dev/null +++ b/app/Domains/Collections/CollectionStatusEnum.php @@ -0,0 +1,15 @@ + + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('collection.'.$this->collection->id), + ]; + } + + /** + * The event's broadcast name. + */ + public function broadcastAs(): string + { + return 'status'; + } +} diff --git a/app/Jobs/ParsePdfFileJob.php b/app/Jobs/ParsePdfFileJob.php new file mode 100644 index 00000000..cd32dc23 --- /dev/null +++ b/app/Jobs/ParsePdfFileJob.php @@ -0,0 +1,40 @@ +batch()->cancelled()) { + // Determine if the batch has been cancelled... + + return; + } + + (new PdfTransformer())->handle($this->document); + + } +} diff --git a/app/Jobs/ProcessFileJob.php b/app/Jobs/ProcessFileJob.php new file mode 100644 index 00000000..5fc77f93 --- /dev/null +++ b/app/Jobs/ProcessFileJob.php @@ -0,0 +1,61 @@ +document), + //new VectorizeDataJob($this->document), + //new SummarizeDataJob($this->document), + //new TagDataJob($this->document), + //then mark it all as done and notify the ui + ]) + ->name('OptOutRequests') + ->finally(function (Batch $batch) { + /** + * @TODO + * make a job that does that and also + * closes up the batch on the run watcher + */ + CollectionStatusEvent::dispatch( + $this->document->collection, + CollectionStatusEnum::PROCESSED); + }) + ->allowFailures() + ->dispatch(); + } +} diff --git a/tests/Feature/Jobs/ChunkFileJobTest.php b/tests/Feature/Jobs/ChunkFileJobTest.php new file mode 100644 index 00000000..b514bb88 --- /dev/null +++ b/tests/Feature/Jobs/ChunkFileJobTest.php @@ -0,0 +1,18 @@ +get('/'); + + $response->assertStatus(200); + } +}