Переглянути джерело

actions: Update codecov uploader and simplify unit-test runner

The newer version of the codecov uploader requires the token to be
explicitly passed.
Use globs in codecov.yml to make it easier for forks of the repository
to get coverage information

Signed-off-by: Anatole Denis <anatole@unverle.fr>
Anatole Denis 1 рік тому
батько
коміт
bb0406dadf
2 змінених файлів з 15 додано та 11 видалено
  1. 3 2
      .github/codecov.yml
  2. 12 9
      .github/workflows/tests.yml

+ 3 - 2
.github/codecov.yml

@@ -1,4 +1,5 @@
 # Map file paths during tests to the canonical path in the repo
 fixes:
-    # Removes the prefix we use during github actions
-    - "src/github.com/coredhcp/coredhcp/::"
+    # Removes the prefix we use during github actions, use glob to support forks
+    - "src/github.com/*/coredhcp/::"
+    - "github.com/*/coredhcp/::"

+ 12 - 9
.github/workflows/tests.yml

@@ -26,21 +26,19 @@ jobs:
         run: |
           cd $GITHUB_WORKSPACE/src/github.com/${{ github.repository }}
           go get -v -t ./...
-          echo "" > "${GITHUB_WORKSPACE}"/coverage.txt
-          for d in $(go list ./...); do
-              go test -v -race -coverprofile=profile.out -covermode=atomic "${d}"
-              if [ -f profile.out ]; then
-                cat profile.out >> "${GITHUB_WORKSPACE}"/coverage.txt
-                rm profile.out
-              fi
-          done
+          go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
       - name: report coverage to codecov
         uses: codecov/codecov-action@v4
         with:
           files: coverage.txt
+          disable_search: true
           flags: unittests
           fail_ci_if_error: true
           verbose: true
+          root_dir: ${{ github.workspace }}/src/github.com/${{ github.repository }}
+          working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
+        env:
+          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
   integration-tests:
     runs-on: ubuntu-latest
     strategy:
@@ -82,7 +80,12 @@ jobs:
       - name: report coverage to codecov
         uses: codecov/codecov-action@v4
         with:
-          files: coverage.txt
+          files: ${{github.workspace}}/coverage.txt
+          disable_search: true
           flags: integtests
           fail_ci_if_error: true
           verbose: true
+          root_dir: ${{ github.workspace }}/src/github.com/${{ github.repository }}
+          working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
+        env:
+          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}