diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index 9ba803d..23f3dcd 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -17,24 +17,25 @@ on: test_script_path: required: false type: string - default: ./tasks/coverage.os + default: ./tasks/coverage.os + codecov: + required: false + type: boolean + default: false secrets: SONAR_TOKEN: required: false + CODECOV_TOKEN: + required: false jobs: - sonar: + test: if: (github.repository == ${{ inputs.github_repository }} ) && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.event.repository.full_name) runs-on: ubuntu-latest steps: - name: Актуализация uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Вычисление имени ветки - uses: nelonoel/branch-name@v1.0.1 - name: Вычисление версии OneScript shell: bash @@ -63,6 +64,23 @@ jobs: - name: Запуск тестов run: oscript ${{ inputs.test_script_path }} + sonar: + runs-on: ubuntu-latest + needs: [test] + steps: + - name: Актуализация + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Вычисление имени ветки + uses: nelonoel/branch-name@v1.0.1 + + - name: Скачивание артефактов + uses: actions/download-artifact@v4 + with: + name: coverage + - name: Извлечение версии пакета shell: bash run: echo "version=`cat packagedef | grep ".Версия(" | sed 's|[^"]*"||' | sed -r 's/".+//'`" >> $GITHUB_OUTPUT @@ -93,3 +111,24 @@ jobs: -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 }} + + + coverage: + runs-on: ubuntu-latest + needs: [test] + if: ${{ inputs.github_repository }} == true + steps: + - name: Актуализация + uses: actions/checkout@v4 + + - name: Скачивание артефактов + uses: actions/download-artifact@v4 + with: + name: coverage + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: autumn-library/autumn + + \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12fae4f..39bb613 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,9 +11,20 @@ on: required: false type: string default: ./tasks/test.os + test_script_args: + required: false + type: string + default: "" + junit_report_path: + required: false + type: string + default: "out/JUnit" jobs: build: + # permissions: + # checks: write + # pull-requests: write runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -57,4 +68,43 @@ jobs: opm install -l --dev - name: Тестирование - run: oscript ${{ inputs.test_script_path}} + run: oscript ${{ inputs.test_script_path}} ${{ inputs.test_script_args }} + + - name: Загрузка артефактов тестирования + if: always() + uses: actions/upload-artifact@v4 + with: + name: Test Results (oscript ${{ matrix.oscript_version }} on ${{ matrix.os }}) + path: ${{ inputs.junit_report_path }} + if-no-files-found: ignore + + publish-test-results: + name: "Publish Tests Results" + needs: build + runs-on: ubuntu-latest + permissions: + checks: write + pull-requests: write + # only needed for private repository + # contents: read + # only needed for private repository + # issues: read + if: always() + + steps: + - name: Скачивание артефактов тестирования + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Проверка существования директории с результатами тестов + id: check_files + uses: andstor/file-existence-action@v2 + with: + files: artifacts/**/*.xml + + - name: Сохранение результатов тестирования + if: steps.check_files.outputs.files_exists == 'true' + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + files: "artifacts/**/*.xml"