name: coverage_report

on:
  schedule:
    - cron: '0 0 * * 5'
  workflow_dispatch:
env:
  CARGO_TARGET_DIR: ${{ github.workspace }}/../target
jobs:
  coverage_report:
    name: coverage_report
    runs-on: self-hosted-coverage_report-ubuntu-20.04
    if: |
        github.repository_owner == 'nervosnetwork'
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: 1.85.0
          components: rustfmt,llvm-tools-preview
      - run: sudo apt-get update && sudo apt-get install libssl-dev pkg-config libclang-dev -y && sudo apt-get install -y gcc-multilib build-essential
      - name: unit coverage
        run: make cov
      - name: integration cov
        run: make integration-cov
      - name: upload unit cov result to codecov.io
        uses: codecov/codecov-action@v2
        with:
          files: ${{github.workspace}}/lcov-unit-test.info
          flags: unit
          override_commit: ${{github.sha}}
      - name: upload integration cov result to codecov.io
        uses: codecov/codecov-action@v2
        with:
          files: ${{github.workspace}}/lcov-integration-test.info
          flags: integration
          override_commit: ${{github.sha}}
      - uses: actions/upload-artifact@v2
        with:
          name: coverage_report
          path: ${{github.workspace}}/*.info
          if-no-files-found: error
