Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Commit 2feaf40

Browse files
committed
SHARE-234 github Actions, here we come :)
- run PhpUnit tests on every pull request - create pull request on merge into develop to - remove old auto generated code - generate new code - fix code style
1 parent a76d0a3 commit 2feaf40

35 files changed

+2050
-1972
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Create Pull Request
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
10+
createPullRequest:
11+
12+
name: Create Pull Request
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Clean old files
19+
run: |
20+
rm -rf .openapi-generator Api Controller DependencyInjection Model Resources Service Tests
21+
22+
- name: Open API code generation
23+
run:
24+
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v5.0.0-beta generate -i local/catroweb.yaml -g php-symfony -p sortParamsByRequiredFlag=true -p skipFormModel=true -p variableNamingConvention=snake_case -p phpLegacySupport=false -o /local
25+
26+
- name: Fix code style
27+
uses: docker://oskarstark/php-cs-fixer-ga:latest
28+
with:
29+
args: --allow-risky=yes
30+
31+
- name: Create Pull Request
32+
id: cpr
33+
uses: peter-evans/create-pull-request@v2
34+
with:
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
commit-message: Automated php-cs-fixer
37+
committer: Catrobot <Catrobot@catroweb.github.com>
38+
title: 'Bump autogenerated open API code'
39+
body: |
40+
Automatic Open API Code Generation
41+
42+
This pull request is autogenerated using the latest catroweb.yml swagger specificatons
43+
from the develop branch and is updated automatically with every new change merged into the develop branch.
44+
45+
- removes old autogenerated files
46+
- run open API generator (Symfony-Php)
47+
- fix code style (Php-cs-fixer)
48+
49+
For more information checkout the action '.github/workflows/create_pull_request.yml'
50+
labels: automated, open-api-generator, php-cs-fixer
51+
52+
- name: Check outputs
53+
run: |
54+
echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}"
55+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"

.github/workflows/tests.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
pull_request:
9+
10+
jobs:
11+
12+
tests:
13+
name: PHPUnit
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Validate composer.json and composer.lock
20+
run: composer validate
21+
22+
- name: Cache Composer packages
23+
id: composer-cache
24+
uses: actions/cache@v2
25+
with:
26+
path: vendor
27+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
28+
restore-keys: |
29+
${{ runner.os }}-php-
30+
31+
- name: Install dependencies
32+
if: steps.composer-cache.outputs.cache-hit != 'true'
33+
run: composer install --prefer-dist --no-progress --no-suggest
34+
35+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
36+
# Docs: https://getcomposer.org/doc/articles/scripts.md
37+
- name: Run test suite
38+
run: composer run-script test

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# ref: https://github.com/github/gitignore/blob/master/Symfony.gitignore
22

