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

[TS-711] Wrong commit UUID is discovered #78

Closed
milkshakeuk opened this issue Dec 15, 2023 · 5 comments
Closed

[TS-711] Wrong commit UUID is discovered #78

milkshakeuk opened this issue Dec 15, 2023 · 5 comments
Labels
jira-issue Issue tracked on JIRA

Comments

@milkshakeuk
Copy link

Hi, your action doesn't allow a mechanism to specify the commit UUID and in my case its auto discovering the wrong commit id:

See my Action Run here:
https://github.com/nHapiNET/nHapi/actions/runs/7222494087/job/19679576963

it "should" discover 6371a8bfc534e7b9df7e724ab4e9d42fdf26ae23 (as seen in the checkout step) but is discovering 50be0187277c901ced58db7ded7acc098f6420d3 and therefor associating the coverage reports with the wrong commit, I know the Codacy Coverage Reporter script has an option to pass --commit-uuid but you aren't using this?

Am I doing something wrong? or is could there be missing feature in this action?

@github-actions github-actions bot added the jira-issue Issue tracked on JIRA label Dec 15, 2023
@github-actions github-actions bot changed the title Wrong commit UUID is discovered [TS-711] Wrong commit UUID is discovered Dec 15, 2023
Copy link

Internal ticket created : TS-711

@milkshakeuk
Copy link
Author

I believe this is linked to #67, although I can manually use the Codacy Coverage Reporter Cli to pass in the correct commit id, I would rather use a prebuild action which already supports this.

@SchoolGuy
Copy link

So this is also linked to cobbler/cobbler#3379. I had to resort to the workaround that @milkshakeuk linked. I am still baffled how Codecov is able to do this without needing to resort to these workarounds directly from the fork.

The workaround looks something like this:

testing.yml:

name: Testing Cobbler

on:
  push:
    branches: [ main, release* ]
  pull_request:
    branches: [ main, release* ]

jobs:
  run_tests:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v4
      - name: Pull Docker Test Container
        run: docker pull registry.opensuse.org/systemsmanagement/cobbler/github-ci/containers/cobbler-test-github:main
      - name: Run previously built Docker Container
        run: docker run --privileged -t -d -v $PWD:/code --name cobbler registry.opensuse.org/systemsmanagement/cobbler/github-ci/containers/cobbler-test-github:main
      - name: Setup Cobbler in the Container
        shell: 'script -q -e -c "bash {0}"'
        run: |
          docker exec -u 0 -it cobbler bash -c "./docker/develop/scripts/setup-supervisor.sh"
      - name: Run the Tests inside the Docker Container
        shell: 'script -q -e -c "bash {0}"'
        run: |
          docker exec -u 0 -it cobbler bash -c "pytest --cov=./cobbler --benchmark-skip && git config --global --add safe.directory /code && coverage xml && codecov --token=1064928c-6477-41be-9ac2-7ce5e6d1fd8b --commit=${GITHUB_SHA}"
      - name: Stop and remove the container
        run: docker stop cobbler && docker rm cobbler
      # https://github.com/actions/upload-artifact
      - name: Upload coverage report to GH artifacts
        uses: actions/upload-artifact@v4
        with:
          name: coverage-report
          path: coverage.xml
          if-no-files-found: error

coverage-upload.yml:

name: Coverage Upload

on:
  workflow_run:
    workflows: [Testing Cobbler]
    types:
      - completed

jobs:
  run_tests:
    runs-on: ubuntu-latest
    steps:
      # https://github.com/dawidd6/action-download-artifact
      - name: Download artifact
        id: download-artifact
        uses: dawidd6/action-download-artifact@v3
        with:
          name: coverage-report
          workflow: testing.yml
          allow_forks: true
          workflow_conclusion: success
      # https://github.com/codacy/codacy-coverage-reporter-action
      # - name: Run codacy-coverage-reporter
      #   uses: codacy/codacy-coverage-reporter-action@v1
      #   with:
      #     project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
      #     coverage-reports: coverage.xml
      - name: Publish Code Coverage Results
        run: |
          auth="--project-token ${{ secrets.CODACY_PROJECT_TOKEN }}"
          commit_uuid="--commit-uuid ${{ github.event.workflow_run.head_sha }}"

          bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth $commit_uuid -r coverage.xml --partial &&\
          bash <(curl -Ls https://coverage.codacy.com/get.sh) final $auth $commit_uuid

@yoanm
Copy link

yoanm commented Mar 23, 2024

Workaround proposal => #83

@lolgab
Copy link
Contributor

lolgab commented Mar 25, 2024

Hi @yoanm,
Thank you for opening the issue and for the workaround proposed.
We were already having special code to handle the pull_request workflows in GitHub Actions, which also have different commit SHA. I did a similar thing for workflow_run workflows in codacy/codacy-coverage-reporter#492 and now both the CLI reporter and the GitHub Action should get the right commit SHA by default.
I'm closing this issue. Feel free to reopen if this is not working as expected.

@lolgab lolgab closed this as completed Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira-issue Issue tracked on JIRA
Projects
None yet
Development

No branches or pull requests

4 participants