From 5447507cd59bca4947571af806935e85bc629d0c Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Wed, 4 Sep 2024 12:56:46 -0500 Subject: [PATCH] CI initial workflow (#2) --- .github/workflows/ci.yml | 76 ++++------------------------------------ composer.json | 16 ++++----- phpcs.xml.dist | 10 +++--- phpstan.neon | 4 +++ phpunit.xml.dist | 25 +++++++------ 5 files changed, 38 insertions(+), 93 deletions(-) create mode 100644 phpstan.neon diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a86de3..19f7e63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,75 +1,13 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions +name: CI on: push: - branches: [ '**' ] pull_request: - branches: [ '**' ] - -name: "CI" + workflow_dispatch: jobs: - tests: - name: "Tests" - - runs-on: "ubuntu-latest" - - env: - php_extensions: ctype, dom, fileinfo, hash, intl, mbstring, session, simplexml, tokenizer, xml, pdo, mysqli, gd, zip - - services: - mysql: - image: "mysql:5.7" - env: - MYSQL_ALLOW_EMPTY_PASSWORD: true - MYSQL_ROOT_PASSWORD: - MYSQL_DATABASE: test_db - ports: - - 3306/tcp - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - - strategy: - fail-fast: false - matrix: - php-version: - - "7.4" - - "8.0" - - "8.1" - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.php_extensions }}" - coverage: "xdebug" - - - name: "Start mysql service" - run: "sudo /etc/init.d/mysql start" - - - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1" - with: - path: "~/.composer/cache" - key: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}" - restore-keys: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" - - - name: "Install dependencies with composer" - run: "composer install --no-ansi --no-interaction --no-progress" - - - name: "Run tests with phpunit/phpunit" - env: - SS_DATABASE_PORT: ${{ job.services.mysql.ports['3306'] }} - run: "vendor/bin/phpunit --coverage-clover=coverage.xml" - - - name: "Upload coverage results to CodeCov" - uses: codecov/codecov-action@v1 - with: - files: ./coverage.xml # optional - flags: unittests # optional - - - name: "Run tests with squizlabs/php_codesniffer" - run: "vendor/bin/phpcs -s --report=summary --standard=phpcs.xml.dist --extensions=php,inc --ignore=autoload.php --ignore=vendor/ src/ tests/" + ci: + name: CI + uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 + with: + phpcoverage: true diff --git a/composer.json b/composer.json index a6eb33e..e74ea30 100644 --- a/composer.json +++ b/composer.json @@ -1,31 +1,29 @@ { "name": "dynamic/silverstripe-elemental-locations", "description": "A locations block for Silverstripe. Display one or more locations on a map.", + "license": "BSD-3-Clause", "type": "silverstripe-vendormodule", "keywords": [ "silverstripe", "CMS" ], - "license": "BSD-3-Clause", "require": { - "dnadesign/silverstripe-elemental": "^4.8", - "symbiote/silverstripe-addressable": "^5.0" + "dnadesign/silverstripe-elemental": "^5.0" }, "require-dev": { - "silverstripe/recipe-testing": "^2", - "squizlabs/php_codesniffer": "^3.0" + "silverstripe/recipe-testing": "^3" }, + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-4": { "Dynamic\\Elements\\Locations\\": "src/", - "Dynamic\\Elements\\Blog\\Locations\\": "tests/" + "Dynamic\\Elements\\Locations\\Test\\": "tests/" } }, "extra": { "branch-alias": { "dev-master": "1.x-dev" } - }, - "minimum-stability": "dev", - "prefer-stable": true + } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index fe58f6f..488aba4 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,11 +1,13 @@ - - CodeSniffer ruleset for SilverStripe coding conventions. + + CodeSniffer ruleset for Silverstripe coding conventions. + + src + tests - - + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..2e09595 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 4 + paths: + - src diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a5ec7a1..854e0be 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,16 @@ - - - tests/ - - - + + + + src/ - - tests/ - - - + + + tests/ + + + + + tests/ + +