3-
.idea/
4-
53
# Cache and logs (Symfony2)
64
/app/cache/*
75
/app/logs/*

.openapi-generator/FILES

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,8 @@
3636
./Service/SymfonyValidator.php
3737
./Service/TypeMismatchException.php
3838
./Service/ValidatorInterface.php
39-
./Tests/Api/AuthenticationApiInterfaceTest.php
40-
./Tests/Api/MediaLibraryApiInterfaceTest.php
41-
./Tests/Api/ProjectsApiInterfaceTest.php
42-
./Tests/Api/UserApiInterfaceTest.php
43-
./Tests/Api/UtilityApiInterfaceTest.php
4439
./Tests/AppKernel.php
4540
./Tests/Controller/ControllerTest.php
46-
./Tests/Model/BaseUserTest.php
47-
./Tests/Model/DryRunTest.php
48-
./Tests/Model/FeaturedProjectTest.php
49-
./Tests/Model/JWTTokenResponseTest.php
50-
./Tests/Model/LoginTest.php
51-
./Tests/Model/MediaCategoriesTest.php
52-
./Tests/Model/MediaCategoryTest.php
53-
./Tests/Model/MediaFileTest.php
54-
./Tests/Model/MediaPackageTest.php
55-
./Tests/Model/MediaPackagesTest.php
56-
./Tests/Model/ProjectTest.php
57-
./Tests/Model/ProjectUploadTest.php
58-
./Tests/Model/RegisterErrorTest.php
59-
./Tests/Model/RegisterTest.php
60-
./Tests/Model/UpdateUserAllOfTest.php
61-
./Tests/Model/UpdateUserErrorTest.php
62-
./Tests/Model/UpdateUserTest.php
63-
./Tests/Model/UploadErrorTest.php
64-
./Tests/Model/UserPrivateGetTest.php
65-
./Tests/Model/UserPublicGetTest.php
6641
./Tests/test_config.yml
6742
.coveralls.yml
6843
.gitignore

Controller/MediaLibraryController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public function mediaPackagePackageNameGetAction(Request $request, $package_name
396396
$asserts = [];
397397
$asserts[] = new Assert\NotNull();
398398
$asserts[] = new Assert\Type("string");
399-
$asserts[] = new Assert\Regex("/^[a-zA-Z0-9-_]+$/");
399+
$asserts[] = new Assert\Regex("/^[a-zA-Z0-9\\-_]+$/");
400400
$response = $this->validate($package_name, $asserts);
401401
if ($response instanceof Response) {
402402
return $response;

Controller/ProjectsController.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function projectProjectIdGetAction(Request $request, $project_id)
8787
$asserts = [];
8888
$asserts[] = new Assert\NotNull();
8989
$asserts[] = new Assert\Type("string");
90-
$asserts[] = new Assert\Regex("/^[a-zA-Z0-9-]+$/");
90+
$asserts[] = new Assert\Regex("/^[a-zA-Z0-9\\-]+$/");
9191
$response = $this->validate($project_id, $asserts);
9292
if ($response instanceof Response) {
9393
return $response;
@@ -189,7 +189,6 @@ public function projectsFeaturedGetAction(Request $request)
189189
}
190190
$asserts = [];
191191
$asserts[] = new Assert\Type("string");
192-
$asserts[] = new Assert\Regex("/[0-9]\\.[0-9]{3}/");
193192
$response = $this->validate($max_version, $asserts);
194193
if ($response instanceof Response) {
195194
return $response;
@@ -318,7 +317,6 @@ public function projectsGetAction(Request $request)
318317
}
319318
$asserts = [];
320319
$asserts[] = new Assert\Type("string");
321-
$asserts[] = new Assert\Regex("/[0-9]\\.[0-9]{3}/");
322320
$response = $this->validate($max_version, $asserts);
323321
if ($response instanceof Response) {
324322
return $response;
@@ -563,7 +561,6 @@ public function projectsSearchGetAction(Request $request)
563561
}
564562
$asserts = [];
565563
$asserts[] = new Assert\Type("string");
566-
$asserts[] = new Assert\Regex("/[0-9]\\.[0-9]{3}/");
567564
$response = $this->validate($max_version, $asserts);
568565
if ($response instanceof Response) {
569566
return $response;
@@ -677,7 +674,6 @@ public function projectsUserGetAction(Request $request)
677674
// Validate the input values
678675
$asserts = [];
679676
$asserts[] = new Assert\Type("string");
680-
$asserts[] = new Assert\Regex("/[0-9]\\.[0-9]{3}/");
681677
$response = $this->validate($max_version, $asserts);
682678
if ($response instanceof Response) {
683679
return $response;
@@ -795,14 +791,13 @@ public function projectsUserUserIdGetAction(Request $request, $user_id)
795791
$asserts = [];
796792
$asserts[] = new Assert\NotNull();
797793
$asserts[] = new Assert\Type("string");
798-
$asserts[] = new Assert\Regex("/^[a-zA-Z0-9-]+$/");
794+
$asserts[] = new Assert\Regex("/^[a-zA-Z0-9\\-]+$/");
799795
$response = $this->validate($user_id, $asserts);
800796
if ($response instanceof Response) {
801797
return $response;
802798
}
803799
$asserts = [];
804800
$asserts[] = new Assert\Type("string");
805-
$asserts[] = new Assert\Regex("/[0-9]\\.[0-9]{3}/");
806801
$response = $this->validate($max_version, $asserts);
807802
if ($response instanceof Response) {
808803
return $response;

Controller/UserController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function userIdGetAction(Request $request, $id)
225225
$asserts = [];
226226
$asserts[] = new Assert\NotNull();
227227
$asserts[] = new Assert\Type("string");
228-
$asserts[] = new Assert\Regex("/^[a-zA-Z0-9-]+$/");
228+
$asserts[] = new Assert\Regex("/^[a-zA-Z0-9\\-]+$/");
229229
$response = $this->validate($id, $asserts);
230230
if ($response instanceof Response) {
231231
return $response;

Resources/config/routing.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ open_api_server_mediaLibrary_mediapackagepackagenameget:
4242
defaults:
4343
_controller: open_api_server.controller.mediaLibrary:mediaPackagePackageNameGetAction
4444
requirements:
45-
package_name: '^[a-zA-Z0-9-_]+$'
45+
package_name: '^[a-zA-Z0-9\\-_]+$'
4646

4747
# projects
4848
open_api_server_projects_projectprojectidget:
@@ -51,7 +51,7 @@ open_api_server_projects_projectprojectidget:
5151
defaults:
5252
_controller: open_api_server.controller.projects:projectProjectIdGetAction
5353
requirements:
54-
project_id: '^[a-zA-Z0-9-]+$'
54+
project_id: '^[a-zA-Z0-9\\-]+$'
5555

5656
open_api_server_projects_projectsfeaturedget:
5757
path: /projects/featured
@@ -89,7 +89,7 @@ open_api_server_projects_projectsuseruseridget:
8989
defaults:
9090
_controller: open_api_server.controller.projects:projectsUserUserIdGetAction
9191
requirements:
92-
user_id: '^[a-zA-Z0-9-]+$'
92+
user_id: '^[a-zA-Z0-9\\-]+$'
9393

9494
# user
9595
open_api_server_user_userdelete:
@@ -110,7 +110,7 @@ open_api_server_user_useridget:
110110
defaults:
111111
_controller: open_api_server.controller.user:userIdGetAction
112112
requirements:
113-
id: '^[a-zA-Z0-9-]+$'
113+
id: '^[a-zA-Z0-9\\-]+$'
114114

115115
open_api_server_user_userpost:
116116
path: /user

0 commit comments

Comments
 (0)