-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Kafka Messenger] Added SonarCloud checks, refactor GitHub actions
[Kafka Messenger] Added SonarCloud checks, refactor GitHub actions [Kafka Messenger] Added SonarCloud checks, refactor GitHub actions
- Loading branch information
1 parent
b4f8bc5
commit b39e905
Showing
6 changed files
with
167 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
- 'releases/**' | ||
paths-ignore: | ||
- '**/*.md' | ||
- '**/*.gitignore' | ||
- '**/*.gitattributes' | ||
|
||
pull_request: | ||
types: | ||
- published | ||
- created | ||
- edited | ||
- opened | ||
- synchronize | ||
- reopened | ||
paths-ignore: | ||
- '**/*.md' | ||
- '**/*.gitignore' | ||
- '**/*.gitattributes' | ||
|
||
jobs: | ||
build: | ||
name: PHP | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
php: | ||
- "8.1" | ||
- "8.2" | ||
include: | ||
- php-versions: ["8.1", "8.2"] | ||
- composer-options: "--ignore-platform-reqs" | ||
|
||
services: | ||
kafka: | ||
image: lensesio/fast-data-dev | ||
env: | ||
ADV_HOST: 127.0.0.1 | ||
SAMPLEDATA: 0 | ||
RUNTESTS: 0 | ||
FORWARDLOGS: 0 | ||
ports: | ||
- 9092:9092 | ||
- 8081:8081 | ||
- 8082:8082 | ||
- 8083:8083 | ||
- 2181:2181 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install rdkafka | ||
run: sudo add-apt-repository universe && sudo apt update && sudo apt install netcat librdkafka1 librdkafka-dev | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: "${{ matrix.php }}" | ||
extensions: mbstring, intl, rdkafka | ||
coverage: xdebug | ||
tools: pecl, phpunit, composer | ||
ini-values: post_max_size=256M | ||
env: | ||
MESSENGER_KAFKA_DSN: ${{ secrets.MESSENGER_KAFKA_DSN }} | ||
MESSENGER_KAFKA_DEBUG: ${{ secrets.MESSENGER_KAFKA_DEBUG }} | ||
|
||
- name: Check Kafka Extension | ||
run: php -v && php --ri rdkafka | ||
|
||
- name: Setup composer | ||
uses: ramsey/composer-install@v1 | ||
with: | ||
composer-options: "${{ matrix.composer-options }}" | ||
|
||
- name: Validate composer files | ||
run: composer validate | ||
|
||
- name: Cache composer packages | ||
id: composer-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
- name: Install dependencies | ||
if: steps.composer-cache.outputs.cache-hit != 'true' | ||
run: composer update --prefer-dist --no-progress | ||
|
||
- name: Wait for Kafka | ||
run: .github/workflows/wait-for-kafka.sh -s localhost -p 2181 | ||
|
||
- name: Execute unit tests | ||
run: ./vendor/bin/phpunit --colors=always --configuration phpunit.xml.dist --coverage-cobertura tests-cobertura.xml --coverage-clover tests-coverage.xml --log-junit tests-execution.xml | ||
env: | ||
MESSENGER_KAFKA_DSN: ${{ secrets.MESSENGER_KAFKA_DSN }} | ||
MESSENGER_KAFKA_DEBUG: ${{ secrets.MESSENGER_KAFKA_DEBUG }} | ||
|
||
- name: Setup coverages and logs directories | ||
run: mkdir -p build/logs | ||
|
||
- name: Prepare coverages and logs | ||
run: cp tests-coverage.xml build/logs/clover.xml && cp tests-cobertura.xml build/logs/cobertura.xml && cp tests-execution.xml build/logs/junit.xml | ||
|
||
- name: Push to Coveralls | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COVERALLS_PARALLEL: true | ||
COVERALLS_FLAG_NAME: php-${{ matrix.php-versions }} | ||
run: | | ||
composer global require php-coveralls/php-coveralls | ||
php-coveralls -v | ||
- name: SonarCloud scan | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
with: | ||
projectBaseDir: ${{ github.workspace }} | ||
|
||
finish: | ||
needs: [ build ] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Coveralls Finished | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
parallel-finished: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sonar.projectKey=fractalzombie_frzb-kafka-messenger | ||
sonar.organization=fractalzombie | ||
sonar.projectName=frzb-kafka-messenger | ||
sonar.sources=Enum,Exception,Helper,Integration,Transport | ||
sonar.sourceEncoding=UTF-8 | ||
sonar.tests=Tests | ||
sonar.exclusions=Resources/**,.docker/**,.github/**,vendor/** | ||
sonar.php.coverage.reportPaths=tests-coverage.xml | ||
sonar.php.tests.reportPath=tests-execution.xml | ||
verbose=true |