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 + + + 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" ], 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'), ], ], 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/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/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/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); - } -} 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 {