Skip to content

Commit

Permalink
Simplify workflow to run unit and integration tests together
Browse files Browse the repository at this point in the history
This is needed because of our php requirements and phpunit version of the shop. Coverage merging on php 8.1 doesnt work with phpunit 9. Also, unit tests are running in several seconds, installing separate run just for those seconds is not adequate. Locally it still can be run separately for fast check, but also running all integrations doesnt take long as well.

Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Oct 2, 2023
1 parent 3593810 commit 4b43080
Showing 1 changed file with 14 additions and 100 deletions.
114 changes: 14 additions & 100 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ jobs:
path: |
source/test-module/phpstan.report.json
integration_tests:
unit_integration_tests:
needs: [ install_shop_with_module ]
runs-on: ubuntu-latest
steps:
Expand All @@ -243,62 +243,16 @@ jobs:
-e XDEBUG_MODE=coverage \
--workdir=/var/www/test-module \
php composer phpunit -- \
--testsuite=Integration \
--coverage-text \
--coverage-php=/var/www/integration.cov
--coverage-clover=/var/www/integration.xml
- name: Upload log artifact
if: always()
uses: actions/upload-artifact@v3
with:
name: ModuleIntegrationTestsLog-${{ inputs.php }}-${{ inputs.mysql }}
path: |
source/integration.cov
source/source/log/oxideshop.log
data/php/logs/error_log.txt
- name: Stop containers
if: always()
run: |
docker-compose down
sleep 2
unit_tests:
needs: [ install_shop_with_module ]
runs-on: ubuntu-latest
steps:
- name: Load current installation from cache
uses: actions/cache@v3
with:
path: |
./*
key: installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
restore-keys: |
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}
- name: Start containers
run: |
make up
sleep 2
- name: Run tests
run: |
docker-compose exec -T \
-e XDEBUG_MODE=coverage \
--workdir=/var/www/test-module \
php composer phpunit -- \
--testsuite=Unit \
--coverage-text \
--coverage-php=/var/www/unit.cov
- name: Upload log artifact
if: always()
uses: actions/upload-artifact@v3
with:
name: ModuleUnitTestsLog-${{ inputs.php }}-${{ inputs.mysql }}
path: |
source/unit.cov
source/integration.xml
source/source/log/oxideshop.log
data/php/logs/error_log.txt
Expand Down Expand Up @@ -360,55 +314,8 @@ jobs:
make down
sleep 2
prepare_coverage_results:
needs: [ unit_tests, integration_tests ]
if: ${{ always() && inputs.report_sonarcloud }}
runs-on: ubuntu-latest
steps:
- name: Load current installation from cache
uses: actions/cache@v3
with:
path: |
./*
key: installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
restore-keys: |
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}
- name: Download unit artifacts
uses: actions/download-artifact@v3
with:
name: ModuleUnitTestsLog-${{ inputs.php }}-${{ inputs.mysql }}
path: ./source/coverage/

- name: Download integration artifacts
uses: actions/download-artifact@v3
with:
name: ModuleIntegrationTestsLog-${{ inputs.php }}-${{ inputs.mysql }}
path: ./source/coverage/

- name: Start containers
run: |
make up
sleep 2
- name: Collect and merge coverage reports
continue-on-error: true
run: |
ls -alh source/coverage
wget https://phar.phpunit.de/phpcov-8.2.1.phar
mv phpcov-8.2.1.phar source/phpcov.phar
docker-compose exec -T php php phpcov.phar merge --clover coverage.xml ./coverage
sed -i 's+/var/www/test-module/+./+' source/coverage.xml
- name: Upload log artifact
uses: actions/upload-artifact@v3
with:
name: TestsLog-${{ inputs.php }}-${{ inputs.mysql }}
path: source/coverage.xml

sonarcloud:
needs: [ prepare_coverage_results ]
needs: [ unit_integration_tests ]
if: ${{ always() && inputs.report_sonarcloud }}
runs-on: ubuntu-latest
steps:
Expand All @@ -419,8 +326,15 @@ jobs:
continue-on-error: true
uses: actions/download-artifact@v3
with:
name: TestsLog-${{ inputs.php }}-${{ inputs.mysql }}
path: ./tests/
name: ModuleCodeceptionTestsLog-${{ inputs.php }}-${{ inputs.mysql }}
path: ./

- name: List file structure
if: always()
run: |
ls -alh
cd source
ls -alh
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
Expand All @@ -434,6 +348,6 @@ jobs:
-Dsonar.sources=src
-Dsonar.tests=tests
-Dsonar.sourceEncoding=UTF-8
-Dsonar.php.coverage.reportPaths=tests/coverage.xml
-Dsonar.php.coverage.reportPaths=source/coverage.xml
-Dsonar.cpd.php.minimumTokens=25
-Dsonar.cpd.php.minimumLines=5

0 comments on commit 4b43080

Please sign in to comment.