Skip to content

Commit

Permalink
Merge pull request #7 from ikhsan3adi/ci
Browse files Browse the repository at this point in the history
chore: Add test workflow
  • Loading branch information
ikhsan3adi authored Apr 29, 2024
2 parents 8f66bc3 + ae1be29 commit f95737f
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 58 deletions.
14 changes: 7 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ database.default.DBDriver = MySQLi
# database.default.DBPrefix =
database.default.port = 3306

# database.tests.hostname = localhost
# database.tests.database = ci4_test
# database.tests.username = root
# database.tests.password = root
# database.tests.DBDriver = MySQLi
# database.tests.DBPrefix =
# database.tests.port = 3306
database.tests.hostname = 127.0.0.1
database.tests.database = db_book_library_test
database.tests.username = root
database.tests.password = root
database.tests.DBDriver = MySQLi
database.tests.DBPrefix =
database.tests.port = 3306

#--------------------------------------------------------------------
# CONTENT SECURITY POLICY
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Continuous Integration

on:
push:
branches: main
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

services:
mysql:
image: mysql:8.0
env:
# The MySQL docker container requires these environment variables to be set
# so we can create and migrate the test database.
# See: https://hub.docker.com/_/mysql
MYSQL_DATABASE: db_book_library_test
MYSQL_ROOT_PASSWORD: root
ports:
# Opens port 3306 on service container and host
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
- 3306:3306
# Before continuing, verify the mysql container is reachable from the ubuntu host
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v4

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Setup environment
run: cp .env.example .env

- name: Install dependencies
run: composer install --prefer-dist --no-progress

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

- name: Run test suite
run: composer run-script test
39 changes: 0 additions & 39 deletions .github/workflows/php.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ nb-configuration.xml

/results/
/phpunit*.xml
/.phpunit.*.cache
/.phpunit.*.cache
2 changes: 1 addition & 1 deletion .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":1,"defects":[],"times":{"ExampleDatabaseTest::testModelFindAll":0.063000000000000000444089209850062616169452667236328125,"ExampleDatabaseTest::testSoftDeleteLeavesRow":0.008000000000000000166533453693773481063544750213623046875,"ExampleSessionTest::testSessionSimple":0.00200000000000000004163336342344337026588618755340576171875,"HealthTest::testIsDefinedAppPath":0.001000000000000000020816681711721685132943093776702880859375,"HealthTest::testBaseUrlHasBeenSet":0.005000000000000000104083408558608425664715468883514404296875}}
{"version":1,"defects":{"ExampleDatabaseTest::testModelFindAll":4,"ExampleDatabaseTest::testSoftDeleteLeavesRow":4},"times":{"ExampleDatabaseTest::testModelFindAll":0.2260000000000000064392935428259079344570636749267578125,"ExampleDatabaseTest::testSoftDeleteLeavesRow":0.1449999999999999900079927783735911361873149871826171875,"ExampleSessionTest::testSessionSimple":0.00200000000000000004163336342344337026588618755340576171875,"HealthTest::testIsDefinedAppPath":0.001000000000000000020816681711721685132943093776702880859375,"HealthTest::testBaseUrlHasBeenSet":0.01600000000000000033306690738754696212708950042724609375}}
20 changes: 10 additions & 10 deletions build/logs/logfile.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="" tests="5" assertions="6" errors="0" warnings="0" failures="0" skipped="0" time="0.078822">
<testsuite name="App" tests="5" assertions="6" errors="0" warnings="0" failures="0" skipped="0" time="0.078822">
<testsuite name="ExampleDatabaseTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/database/ExampleDatabaseTest.php" tests="2" assertions="3" errors="0" warnings="0" failures="0" skipped="0" time="0.070723">
<testcase name="testModelFindAll" class="ExampleDatabaseTest" classname="ExampleDatabaseTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/database/ExampleDatabaseTest.php" line="17" assertions="1" time="0.062685"/>
<testcase name="testSoftDeleteLeavesRow" class="ExampleDatabaseTest" classname="ExampleDatabaseTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/database/ExampleDatabaseTest.php" line="28" assertions="2" time="0.008038"/>
<testsuite name="" tests="5" assertions="7" errors="0" warnings="0" failures="0" skipped="0" time="0.391194">
<testsuite name="App" tests="5" assertions="7" errors="0" warnings="0" failures="0" skipped="0" time="0.391194">
<testsuite name="ExampleDatabaseTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/database/ExampleDatabaseTest.php" tests="2" assertions="3" errors="0" warnings="0" failures="0" skipped="0" time="0.371416">
<testcase name="testModelFindAll" class="ExampleDatabaseTest" classname="ExampleDatabaseTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/database/ExampleDatabaseTest.php" line="17" assertions="1" time="0.225974"/>
<testcase name="testSoftDeleteLeavesRow" class="ExampleDatabaseTest" classname="ExampleDatabaseTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/database/ExampleDatabaseTest.php" line="28" assertions="2" time="0.145442"/>
</testsuite>
<testsuite name="ExampleSessionTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/session/ExampleSessionTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.002144">
<testcase name="testSessionSimple" class="ExampleSessionTest" classname="ExampleSessionTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/session/ExampleSessionTest.php" line="11" assertions="1" time="0.002144"/>
<testsuite name="ExampleSessionTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/session/ExampleSessionTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.001882">
<testcase name="testSessionSimple" class="ExampleSessionTest" classname="ExampleSessionTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/session/ExampleSessionTest.php" line="11" assertions="1" time="0.001882"/>
</testsuite>
<testsuite name="HealthTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/unit/HealthTest.php" tests="2" assertions="2" errors="0" warnings="0" failures="0" skipped="0" time="0.005955">
<testcase name="testIsDefinedAppPath" class="HealthTest" classname="HealthTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/unit/HealthTest.php" line="13" assertions="1" time="0.001342"/>
<testcase name="testBaseUrlHasBeenSet" class="HealthTest" classname="HealthTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/unit/HealthTest.php" line="18" assertions="1" time="0.004613"/>
<testsuite name="HealthTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/unit/HealthTest.php" tests="2" assertions="3" errors="0" warnings="0" failures="0" skipped="0" time="0.017896">
<testcase name="testIsDefinedAppPath" class="HealthTest" classname="HealthTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/unit/HealthTest.php" line="13" assertions="1" time="0.001446"/>
<testcase name="testBaseUrlHasBeenSet" class="HealthTest" classname="HealthTest" file="/home/ikhsan3adi/ngoding/codeigniter/sistem-perpustakaan-qr-code/tests/unit/HealthTest.php" line="18" assertions="2" time="0.016450"/>
</testsuite>
</testsuite>
</testsuite>
Expand Down

0 comments on commit f95737f

Please sign in to comment.