From 66d112c24bad5f4ede045273fc9c5fc891c0e612 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 16 Nov 2020 16:30:24 +0100 Subject: [PATCH] Enhancement: Use GithubActions (#43) --- .github/main.workflow | 10 ---- .github/workflows/ci.yaml | 84 ++++++++++++++++++++++++++++++ .travis.yml | 33 ------------ Makefile | 2 +- composer.json | 5 +- phpunit.xml.dist | 4 +- src/Context/SonataAdminContext.php | 25 ++------- 7 files changed, 94 insertions(+), 69 deletions(-) delete mode 100644 .github/main.workflow create mode 100644 .github/workflows/ci.yaml delete mode 100644 .travis.yml diff --git a/.github/main.workflow b/.github/main.workflow deleted file mode 100644 index 685c0f6..0000000 --- a/.github/main.workflow +++ /dev/null @@ -1,10 +0,0 @@ -workflow "Lint" { - on = "push" - resolves = ["PHP-CS-Fixer"] -} - -action "PHP-CS-Fixer" { - uses = "docker://oskarstark/php-cs-fixer-ga" - secrets = ["GITHUB_TOKEN"] - args = "--diff --dry-run" -} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..8fcef98 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,84 @@ +on: + push: + branches: + - 'master' + pull_request: + +name: CI + +env: + SYMFONY_DEPRECATIONS_HELPER: weak_vendors + +jobs: + php-cs-fixer: + name: PHP-CS-Fixer + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: PHP-CS-Fixer + uses: docker://oskarstark/php-cs-fixer-ga:2.16.7 + with: + args: --diff --dry-run + + composer-normalize: + name: composer-normalize + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: composer-normalize + uses: docker://ergebnis/composer-normalize-action:0.8.0 + + test: + name: "PHP ${{ matrix.php-version }} + ${{ matrix.dependency }}" + + runs-on: ubuntu-latest + + continue-on-error: ${{ matrix.allowed_to_fail }} + + strategy: + matrix: + php-version: + - '7.1' + - '7.2' + - '7.3' + - '7.4' + dependency: + - 'lowest' + - 'highest' + allowed_to_fail: [false] + include: + - php-version: '8.0' + dependency: 'lowest' + allowed_to_fail: true + - php-version: '8.0' + dependency: 'highest' + allowed_to_fail: true + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v2 + + - name: Add PHPUnit matcher + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: "Composer install" + uses: "ramsey/composer-install@v1" + with: + dependency-versions: "${{ matrix.dependency }}" + + - name: "Run tests" + run: vendor/bin/phpunit diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 75625c3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: php -sudo: false - -cache: - directories: - - $HOME/.composer/cache/files - -env: - global: - - SYMFONY_DEPRECATIONS_HELPER=weak_vendors - - COMPOSER_MEMORY_LIMIT=-1 - -stages: - - test - -matrix: - fast_finish: true - include: - - stage: test - php: 7.1 - - stage: test - php: 7.2 - - stage: test - php: 7.3 - -install: - - composer install - -script: - - vendor/bin/phpunit - -notifications: - email: oskarstark@googlemail.com diff --git a/Makefile b/Makefile index 5821e27..9413f65 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ cs: - docker run --rm -it -w /app -v ${PWD}:/app oskarstark/php-cs-fixer-ga:latest + docker run --rm -it -w /app -v ${PWD}:/app oskarstark/php-cs-fixer-ga:2.16.7 diff --git a/composer.json b/composer.json index 7867325..52340e5 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": "^7.1", + "php": ">=7.1", "behat/behat": "^3.0", "behat/mink-extension": "^2.3", "behat/symfony2-extension": "^2.1", @@ -31,6 +31,9 @@ "phpunit/phpunit": "^6.0", "symfony/browser-kit": "^4.3" }, + "config": { + "sort-packages": true + }, "autoload": { "psr-4": { "OStark\\": "src/" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 88f6722..597b238 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,14 +2,14 @@ - + tests diff --git a/src/Context/SonataAdminContext.php b/src/Context/SonataAdminContext.php index 42b487c..a4e6f77 100644 --- a/src/Context/SonataAdminContext.php +++ b/src/Context/SonataAdminContext.php @@ -302,10 +302,7 @@ public function iShouldSeeFlashMessageWith($status, $message) $text = $flashMessage->getText(); if (!strstr($text, $message)) { - throw new ExpectationException( - sprintf('Could not find message "%s" in Flash-Message!', $message), - $this->getSession()->getDriver() - ); + throw new ExpectationException(sprintf('Could not find message "%s" in Flash-Message!', $message), $this->getSession()->getDriver()); } } @@ -398,10 +395,7 @@ public function iAmAuthenticatedAsUser($username) $user = $this->userManager->findOneBy(['username' => $username]); if (null === $user) { - throw new ExpectationException( - sprintf('User with username "%s" does not exist', $username), - $driver - ); + throw new ExpectationException(sprintf('User with username "%s" does not exist', $username), $driver); } $this->user = $user; @@ -655,8 +649,6 @@ public function theFieldShouldNotBeEmtpy($field) } /** - * @param UserInterface $user - * * @throws UnsupportedDriverActionException * * @codeCoverageIgnore Selenium2Driver needed @@ -698,10 +690,7 @@ private function getCurrentUser(): UserInterface $user = $this->userManager->findOneBy(['username' => self::DEFAULT_USERNAME]); if (null === $user) { - throw new ExpectationException( - sprintf('User with username "%s" does not exist', self::DEFAULT_USERNAME), - $this->getSession()->getDriver() - ); + throw new ExpectationException(sprintf('User with username "%s" does not exist', self::DEFAULT_USERNAME), $this->getSession()->getDriver()); } return $user; @@ -760,11 +749,6 @@ private function fixFilter(string $filter): string } /** - * @param string $locator - * @param string $type - * - * @return NodeElement - * * @throws ElementNotFoundException */ private function findElement(string $locator, string $type): NodeElement @@ -779,9 +763,6 @@ private function findElement(string $locator, string $type): NodeElement } /** - * @param string $locator - * @param string $type - * * @throws ExpectationException */ private function notFindElement(string $locator, string $type): void