coroo / pytest-coverage-commentator

A Github action to comments a Pytest Coverage on PR
MIT License
46 stars 16 forks source link

Workflow failed! Resource not accessible by integration #30

Open krkeegan opened 3 years ago

krkeegan commented 3 years ago

I am getting the error Workflow failed! Resource not accessible by integration

I am using the following workflow. Everything works fine if I comment out the Comment Coverage step.

name: Linting and Pytest

on:
  pull_request:
    branches:
      - dev

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.8
      uses: actions/setup-python@v2
      with:
        python-version: 3.8
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install flake8 pytest
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
        if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
    - name: Lint with flake8 exit on errors
      run: |
        # stop the build if there are Python syntax errors or undefined names
        flake8 app --count --select=E9,F63,F7,F82 --show-source --statistics
    - name: Test with pytest
      run: |
        # Skips creating coverage stats for covered items
        pytest --cache-clear --cov-report term:skip-covered --cov=app tests/ | tee pytest-coverage.txt
     - name: Comment coverage
       uses: coroo/pytest-coverage-commentator@v1.0.2
       with:
         pytest-coverage: pytest-coverage.txt
coroo commented 3 years ago

Hi @krkeegan ,

I think the problem since you not create pytest-coverage.txt. Please use:

    - name: Build coverage file
      run: |
        pytest --cache-clear --cov=app test/ > pytest-coverage.txt
    - name: Comment coverage
      uses: coroo/pytest-coverage-commentator@v1.0.2

I think for your case should be:

    - name: Test with pytest
      run: |
        pytest --cache-clear --cov-report term:skip-covered --cov=app tests/ > pytest-coverage.txt
    - name: Comment coverage
      uses: coroo/pytest-coverage-commentator@v1.0.2
krkeegan commented 3 years ago

Hmm piping the output to tee should be creating pytest-coverge.txt. It certainly does locally. I would prefer to tee the output so that I can still get the failures in the terminal output.

MishaKav commented 3 years ago

Have the same issue. Found solution on similar GitHub Action: Pytest Coverage Comment It uses tee in every example :)