Skip to content

Commit

Permalink
remove the port call in ci-cd
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Mar 25, 2024
1 parent 0d2ad10 commit 8c9224b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .env.github
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ ADMIN_ONE_PASSWORD=makeagoodone
[email protected]
ADMIN_TWO_PASSWORD=makeagoodone

OPENAI_API_KEY=
## Fake key
OPENAI_API_KEY=sk-m8ox9NVgboSLRCr5VA5RT3BXbkFJzP1QGUedbQxGmmuAQWRT
2 changes: 0 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ jobs:
run: |
npm install && npm run build
XDEBUG_MODE=coverage php artisan test --coverage --min=50
env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
cd:
runs-on: ubuntu-latest
Expand Down
12 changes: 5 additions & 7 deletions app/Domains/Documents/Transformers/PdfTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@

use App\Models\Document;
use App\Models\DocumentChunk;
use App\Models\Transformer;
use App\Transformer\BaseTransformer;
use Smalot\PdfParser\Parser;

class PdfTransformer
class PdfTransformer
{
protected Document $document;

public function handle(Document $document): Document
{
$this->document = $document;

$filePath = $this->document->pathToFile();

$parser = new Parser();
Expand All @@ -28,12 +26,12 @@ public function handle(Document $document): Document
$guid = md5($pageContent);
DocumentChunk::updateOrCreate(
[
'guid' => $guid,
'document_id' => $this->document->id
'guid' => $guid,
'document_id' => $this->document->id,
],
[
'content' => $pageContent,
'sort_order' => $page_number
'sort_order' => $page_number,
]
);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public function document_chunks(): HasMany
return $this->hasMany(DocumentChunk::class);
}

public function pathToFile(): string|null
public function pathToFile(): ?string
{
return sprintf(
storage_path('app/collections/%d/%s'),
$this->collection_id,
$this->file_path);
}

public function mkdirPathToFile(): string|null
public function mkdirPathToFile(): ?string
{
return sprintf(
storage_path('app/collections/%d'),
Expand Down
2 changes: 0 additions & 2 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ function put_fixture($file_name, $content = [], $json = true)
}
}


if (! function_exists('remove_ascii')) {
function remove_ascii($string): string
{
return preg_replace('/[^\x00-\x7F]+/', '', $string);
}
}


if (! function_exists('get_fixture')) {
function get_fixture($file_name, $decode = true)
{
Expand Down
1 change: 0 additions & 1 deletion database/factories/DocumentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ public function pdf(): Factory
];
});
}

}
7 changes: 7 additions & 0 deletions tests/Feature/SharedSetupForPdfFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ protected function webFileDownloadSetup()
$from = base_path('tests/fixtures/example.pdf');

if (! File::exists($document->pathToFile())) {
if(!File::exists($document->mkdirPathToFile())) {
File::makeDirectory(
$document->mkdirPathToFile(),
0755,
true
);
}
File::copy(
$from,
$document->pathToFile()
Expand Down

0 comments on commit 8c9224b

Please sign in to comment.