Skip to content

Commit

Permalink
test: Добавлена настройка проверки покрытия и отправки в Sonar.
Browse files Browse the repository at this point in the history
  • Loading branch information
arkuznetsov committed Oct 29, 2020
1 parent 08f7984 commit e4185f8
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 2 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# MIT License
# Copyright (C) 2020 Tymko Oleg <[email protected]> and contributors
# All rights reserved.

name: Контроль качества
# Любой пуш и pr в проекте но с фильтром по основному проекту
on: [push, pull_request]
jobs:
build:
if: github.repository == 'owner/project'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
oscript_version: ['1.4.0']

steps:
# Загрузка проекта
- name: Актуализация
uses: actions/checkout@v2

# https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions
- name: Извлечение имени текущей ветки
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

# Установка OneScript конкретной версии
- name: Установка OneScript
uses: otymko/[email protected]
with:
version: ${{ matrix.oscript_version }}

# Установка зависимостей пакета
- name: Установка зависимостей
run: |
opm install opm
opm install --dev
# Запуск тестов и сбор покрытия кода
- name: Покрытие кода
run: oscript ./tasks/coverage.os

- name: Извлечение версии пакета
shell: bash
run: echo "##[set-output name=version;]`cat packagedef | grep ".Версия(" | sed 's|[^"]*"||' | sed -r 's/".+//'`"
id: extract_version

- name: Установка Sonar-scanner
uses: warchant/setup-sonar-scanner@v1

# Анализ проекта в SonarQube (ветка)
- name: Анализ в SonarQube (branch)
if: github.event_name == 'push'
run: sonar-scanner
-Dsonar.login=${{ secrets.SONARQUBE_TOKEN }}
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
-Dsonar.branch.name=${{ steps.extract_branch.outputs.branch }}
-Dsonar.projectVersion=${{ steps.extract_version.outputs.version }}

# Анализ проекта в SonarQube (PR)
# https://docs.sonarqube.org/latest/analysis/pull-request/
- name: Анализ в SonarQube (pull-request)
if: github.event_name == 'pull_request'
run: sonar-scanner
-Dsonar.login=${{ secrets.SONARQUBE_TOKEN }}
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
-Dsonar.branch.name=${{ steps.extract_branch.outputs.branch }}
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
-Dsonar.scm.revision=${{ github.event.pull_request.head.sha }}
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# must be unique in a given SonarQube instance
sonar.projectKey=yabr.os
sonar.projectKey=yabr

# this is the name displayed in the SonarQube UI
sonar.projectName=yabr.os
Expand All @@ -17,4 +17,4 @@ sonar.sourceEncoding=UTF-8

sonar.coverageReportPaths=coverage/genericCoverage.xml

sonar.testExecutionReportPaths=test-reports/tests.xml
# sonar.testExecutionReportPaths=test-reports/tests.xml

0 comments on commit e4185f8

Please sign in to comment.