Skip to content

Commit

Permalink
move to postgres on github
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Mar 25, 2024
1 parent 51ef6d5 commit 53cd9bb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 60 deletions.
69 changes: 15 additions & 54 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ name: CI-CD

on: [ push ]

# Thanks to https://github.com/shivammathur/setup-php/blob/master/examples/laravel-mysql.yml
jobs:
ci:
runs-on: ubuntu-latest
env:
DB_CONNECTION: pgsql
DB_DATABASE: test
DB_USERNAME: root
DB_USERNAME: postgres
DB_PASSWORD: password
APP_ENV: testing
BROADCAST_DRIVER: log
services:
mysql:
image: mysql:8.0
postgres:
image: postgres:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test
POSTGRES_PASSWORD: password
POSTGRES_DB: test
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
- 5432/tcp
options: --health-cmd="pg_isready -U postgres" --health-interval=10s --health-timeout=5s --health-retries=5

strategy:
fail-fast: false
matrix:
Expand All @@ -30,56 +30,17 @@ jobs:
- uses: actions/checkout@v4

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpmd
extensions: mbstring, dom, fileinfo, mysql, grpc, :psr
coverage: xdebug #optional


- name: Start mysql service
run: sudo /etc/init.d/mysql start

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT


- name: Cache composer dependencies
uses: actions/cache@v3
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 config http-basic.packages.craftable.pro "${{ secrets.CRAFTABLE_PRO_EMAIL }}" "${{ secrets.CRAFTABLE_PRO_LICENCE_KEY }}"
composer install --no-interaction --prefer-dist
- name: Prepare the application
run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
- name: Clear Config
run: php artisan config:clear

- name: PHP Stan
run: |
composer stan
- name: PHP Code Style (phpcs)
run: |
./vendor/bin/pint --test
extensions: mbstring, dom, fileinfo, pgsql, grpc, :psr
coverage: xdebug

- name: Migrations
- name: Enable PostgreSQL Extensions
run: |
sudo cp .env.github .env
php artisan storage:link
sudo service postgresql start
sudo -u postgres psql -c "CREATE EXTENSION IF NOT EXISTS vector;" -d test
- name: Test with phpunit
run: |
Expand Down
3 changes: 3 additions & 0 deletions database/factories/ApiKeyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public function definition(): array
'key' => $this->faker->uuid,
'name' => $this->faker->word,
'type' => 'openai',
'settings' => [
'organization_key' => 'testing',
],
];
}
}
5 changes: 1 addition & 4 deletions database/factories/CollectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ public function definition(): array
'name' => $this->faker->sentence,
'description' => $this->faker->paragraph,
'active' => $this->faker->boolean,
'team_id' => Team::factory(),
'settings' => [
'organization_key' => 'testing',
],
'team_id' => Team::factory()
];
}
}
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_STORE" value="array"/>
<env name="DB_CONNECTION" value="mysql"/>
<env name="DB_CONNECTION" value="pgsql"/>
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<!-- this is a fake token! -->
<env name="OPENAI_API_KEY" value="sk-m8ox9NVgboSLRCr5VA5RT3BXbkFJzP1QGUedbQxGmmuAQWRT"/>
<env name="DB_DATABASE" value="test"/>
<env name="DB_DATABASE" value="testing"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
Expand Down

0 comments on commit 53cd9bb

Please sign in to comment.