From 40f7793c28e3896a5c6d4a01f1a2b31d07acae33 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Wed, 10 Apr 2024 12:45:46 +0200 Subject: [PATCH] Add GHA CI --- .github/workflows/test.yml | 60 +++++++++++++++++++++++++++++++++++ .gitlab-ci.yml | 64 -------------------------------------- 2 files changed, 60 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8a1a8a1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,60 @@ +name: Test + +on: + pull_request: + push: + workflow_dispatch: + +env: + COMPOSER_CACHE_DIR: /tmp/_composer_cache + +jobs: + unit-tests: + name: Tests for php${{ matrix.php-versions }} + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3'] + steps: + - name: Set up php${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: ctype,curl,dom,gd,iconv,intl,json,mbstring,openssl,posix,sqlite,xml,zip,gmp + coverage: xdebug + - name: Checkout code + uses: actions/checkout@v4 + - name: Cache composer cache directory + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: composer-cache + - name: Unit tests + run: | + composer install + composer test + linting: + name: Linting + runs-on: ubuntu-latest + steps: + - name: Set up php${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + extensions: ctype,curl,dom,gd,iconv,intl,json,mbstring,openssl,posix,sqlite,xml,zip,gmp + coverage: xdebug + - name: Checkout code + uses: actions/checkout@v4 + - name: Cache composer cache directory + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: composer-cache + - name: Unit tests + run: | + composer install + result=0 + composer run cs || result=1 + composer run phpstan || result=1 + composer run psalm || result=1 + exit $result diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 4b5e8ca..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,64 +0,0 @@ -image: registry.gitlab.tugraz.at/dbp/relay/docker-images/main:v1 - -before_script: - - 'git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.tugraz.at/".insteadOf "git@gitlab.tugraz.at:"' - -variables: - COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/_composer_cache" - -cache: - key: ${CI_PROJECT_PATH} - paths: - - _composer_cache - -stages: - - test - -.test_defaults: &test_defaults - script: - - sudo update-alternatives --set php "/usr/bin/${PHP}" - - composer validate - - composer install - - composer test - -.test_lowest: &test_lowest - script: - - sudo update-alternatives --set php "/usr/bin/${PHP}" - - composer validate - - composer update --prefer-lowest --prefer-dist --prefer-stable --no-interaction - - composer test - -test-php8.1-lowest: - stage: test - variables: - PHP: "php8.1" - <<: *test_lowest - -test-php8.1: - stage: test - variables: - PHP: "php8.1" - <<: *test_defaults - -test-php8.2: - stage: test - variables: - PHP: "php8.2" - <<: *test_defaults - -test-php8.3: - stage: test - variables: - PHP: "php8.3" - <<: *test_defaults - -linting: - stage: test - script: - - sudo update-alternatives --set php /usr/bin/php8.1 - - composer install - - result=0 - - composer run cs || result=1 - - composer run phpstan || result=1 - - composer run psalm || result=1 - - exit $result \ No newline at end of file