Skip to content

ci: adjust finish-coverage-report job condition for strict workflow c… #20

ci: adjust finish-coverage-report job condition for strict workflow c…

ci: adjust finish-coverage-report job condition for strict workflow c… #20

Workflow file for this run

name: monorepo-main
concurrency:
group: main-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'main'
tags-ignore:
- 'main'
pull_request:
branches:
- 'main'
workflow_dispatch:
inputs:
strict:
description: 'Set to true to make the workflow fail on the first error'
required: false
default: 'false'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint all packages
uses: ./.github/actions/golangci-lint-monorepo-action
with:
go-version: '>=1.21.0'
golangci-lint-version: latest
list-modules:
needs: lint
runs-on: ubuntu-latest
outputs:
modules: ${{ steps.modulelist.outputs.modules }}
steps:
- uses: actions/checkout@v4
- name: Get monorepo modules
id: modulelist
uses: ./.github/actions/go-test-monorepo-action
with:
go-version: '>=1.21.0'
only-module-list: true
coverage:
needs: list-modules
strategy:
matrix:
module: ${{ fromJson(needs.list-modules.outputs.modules) }}
platform: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: ${{ github.event.inputs.strict == 'true' }}
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Run tests and generate coverage reports
id: modulelist
uses: ./.github/actions/go-test-monorepo-action
with:
go-version: '>=1.21.0'
- name: Check if coverage data exists
if: success() || failure()
id: check-coverage
working-directory: ${{ matrix.module }}
run: |
if [[ -f coverage.out && $(wc -l <coverage.out) -gt 1 ]]; then
echo "coverage_data_exists=true" >> $GITHUB_OUTPUT
else
echo "coverage_data_exists=false" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Prepare flag name
id: prepare-flag
run: |
module_path="${{ matrix.module }}"
if [ "$module_path" == "." ]; then
clean_module_name="happy"
else
clean_module_name="${module_path#./}"
fi
echo "clean_module_name=$clean_module_name" >> $GITHUB_OUTPUT
shell: bash
- name: Upload coverage
if: steps.check-coverage.outputs.coverage_data_exists == 'true'
uses: coverallsapp/github-action@v2
with:
flag-name: ${{ steps.prepare-flag.outputs.clean_module_name }}
parallel: true
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.module }}/coverage.out
finish-coverage-report:
needs: coverage
if: github.event.inputs.strict == 'false' || success()
runs-on: ubuntu-latest
steps:
- name: Coveralls Finish
uses: coverallsapp/github-action@v2
with:
parallel-finished: true