feat(db): init boundaries data using cahyadsn/wilayah_boundaries
#343
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
schedule: # scheduled to run at 23.00 on Saturday (UTC), means 6.00 on Monday (WIB) | |
- cron: '0 23 * * 6' | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
# paths: ['.github/**.yml', 'src/*', 'tests/*'] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
configs: | |
name: Configure | |
uses: projek-xyz/actions/.github/workflows/configure.yml@main | |
with: | |
php-version: 8.2 | |
secrets: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
prepare: | |
name: Prepare Database | |
runs-on: ubuntu-latest | |
needs: configs | |
env: | |
DB_USERNAME: root | |
DB_PASSWORD: root | |
DB_DATABASE: ${{ github.repository_owner }} | |
UPSTREAM_DB_DATABASE: nusantara | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup MySQL | |
run: | | |
sudo /etc/init.d/mysql start | |
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USERNAME }} -p${{ env.DB_PASSWORD }} | |
mysql -e 'CREATE DATABASE ${{ env.UPSTREAM_DB_DATABASE }};' -u${{ env.DB_USERNAME }} -p${{ env.DB_PASSWORD }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.1 | |
tools: composer:v2 | |
coverage: xdebug | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ needs.configs.outputs.composer-cache }} | |
key: php-8.1-10.x-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: php-8.1-10.x--composer- | |
- name: Download previous stat | |
uses: dawidd6/action-download-artifact@v6 | |
with: | |
branch: main | |
name: upstream-stats | |
path: tests | |
- name: Install dependencies | |
run: composer update --prefer-dist --no-interaction --no-progress | |
- name: Import databases | |
run: | | |
./vendor/bin/testbench nusa:import --ansi | |
./vendor/bin/testbench nusa:stat -dw --ansi | |
git status -s {database,resources} | |
# - name: Get file changed | |
# uses: tj-actions/changed-files@v45 | |
# with: | |
# exclude_submodules: true | |
# # files: resources/** | |
- name: Store current stat | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: upstream-stats | |
path: tests/stats.json | |
if-no-files-found: ignore | |
- name: Store static resources | |
uses: actions/upload-artifact@v4 | |
with: | |
name: static-resources | |
path: | | |
database/nusa.sqlite | |
resources/static/** | |
tests: | |
name: Test on PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }} DB ${{ matrix.db }} | |
needs: [configs, prepare] | |
runs-on: ubuntu-latest | |
env: | |
DB_CONNECTION: ${{ matrix.db }} | |
DB_DATABASE: ${{ github.repository_owner }} | |
DB_USERNAME: ${{ github.repository_owner }} | |
DB_PASSWORD: secret | |
services: | |
postgresql: | |
image: postgres:14 | |
env: | |
POSTGRES_DB: ${{ env.DB_DATABASE }} | |
POSTGRES_USER: ${{ env.DB_USERNAME }} | |
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }} | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd=pg_isready | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
mysql: | |
image: mysql:8.0 | |
env: | |
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }} | |
MYSQL_DATABASE: ${{ env.DB_DATABASE }} | |
MYSQL_USER: ${{ env.DB_USERNAME }} | |
MYSQL_PASSWORD: ${{ env.DB_PASSWORD }} | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd="mysqladmin ping" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
strategy: | |
fail-fast: false | |
matrix: | |
db: ['mysql', 'pgsql', 'sqlite'] | |
laravel: ['10.x', '11.x'] | |
php: ['8.1', '8.2', '8.3'] | |
exclude: | |
- php: '8.1' | |
laravel: '11.x' | |
- php: '8.3' | |
laravel: '9.x' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP ${{ matrix.php }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2 | |
coverage: xdebug | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ needs.configs.outputs.composer-cache }} | |
key: php-${{ matrix.php }}-${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: php-${{ matrix.php }}-${{ matrix.laravel }}-composer- | |
- name: Install dependencies | |
run: | | |
composer require "laravel/framework=${{ matrix.laravel }}" --no-update | |
composer update --prefer-dist --no-interaction --no-progress | |
- name: Restore static resources | |
uses: actions/download-artifact@v4 | |
with: | |
name: static-resources | |
- name: Run migrations | |
run: | | |
./vendor/bin/testbench vendor:publish --ansi --tag creasi-migrations | |
./vendor/bin/testbench migrate --ansi | |
- name: Run tests | |
run: | | |
./vendor/bin/testbench config:show database --ansi | |
./vendor/bin/testbench package:test --ansi --coverage | |
- name: Generate reports for CodeClimate | |
id: reports | |
if: needs.configs.outputs.has-codeclimate == '1' | |
env: | |
CODECLIMATE_REPORT: tests/reports/codeclimate.PHP${{ matrix.php }}-L${{ matrix.laravel }}-${{ matrix.db }}.json | |
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }} | |
run: | | |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter | |
./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT tests/reports/clover.xml | |
- name: Store tests reports | |
uses: actions/upload-artifact@v4 | |
if: needs.configs.outputs.has-codeclimate == '1' | |
with: | |
name: test-reports-PHP${{ matrix.php }}-L${{ matrix.laravel }}-${{ matrix.db }} | |
path: tests/reports/codeclimate.*.json | |
reports: | |
name: Report Test Coverages | |
needs: [configs, tests] | |
if: needs.configs.outputs.should-reports == '1' | |
uses: projek-xyz/actions/.github/workflows/report.yml@main | |
secrets: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
with: | |
has-coveralls: ${{ needs.configs.outputs.has-coveralls == '1' }} | |
has-codeclimate: ${{ needs.configs.outputs.has-codeclimate == '1' }} |