|
| 1 | +# MIT License |
| 2 | +# Copyright (C) 2020 Tymko Oleg <olegtymko@yandex.ru> and contributors |
| 3 | +# All rights reserved. |
| 4 | + |
1 | 5 | name: Контроль качества |
2 | 6 |
|
3 | 7 | on: |
4 | 8 | push: |
5 | | - pull_request: |
| 9 | + pull_request_target: |
6 | 10 | workflow_dispatch: |
7 | 11 |
|
8 | 12 | jobs: |
9 | 13 | sonar: |
10 | 14 | if: github.repository == 'oscript-library/gitsync' |
11 | | - uses: autumn-library/workflows/.github/workflows/sonar.yml@main |
12 | | - with: |
13 | | - github_repository: oscript-library/gitsync |
14 | | - secrets: |
15 | | - SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + os: [ubuntu-22.04] |
| 20 | + oscript_version: ['1.9.2'] |
| 21 | + v8_version: ['8.3.24.1691'] |
| 22 | + locale: ['ru_RU'] |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Актуализация |
| 26 | + uses: actions/checkout@v4.2.2 |
| 27 | + with: |
| 28 | + repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} |
| 29 | + ref: ${{ github.event.pull_request.head.ref || github.ref_name }} |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + # https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions |
| 33 | + - name: Извлечение имени текущей ветки |
| 34 | + shell: bash |
| 35 | + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" |
| 36 | + id: extract_branch |
| 37 | + |
| 38 | + - name: Установка OneScript |
| 39 | + uses: otymko/setup-onescript@v1.5 |
| 40 | + with: |
| 41 | + version: ${{ matrix.oscript_version }} |
| 42 | + |
| 43 | + - name: Установка зависимостей |
| 44 | + run: | |
| 45 | + opm install opm |
| 46 | + opm install --dev |
| 47 | +
|
| 48 | + - name: Подготовка окружения (Linux) |
| 49 | + if: startsWith(matrix.os, 'ubuntu') |
| 50 | + run: | |
| 51 | + sudo apt-get update |
| 52 | + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y locales libwebkit2gtk-4.0-37 |
| 53 | + sudo localedef -i ${{ matrix.locale }} -c -f UTF-8 -A /usr/share/locale/locale.alias ${{ matrix.locale }}.UTF-8 |
| 54 | +
|
| 55 | + - name: Установка платформы 1С |
| 56 | + uses: 1CDevFlow/onec-setup-action@main |
| 57 | + with: |
| 58 | + type: onec # Тип устанавливаемого приложения |
| 59 | + onec_version: ${{ matrix.v8_version }} |
| 60 | + cache: true |
| 61 | + cache_distr: true |
| 62 | + env: |
| 63 | + ONEC_USERNAME: ${{ secrets.ONEC_USERNAME }} |
| 64 | + ONEC_PASSWORD: ${{ secrets.ONEC_PASSWORD }} |
| 65 | + |
| 66 | + - name: Установка лицензии (Linux) |
| 67 | + if: startsWith(matrix.os, 'ubuntu') |
| 68 | + run: | |
| 69 | + # Создание каталога |
| 70 | + sudo mkdir -p /var/1C/licenses |
| 71 | + |
| 72 | + # Запись лицензии в файл |
| 73 | + echo "${{ secrets.ONEC_LICENSE }}" | sudo tee /var/1C/licenses/licence.lic > /dev/null |
| 74 | + |
| 75 | + # Назначение прав |
| 76 | + sudo chmod 777 -R /var/1C/licenses |
| 77 | + shell: bash |
| 78 | + env: |
| 79 | + ONEC_LICENSE: ${{ secrets.ONEC_LICENSE }} |
| 80 | + |
| 81 | + - name: Покрытие кода |
| 82 | + uses: coactions/setup-xvfb@v1 |
| 83 | + env: |
| 84 | + GITSYNC_V8VERSION: ${{ matrix.v8_version }} |
| 85 | + with: |
| 86 | + run: opm run coverage |
| 87 | + |
| 88 | + - name: Извлечение версии пакета |
| 89 | + shell: bash |
| 90 | + run: echo "##[set-output name=version;]`cat packagedef | grep ".Версия(" | sed 's|[^"]*"||' | sed -r 's/".+//'`" |
| 91 | + id: extract_version |
| 92 | + |
| 93 | + - name: Установка sonar-scanner |
| 94 | + uses: warchant/setup-sonar-scanner@v8 |
| 95 | + |
| 96 | + - name: Анализ в SonarQube (branch) |
| 97 | + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' |
| 98 | + env: |
| 99 | + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} |
| 100 | + run: sonar-scanner |
| 101 | + -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} |
| 102 | + -Dsonar.branch.name=${{ steps.extract_branch.outputs.branch }} |
| 103 | + -Dsonar.projectVersion=${{ steps.extract_version.outputs.version }} |
| 104 | + |
| 105 | + # https://docs.sonarqube.org/latest/analysis/pull-request/ |
| 106 | + - name: Анализ в SonarQube (pull-request) |
| 107 | + if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' |
| 108 | + env: |
| 109 | + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} |
| 110 | + run: sonar-scanner |
| 111 | + -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} |
| 112 | + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} |
| 113 | + -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} |
| 114 | + -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} |
| 115 | + -Dsonar.scm.revision=${{ github.event.pull_request.head.sha }} |
0 commit comments