From 924da00f3e1f0fe04b06ed1301f1d4f7d159b9a4 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 6 Jun 2024 13:21:00 -0700 Subject: [PATCH 1/3] Add Postgres GitHub workflow for tests --- .github/workflows/tests-postgres.yml | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/tests-postgres.yml diff --git a/.github/workflows/tests-postgres.yml b/.github/workflows/tests-postgres.yml new file mode 100644 index 000000000..c897762bd --- /dev/null +++ b/.github/workflows/tests-postgres.yml @@ -0,0 +1,80 @@ +name: Tests in Postgres + +on: + push: + branches: + - master + - develop + pull_request: + +jobs: + tests: + runs-on: ubuntu-latest + + services: + postgresql: + image: postgres:14 + env: + POSTGRES_DB: snipeit + POSTGRES_USER: snipeit + POSTGRES_PASSWORD: password + ports: + - 5432:5432 + options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3 + + strategy: + fail-fast: false + matrix: + php-version: + - "8.2" + + name: PHP ${{ matrix.php-version }} + + steps: + - uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php-version }}" + coverage: none + + - uses: actions/checkout@v4 + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Copy .env + run: | + cp -v .env.testing.example .env + cp -v .env.testing.example .env.testing + + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: Setup Laravel + env: + DB_CONNECTION: pgsql + DB_DATABASE: snipeit + DB_PORT: ${{ job.services.postgresql.ports[5432] }} + DB_USERNAME: snipeit + DB_PASSWORD: password + run: | + php artisan key:generate + php artisan migrate --force + php artisan passport:install + chmod -R 777 storage bootstrap/cache + + - name: Execute tests (Unit and Feature tests) via PHPUnit + env: + DB_CONNECTION: pgsql + DB_DATABASE: snipeit + DB_PORT: ${{ job.services.postgresql.ports[5432] }} + DB_USERNAME: snipeit + DB_PASSWORD: password + run: php artisan test --parallel From 6c296ccf8e1867fedf1d30f0feb15baf0f641866 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 6 Jun 2024 13:27:39 -0700 Subject: [PATCH 2/3] Use "postgres" instead of "postgres:14" --- .github/workflows/tests-postgres.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-postgres.yml b/.github/workflows/tests-postgres.yml index c897762bd..4e4fbc66d 100644 --- a/.github/workflows/tests-postgres.yml +++ b/.github/workflows/tests-postgres.yml @@ -13,7 +13,7 @@ jobs: services: postgresql: - image: postgres:14 + image: postgres env: POSTGRES_DB: snipeit POSTGRES_USER: snipeit From 5c0ca92fd7a7f5c8d88bd36d15451772f1a3e1a9 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 10 Jun 2024 10:24:10 -0700 Subject: [PATCH 3/3] Switch to using workflow_dispatch for PostgreSQL tests --- .github/workflows/tests-postgres.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/tests-postgres.yml b/.github/workflows/tests-postgres.yml index 4e4fbc66d..b12fdebbc 100644 --- a/.github/workflows/tests-postgres.yml +++ b/.github/workflows/tests-postgres.yml @@ -1,11 +1,6 @@ name: Tests in Postgres -on: - push: - branches: - - master - - develop - pull_request: +on: workflow_dispatch jobs: tests: