From 528c78935e3b69d50f78442b7cebe193283c7f20 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 17 Dec 2023 20:48:34 +0100 Subject: [PATCH 1/5] Migrate from Travis CI to GitHub Actions --- .editorconfig | 3 +++ .gitattributes | 2 +- .github/workflows/ci.yaml | 42 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 28 -------------------------- 4 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 .travis.yml diff --git a/.editorconfig b/.editorconfig index fd23ff9..57a1089 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,6 @@ indent_style = space indent_size = 4 trim_trailing_whitespace = true insert_final_newline = true + +[*.yaml] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 8374ab8..06ec962 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,5 @@ /.gitattributes export-ignore /.gitignore export-ignore -/.travis.yml export-ignore /.rmt.yml export-ignore /.styleci.yml export-ignore /behat.yml export-ignore @@ -10,6 +9,7 @@ /README.md export-ignore /CONTRIBUTING.md export-ignore /CHANGELOG export-ignore +/.github export-ignore /doc export-ignore /tests export-ignore /examples export-ignore diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..bb2ef0a --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,42 @@ +name: CI + +on: + pull_request: + push: + branches: + - master + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + strategy: + matrix: + php: [7.1, 7.2] + fail-fast: true + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --optimize-autoloader --no-interaction + + - run: make tests + + - run: make rusty diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8780005..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: php - -sudo: false - -cache: - directories: - - $HOME/.composer/cache - -branches: - only: - - master - -php: - - 7.1 - - 7.2 - -matrix: - fast_finish: true - -before_install: - - phpenv config-rm xdebug.ini || true - -install: - - composer install --optimize-autoloader --no-interaction - -script: - - make tests - - make rusty From f9318e46246bcfbaff6445a83e4d11bb1d86eb1b Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 17 Dec 2023 21:06:27 +0100 Subject: [PATCH 2/5] Drop support for PHP 7.1 --- .github/workflows/ci.yaml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bb2ef0a..1877592 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [7.1, 7.2] + php: [7.2] fail-fast: true steps: - uses: actions/checkout@v4 diff --git a/composer.json b/composer.json index 3ab54cf..b36e62a 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "bin-dir": "bin/" }, "require": { - "php": ">=7.1", + "php": ">=7.2", "hoa/ruler": "~2.0", "symfony/property-access": "~3.0|~4.0" From f92acc7962de7fa10fa2f9c800961597f6f6642f Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 17 Dec 2023 21:10:11 +0100 Subject: [PATCH 3/5] Remove coduo/phpspec-data-provider-extension --- composer.json | 1 - phpspec.yml | 2 - tests/spec/RulerZ/Parser/ParserSpec.php | 68 +++++++++---------- .../spec/RulerZ/Target/Native/NativeSpec.php | 9 ++- 4 files changed, 37 insertions(+), 43 deletions(-) diff --git a/composer.json b/composer.json index b36e62a..71d6d4b 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,6 @@ "ext-json": "*", "mikey179/vfsstream": "~1.4", - "coduo/phpspec-data-provider-extension": "~1.0,!=1.0.2", "phpspec/phpspec": "~2.0,>=2.4@dev", "behat/behat": "~3.0", diff --git a/phpspec.yml b/phpspec.yml index e19721e..2849816 100644 --- a/phpspec.yml +++ b/phpspec.yml @@ -3,5 +3,3 @@ suites: spec_path: %paths.config%/tests formatter.name: dot -extensions: - - Coduo\PhpSpec\DataProvider\DataProviderExtension diff --git a/tests/spec/RulerZ/Parser/ParserSpec.php b/tests/spec/RulerZ/Parser/ParserSpec.php index 1966322..a262102 100644 --- a/tests/spec/RulerZ/Parser/ParserSpec.php +++ b/tests/spec/RulerZ/Parser/ParserSpec.php @@ -16,56 +16,54 @@ public function it_is_initializable() $this->shouldHaveType(Parser::class); } - /** - * @dataProvider validRules - */ - public function it_returns_an_ast_for_a_valid_rule($rule) + public function it_returns_an_ast_for_a_valid_rule() { - $this->parse($rule)->shouldHaveType(Rule::class); + foreach ($this->validRules() as $rule) { + $this->parse($rule)->shouldHaveType(Rule::class); + } } - /** - * @dataProvider invalidRules - */ - public function it_throws_an_exception_for_an_invalid_rule($rule) + public function it_throws_an_exception_for_an_invalid_rule() { - $this->shouldThrow(Exception::class)->duringParse($rule); + foreach ($this->invalidRules() as $rule) { + $this->shouldThrow(Exception::class)->duringParse($rule); + } } public function validRules() { return [ - ['points > 30'], - ['some_point ∈ some_figure'], - ['some_point ∈ :some_figure'], - ['some_point ∈ ["some", "list", "of", "points"]'], - ['group(user) ∈ :allowed_groups'], - ['locked = false'], - ['admin = true'], - ['deleted_at = null'], - ['user.group = "members"'], - ["user.group = 'members'"], - ['user.group in ["members", "admins"]'], - ['length(name) = 4'], - ['distance(lat1, long1, lat2, long2) < 50'], - ['name = :user_name'], - ['name = ?'], - ['name = ? and group = ?'], - ['name = ? and group = :group'], - ['points > 30 and group = "member"'], - ['(points > 30 and group in ["member", "guest"]) or group = "admin"'], - ['not points > 30'], - ['a < -1'], - ['a > -0.05'], + 'points > 30', + 'some_point ∈ some_figure', + 'some_point ∈ :some_figure', + 'some_point ∈ ["some", "list", "of", "points"]', + 'group(user) ∈ :allowed_groups', + 'locked = false', + 'admin = true', + 'deleted_at = null', + 'user.group = "members"', + "user.group = 'members'", + 'user.group in ["members", "admins"]', + 'length(name) = 4', + 'distance(lat1, long1, lat2, long2) < 50', + 'name = :user_name', + 'name = ?', + 'name = ? and group = ?', + 'name = ? and group = :group', + 'points > 30 and group = "member"', + '(points > 30 and group in ["member", "guest"]) or group = "admin"', + 'not points > 30', + 'a < -1', + 'a > -0.05', ]; } public function invalidRules() { return [ - ['> 30'], - ['name[0] = "a"'], - ['name.foo() = "a"'], + '> 30', + 'name[0] = "a"', + 'name.foo() = "a"', ]; } diff --git a/tests/spec/RulerZ/Target/Native/NativeSpec.php b/tests/spec/RulerZ/Target/Native/NativeSpec.php index 515d27e..ddf7da4 100644 --- a/tests/spec/RulerZ/Target/Native/NativeSpec.php +++ b/tests/spec/RulerZ/Target/Native/NativeSpec.php @@ -32,12 +32,11 @@ public function it_supports_satisfaction_tests_for_arrays() $this->supports([], CompilationTarget::MODE_SATISFIES)->shouldReturn(true); } - /** - * @dataProvider unsupportedTypes - */ - public function it_can_not_filter_other_types($type) + public function it_can_not_filter_other_types() { - $this->supports($type, CompilationTarget::MODE_FILTER)->shouldReturn(false); + foreach ($this->unsupportedTypes() as $type) { + $this->supports($type, CompilationTarget::MODE_FILTER)->shouldReturn(false); + } } public function unsupportedTypes(): array From 5c8a32ddd1a2c3cabebee2761f1b5643ac81478b Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 17 Dec 2023 21:13:14 +0100 Subject: [PATCH 4/5] Bump phpspec/phpspec to 4.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 71d6d4b..01d49b4 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "ext-json": "*", "mikey179/vfsstream": "~1.4", - "phpspec/phpspec": "~2.0,>=2.4@dev", + "phpspec/phpspec": "~4.0", "behat/behat": "~3.0", From 0420ba07c3e16e816b8c440c37184cd8e58136fd Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 17 Dec 2023 21:15:34 +0100 Subject: [PATCH 5/5] Fix YAML syntax --- behat.yml | 2 +- phpspec.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/behat.yml b/behat.yml index e5d9576..9584ea1 100644 --- a/behat.yml +++ b/behat.yml @@ -7,5 +7,5 @@ default: suites: array: - paths: [ %paths.base%/tests/features/common, %paths.base%/features/operators, %paths.base%/tests/features/array ] + paths: [ '%paths.base%/tests/features/common', '%paths.base%/features/operators', '%paths.base%/tests/features/array' ] contexts: [ ArrayContext ] diff --git a/phpspec.yml b/phpspec.yml index 2849816..3a74ae4 100644 --- a/phpspec.yml +++ b/phpspec.yml @@ -1,5 +1,5 @@ suites: default: - spec_path: %paths.config%/tests + spec_path: '%paths.config%/tests' formatter.name: dot