From 388e966f61deac4d43a66865aa2e798d9e8eab9a Mon Sep 17 00:00:00 2001 From: Noel Palo Date: Mon, 11 Sep 2023 11:08:59 +0800 Subject: [PATCH 1/5] Create weather-app-ci-build.yml feature/BWA-8-weather-app-github-action - Create weather-app-ci-build.yml --- .github/workflows/weather-app-ci-build.yml | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/weather-app-ci-build.yml diff --git a/.github/workflows/weather-app-ci-build.yml b/.github/workflows/weather-app-ci-build.yml new file mode 100644 index 0000000..f4f9912 --- /dev/null +++ b/.github/workflows/weather-app-ci-build.yml @@ -0,0 +1,63 @@ +name: Weather App CI + +on: + push: + branches: [ "master", "development" ] + pull_request: + branches: [ "master", "development" ] + +jobs: + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Docker Login + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_KEY: ${{ secrets.DOCKER_KEY }} + run: | + docker login -u $DOCKER_USER -p $DOCKER_KEY + + # Script Permissions + - name: Add Permission to Shell Scripts + run: chmod +x -R ./scripts/*.sh + + # Docker Images + - name: Building the Docker Images + run: ./scripts/build.sh + + # Docker Containers + - name: Start Docker Containers + run: ./scripts/up.sh -d + + # Composer + - name: Run Composer + run: | + ./scripts/composer.sh install + ./scripts/composer.sh dump-autoload + + # NPM + - name: Run NPM + run: | + ./scripts/run.sh npm install + ./scripts/run.sh npm run build + + # Code Quality Check + - name: Run PhpStan + run: ./scripts/composer.sh run phpstan + + - name: Run Easy Coding Sandards + run: ./scripts/composer.sh run ecs-all + + - name: Run Automated Test with PhpUnit + run: ./scripts/composer.sh run phpunit + + # Teardown + - name: Stop container and remove images + run: ./scripts/down.sh -v + + + From f3621fc5843e9e30756eb97de1e587383304f3b8 Mon Sep 17 00:00:00 2001 From: Noel Palo Date: Mon, 11 Sep 2023 11:19:11 +0800 Subject: [PATCH 2/5] Update composer.json Fix /bootstrap/cache directory must be present and writable. --- src/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/composer.json b/src/composer.json index 96260a5..7e4b2d1 100644 --- a/src/composer.json +++ b/src/composer.json @@ -37,6 +37,7 @@ }, "scripts": { "post-autoload-dump": [ + "mkdir -p ./bootstrap/cache/", "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], From 7358b064948aa01010dbfc506fbd20b9f190920a Mon Sep 17 00:00:00 2001 From: Noel Palo Date: Mon, 11 Sep 2023 11:27:31 +0800 Subject: [PATCH 3/5] feature/BWA-8-weather-app-github-action - Remove unused example tests from phpunit --- src/tests/Feature/ExampleTest.php | 23 ----------------------- src/tests/Unit/ExampleTest.php | 20 -------------------- 2 files changed, 43 deletions(-) delete mode 100644 src/tests/Feature/ExampleTest.php delete mode 100644 src/tests/Unit/ExampleTest.php diff --git a/src/tests/Feature/ExampleTest.php b/src/tests/Feature/ExampleTest.php deleted file mode 100644 index e17d7b6..0000000 --- a/src/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,23 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/src/tests/Unit/ExampleTest.php b/src/tests/Unit/ExampleTest.php deleted file mode 100644 index 18d3bcb..0000000 --- a/src/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} From 200ac207525c41b211cc0ac334b8b5267b5b8331 Mon Sep 17 00:00:00 2001 From: Noel Palo Date: Mon, 11 Sep 2023 11:46:16 +0800 Subject: [PATCH 4/5] feature/BWA-8-weather-app-github-action - Fix Error in Unit test in git action --- src/tests/{Unit => }/CreatesApplication.php | 4 ++-- src/tests/{Unit => }/TestCase.php | 2 +- src/tests/Unit/Enums/DirectionTest.php | 2 +- .../ConfigurationMapper/ServiceConfigurationMapperTest.php | 2 +- src/tests/Unit/Services/GeoapifyApi/GeocodingServiceTest.php | 2 +- .../GeoapifyApi/Resources/GeolocationResourceTest.php | 2 +- .../Services/OpenWeatherApi/Resources/WeatherResourceTest.php | 2 +- .../OpenWeatherApi/Resources/WeatherResourcesTest.php | 2 +- .../UrlQueryStringBuilderServiceTest.php | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) rename src/tests/{Unit => }/CreatesApplication.php (81%) rename src/tests/{Unit => }/TestCase.php (93%) diff --git a/src/tests/Unit/CreatesApplication.php b/src/tests/CreatesApplication.php similarity index 81% rename from src/tests/Unit/CreatesApplication.php rename to src/tests/CreatesApplication.php index 079f015..df084d1 100644 --- a/src/tests/Unit/CreatesApplication.php +++ b/src/tests/CreatesApplication.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Unit; +namespace Tests; use Illuminate\Contracts\Console\Kernel; @@ -15,7 +15,7 @@ trait CreatesApplication */ public function createApplication() { - $app = require __DIR__ . '/../../bootstrap/app.php'; + $app = require __DIR__ . '/../bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); diff --git a/src/tests/Unit/TestCase.php b/src/tests/TestCase.php similarity index 93% rename from src/tests/Unit/TestCase.php rename to src/tests/TestCase.php index 1e4d375..c7a1aa3 100644 --- a/src/tests/Unit/TestCase.php +++ b/src/tests/TestCase.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Unit; +namespace Tests; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; diff --git a/src/tests/Unit/Enums/DirectionTest.php b/src/tests/Unit/Enums/DirectionTest.php index 6698fc1..150c599 100644 --- a/src/tests/Unit/Enums/DirectionTest.php +++ b/src/tests/Unit/Enums/DirectionTest.php @@ -5,7 +5,7 @@ namespace Unit\Enums; use App\Enums\Direction; -use Unit\TestCase; +use Tests\TestCase; class DirectionTest extends TestCase { diff --git a/src/tests/Unit/Services/ConfigurationMapper/ServiceConfigurationMapperTest.php b/src/tests/Unit/Services/ConfigurationMapper/ServiceConfigurationMapperTest.php index a896a53..b42af13 100644 --- a/src/tests/Unit/Services/ConfigurationMapper/ServiceConfigurationMapperTest.php +++ b/src/tests/Unit/Services/ConfigurationMapper/ServiceConfigurationMapperTest.php @@ -6,7 +6,7 @@ use App\Services\ConfigurationMapper\Exceptions\UnknownServiceConfigurationException; use App\Services\ConfigurationMapper\ServiceConfigurationMapper; -use Unit\TestCase; +use Tests\TestCase; class ServiceConfigurationMapperTest extends TestCase { diff --git a/src/tests/Unit/Services/GeoapifyApi/GeocodingServiceTest.php b/src/tests/Unit/Services/GeoapifyApi/GeocodingServiceTest.php index 5cb2ba3..a2e4d7d 100644 --- a/src/tests/Unit/Services/GeoapifyApi/GeocodingServiceTest.php +++ b/src/tests/Unit/Services/GeoapifyApi/GeocodingServiceTest.php @@ -9,7 +9,7 @@ use App\Services\UrlQueryStringBuilder\Interfaces\UrlQueryStringBuilderServiceInterface; use Illuminate\Http\Client\RequestException; use Illuminate\Support\Facades\Http; -use Unit\TestCase; +use Tests\TestCase; class GeocodingServiceTest extends TestCase { diff --git a/src/tests/Unit/Services/GeoapifyApi/Resources/GeolocationResourceTest.php b/src/tests/Unit/Services/GeoapifyApi/Resources/GeolocationResourceTest.php index 8c1c8b1..4495049 100644 --- a/src/tests/Unit/Services/GeoapifyApi/Resources/GeolocationResourceTest.php +++ b/src/tests/Unit/Services/GeoapifyApi/Resources/GeolocationResourceTest.php @@ -5,7 +5,7 @@ namespace Unit\Services\GeoapifyApi\Resources; use App\Services\GeoapifyApi\Resources\GeolocationResource; -use Unit\TestCase; +use Tests\TestCase; class GeolocationResourceTest extends TestCase { diff --git a/src/tests/Unit/Services/OpenWeatherApi/Resources/WeatherResourceTest.php b/src/tests/Unit/Services/OpenWeatherApi/Resources/WeatherResourceTest.php index 735ba08..e6ebd46 100644 --- a/src/tests/Unit/Services/OpenWeatherApi/Resources/WeatherResourceTest.php +++ b/src/tests/Unit/Services/OpenWeatherApi/Resources/WeatherResourceTest.php @@ -5,7 +5,7 @@ namespace Unit\Services\OpenWeatherApi\Resources; use App\Services\OpenWeatherApi\Resources\WeatherResource; -use Unit\TestCase; +use Tests\TestCase; class WeatherResourceTest extends TestCase { diff --git a/src/tests/Unit/Services/OpenWeatherApi/Resources/WeatherResourcesTest.php b/src/tests/Unit/Services/OpenWeatherApi/Resources/WeatherResourcesTest.php index c48fd38..860e31e 100644 --- a/src/tests/Unit/Services/OpenWeatherApi/Resources/WeatherResourcesTest.php +++ b/src/tests/Unit/Services/OpenWeatherApi/Resources/WeatherResourcesTest.php @@ -5,7 +5,7 @@ namespace Unit\Services\OpenWeatherApi\Resources; use App\Services\OpenWeatherApi\Resources\WeatherResources; -use Unit\TestCase; +use Tests\TestCase; class WeatherResourcesTest extends TestCase { diff --git a/src/tests/Unit/Services/UrlQueryStringBuilder/UrlQueryStringBuilderServiceTest.php b/src/tests/Unit/Services/UrlQueryStringBuilder/UrlQueryStringBuilderServiceTest.php index af547b8..42a93ae 100644 --- a/src/tests/Unit/Services/UrlQueryStringBuilder/UrlQueryStringBuilderServiceTest.php +++ b/src/tests/Unit/Services/UrlQueryStringBuilder/UrlQueryStringBuilderServiceTest.php @@ -5,7 +5,7 @@ namespace Unit\Services\UrlQueryStringBuilder; use App\Services\UrlQueryStringBuilder\UrlQueryStringBuilderService; -use Unit\TestCase; +use Tests\TestCase; class UrlQueryStringBuilderServiceTest extends TestCase { From 14d697aebc77bf080c64f569a959fede65008ce2 Mon Sep 17 00:00:00 2001 From: Noel Palo Date: Mon, 11 Sep 2023 11:54:25 +0800 Subject: [PATCH 5/5] feature/BWA-8-weather-app-github-action - Fix Error in GeocodingServiceTest::testService - Add API Services URI in the config --- src/config/services.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/services.php b/src/config/services.php index 88edfc4..752d825 100644 --- a/src/config/services.php +++ b/src/config/services.php @@ -37,7 +37,7 @@ 'max_output' => env('OPEN_WEATHER_MAX_OUTPUT', '5'), 'unit' => env('OPEN_WEATHER_UNIT', 'metric'), 'lang' => env('OPEN_WEATHER_LANG', 'en'), - 'uri' => env('OPEN_WEATHER_API_URI', ''), + 'uri' => env('OPEN_WEATHER_API_URI', 'api.openweathermap.org/data/2.5'), ], 'geoapify' => [ 'filter' => env('GEOAPIFY_FILTER', 'countrycode:jp'), @@ -46,7 +46,7 @@ 'lang' => env('GEOAPIFY_LANG', 'en'), 'max_output' => env('GEOAPIFY_MAX_OUTPUT', '1'), 'type' => env('GEOAPIFY_TYPE', 'city'), - 'uri' => env('GEOAPIFY_API_URI', ''), + 'uri' => env('GEOAPIFY_API_URI', 'api.geoapify.com/v1/geocode/search'), 'default_search' => env('GEOAPIFY_DEFAULT', 'Tokyo, Japan'), ], ],