Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging comment content #422

Closed
rsard-ckt opened this issue Jun 4, 2024 · 3 comments
Closed

Logging comment content #422

rsard-ckt opened this issue Jun 4, 2024 · 3 comments

Comments

@rsard-ckt
Copy link

I'm creating a workflow for a private repository using the Basic usage without external contributors yml as an example. The coverage.json file appears to have been created as expected (I added an extra step after py-cov-action/python-coverage-comment-action@v3.23 that runs coverage json -o coverage.json and then uploaded it to Github). But the comment continues to be generated with a 100% wrong coverage rate.

Investigating the package code, I was unable to discover the possible error. Is it possible to add logs that print the comment or coverage variables in the process_pr method? This will help me a lot.

Captura de Tela 2024-06-04 às 20 17 40

The totals attribute from the coverage.json is:

"totals": {"covered_lines": 16602, "num_statements": 37301, "percent_covered": 39.773116524612625, "percent_covered_display": "40", "missing_lines": 20699, "excluded_lines": 83, "num_branches": 12328, "num_partial_branches": 867, "covered_branches": 3137, "missing_branches": 9191}
test:
  name: Test Group
  runs-on: ubuntu-22.04
  services:
    redis:
      image: redis:6-alpine
      ports: ["6379:6379"]
    postgres:
      image: postgres:13-alpine
      env:
        POSTGRES_PASSWORD: postgres
      ports: ["5432:5432"]
      options: --tmpfs=/var/lib/postgresql/data
  permissions:
    pull-requests: write
    contents: write
  steps:
    - uses: actions/checkout@v3
      with:
        # full checkout so the code can generate versions from tags
        fetch-depth: 0
    - uses: actions/setup-python@v4
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: actions/setup-node@v3
      with:
        node-version: '18'
    - uses: actions/cache@v3
      with:
        path: ~/.cache/pip
        key: pip-${{ hashFiles('requirements.txt') }}
        restore-keys: |
          pip-
    - uses: actions/cache@v3
      with:
        path: ~/.npm
        key: node-${{ hashFiles('package-lock.json') }}
        restore-keys: |
          node-
    - name: Install dependencies
      run: |
        make install
        npm ci
        mkdir -p iris/{media,media_test}/reports
        ./.venv/bin/manage.py collectstatic --noinput -v0
    - name: Test and generate coverage report
      run: |
        . .venv/bin/activate
        pytest -n auto -v --disable-pytest-warnings --test-group-count 200 --test-group=1 --test-group-random-seed=836739 --cov=iris --cov-report=xml
      env:
        COVERAGE_FILE: .coverage
    - name: Upload xml to GitHub artifact
      uses: actions/upload-artifact@v4
      with:
        name: coverage
        path: .coverage
coverage:
  name: Post coverage comment
  runs-on: ubuntu-22.04
  needs: 
    - test
  permissions:
    pull-requests: write
    contents: write
    actions: read
  steps:
    - uses: actions/checkout@v4
    - uses: actions/download-artifact@v4
      with:
        pattern: coverage-*
        merge-multiple: true
    - name: Coverage comment
      uses: py-cov-action/python-coverage-comment-action@v3.23
      with:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        MERGE_COVERAGE_FILES: true

Captura de Tela 2024-06-04 às 20 19 51

@rsard-ckt rsard-ckt changed the title Logging coment content Logging comment content Jun 4, 2024
@ewjoachim
Copy link
Member

If you want to debug the action in depth, one possible way is to fork it, edit your fork, and point your workflow yo the banch you edited on your fork. This way, you can add plenty of logs.

If there are things that would deserve being printed for debugging, don't hesitate to make a PR adding log.debug() statements. Those statements are visible if you enable debug logging

@ewjoachim
Copy link
Member

I see you mention the Basic usage without external contributors, but your workflow looks a bit more like the Merging multiple coverage reports one. That's a bit more added complexity, and yet it doesn't seem like you're using a matrix. I'm not sure I understand you make it this way?

@rsard-ckt
Copy link
Author

Thanks, @ewjoachim . I'll fork it and add some logs.

In fact, the test job has other twins (test_1, test_2, test_3, ...). I only inserted one to make it easier to understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants