Parcourir la source

Test GitHub Actions

shalvah il y a 3 ans
Parent
commit
620a6b46da

+ 41 - 0
.github/workflows/lint.yml

@@ -0,0 +1,41 @@
+name: Tests
+
+on:
+  push:
+    branches:
+      - master
+  pull_request:
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        php:
+        - 7.4.7
+
+    name: Lint code (PHP ${{ matrix.php }})
+
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v2
+
+      - name: Setup PHP
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: ${{ matrix.php }}
+          extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, intl, gd
+
+      - name: Cache composer dependencies
+        uses: actions/cache@v2
+        with:
+          path: vendor
+          key: composer-${{ hashFiles('composer.lock') }}
+
+      - name: Install dependencies
+        run: composer install
+
+      - name: Lint code
+        env:
+          COMPOSER_MEMORY_LIMIT: "-1"
+        run: composer lint

+ 45 - 0
.github/workflows/run-tests.yml

@@ -0,0 +1,45 @@
+name: Tests
+
+on: [push, pull_request]
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        php:
+        - 7.4
+        - 8.0
+        deps: [stable, lowest, dingo]
+
+    name: Tests (PHP ${{ matrix.php }} - ${{ matrix.deps }})
+
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v2
+
+      - name: Setup PHP
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: ${{ matrix.php }}
+          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
+          coverage: none
+
+      - name: Install dependencies
+        if: ${{ matrix.deps == 'stable' }}
+        run: composer update --prefer-stable;
+
+      - name: Install dependencies (Dingo)
+        if: ${{ matrix.deps == 'dingo' }}
+        env:
+          COMPOSER: composer.dingo.json
+        run: composer update --prefer-stable;
+
+      - name: Install dependencies (lowest)
+        if: ${{ matrix.deps == 'lowest' }}
+        env:
+          LOWEST: "6.0"
+        run: composer require laravel/framework:^$LOWEST; composer require laravel/lumen-framework:^$LOWEST
+
+      - name: Execute tests
+        run: composer test-parallel-ci

+ 1 - 1
src/Extracting/Extractor.php

@@ -369,7 +369,7 @@ class Extractor
         if ($this->config->get('faker_seed')) {
             $faker->seed($this->config->get('faker_seed'));
         }
-        $token = $faker->shuffle('abcdefghkvaZVDPE1864563');
+        $token = $faker->shuffleString('abcdefghkvaZVDPE1864563');
         $valueToUse = $this->config->get('auth.use_value');
         $valueToDisplay = $this->config->get('auth.placeholder');
 

+ 7 - 2
tests/GenerateDocumentationTest.php

@@ -320,6 +320,7 @@ class GenerateDocumentationTest extends BaseLaravelTest
         RouteFacade::get('/api/action1', [TestGroupController::class, 'action1']);
         RouteFacade::get('/api/action1b', [TestGroupController::class, 'action1b']);
         config(['scribe.routes.0.match.prefixes' => ['api/*']]);
+        config(['scribe.routes.0.apply.response_calls.methods' => []]);
 
         $this->artisan('scribe:generate');
 
@@ -373,6 +374,7 @@ class GenerateDocumentationTest extends BaseLaravelTest
             ]);
         });
         config(['scribe.routes.0.match.prefixes' => ['*']]);
+        config(['scribe.routes.0.apply.response_calls.methods' => []]);
 
         $this->artisan('scribe:generate');
 
@@ -396,8 +398,8 @@ class GenerateDocumentationTest extends BaseLaravelTest
         [$intro, $auth] = $crawler->filter('h1 + p')->getIterator();
         $this->assertEquals('Heyaa introduction!👋', trim($intro->firstChild->textContent));
         $this->assertEquals('This is just a test.', trim($auth->firstChild->textContent));
-        $endpoints = $crawler->filter('h1')->getNode(2);
-        $this->assertEquals('General', trim($endpoints->textContent));
+        $group = $crawler->filter('h1')->getNode(2);
+        $this->assertEquals('General', trim($group->textContent));
         $expectedEndpoint = $crawler->filter('h2');
         $this->assertCount(1, $expectedEndpoint);
         $this->assertEquals("Healthcheck", $expectedEndpoint->text());
@@ -409,6 +411,7 @@ class GenerateDocumentationTest extends BaseLaravelTest
         RouteFacade::get('/api/action1', [TestGroupController::class, 'action1']);
         RouteFacade::get('/api/action2', [TestGroupController::class, 'action2']);
         config(['scribe.routes.0.match.prefixes' => ['api/*']]);
+        config(['scribe.routes.0.apply.response_calls.methods' => []]);
         if (!is_dir('.scribe/endpoints'))
             mkdir('.scribe/endpoints', 0777, true);
         copy(__DIR__ . '/Fixtures/custom.0.yaml', '.scribe/endpoints/custom.0.yaml');
@@ -438,6 +441,7 @@ class GenerateDocumentationTest extends BaseLaravelTest
         RouteFacade::get('/api/action1b', [TestGroupController::class, 'action1b']);
         RouteFacade::get('/api/action2', [TestGroupController::class, 'action2']);
         config(['scribe.routes.0.match.prefixes' => ['api/*']]);
+        config(['scribe.routes.0.apply.response_calls.methods' => []]);
 
         $this->artisan('scribe:generate');
 
@@ -497,6 +501,7 @@ class GenerateDocumentationTest extends BaseLaravelTest
          */
         RouteFacade::post('nested-file', fn() => null);
         config(['scribe.routes.0.match.prefixes' => ['*']]);
+        config(['scribe.routes.0.apply.response_calls.methods' => []]);
 
         $this->artisan('scribe:generate');