From 5aefe8449530808f10c9ab67392763701ac3e0a7 Mon Sep 17 00:00:00 2001 From: David Callizaya Date: Tue, 25 Jun 2024 21:06:22 -0400 Subject: [PATCH] Add tests to github action --- .circleci/config.yml | 10 ++++---- .github/workflows/sonarqube.yml | 42 +++++++++++++++++++++++++++++---- phpunit.xml | 16 ++++++++++--- sonar-project.properties | 3 +++ 4 files changed, 59 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c3d14393..6d97748c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,10 +3,13 @@ version: 2 jobs: build: docker: - - image: circleci/php:7.1-node-browsers + - image: php:8.2.0-fpm steps: - checkout - - run: sudo composer self-update + - run: apt-get update && apt-get install -y git unzip + - run: pecl install xdebug && docker-php-ext-enable xdebug + - run: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + - run: composer self-update - restore_cache: keys: - composer-v1-{{ checksum "composer.json" }} @@ -16,8 +19,7 @@ jobs: key: composer-v1-{{ checksum "composer.json" }} paths: - vendor - - run: sudo docker-php-ext-enable xdebug - run: ./vendor/bin/phpunit -d memory_limit=-1 --coverage-html coverage - run: ./check_coverage.php - store_artifacts: - path: coverage + path: coverage \ No newline at end of file diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 3980790a..64775419 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -4,17 +4,49 @@ on: push: branches: - develop + - next pull_request: - types: [opened, synchronize, reopened] + types: [opened, synchronize, reopened, edited] jobs: - build: - name: Scan + test: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Update Composer + run: sudo composer self-update + + - name: Cache Composer dependencies + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: composer-v1-${{ hashFiles('composer.json') }} + restore-keys: | + composer-v1- + + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + php-version: "8.2" + extensions: xdebug + coverage: xdebug + ini-values: xdebug.mode=coverage + + - name: Install Composer dependencies + run: composer install -n --prefer-dist + + - name: Run PHPUnit tests + run: ./vendor/bin/phpunit -d memory_limit=-1 + + - name: List coverage files + run: ls -l coverage + - uses: sonarsource/sonarqube-scan-action@master env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/phpunit.xml b/phpunit.xml index 5c977b2d..9484a66e 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,13 +1,23 @@ - - + + + + + + - ./src + src + tests/Feature + + tests/unit diff --git a/sonar-project.properties b/sonar-project.properties index 48a651e5..f6d6d464 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1 +1,4 @@ sonar.projectKey=ProcessMaker_nayra_AYq58Vs2xYvY_isvKv_4 +sonar.php.coverage.reportPaths=./coverage/clover.xml +sonar.sources=src +sonar.tests=tests