diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 666ca7b78..5d8307574 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,14 +35,7 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: Test code # we're passing -short so that we skip the integration tests, which will be run in parallel below - run: | - mkdir -p /tmp/code_coverage - go test ./... -short -cover -args "-test.gocoverdir=/tmp/code_coverage" - - name: Upload code coverage artifacts - uses: actions/upload-artifact@v7 - with: - name: coverage-unit-${{ matrix.os }}-${{ github.run_id }} - path: /tmp/code_coverage + run: go test ./... -short integration-tests: strategy: @@ -100,11 +93,6 @@ jobs: run: git --version - name: Test code env: - # See https://go.dev/blog/integration-test-coverage. The race variant - # skips coverage: it's redundant with the non-race latest job and - # would only slow the -race build down further. Leaving the dir unset - # makes run_integration_tests.sh take its non-coverage path. - LAZYGIT_GOCOVERDIR: ${{ !matrix.race && '/tmp/code_coverage' || '' }} # Only set for the race variant. The race detector needs cgo; it's on # by default on the Linux runner, but we set it explicitly to be safe. LAZYGIT_RACE_DETECTOR: ${{ matrix.race && '1' || '' }} @@ -112,15 +100,7 @@ jobs: # Append each test's duration to this file; run_integration_tests.sh # prints the slowest at the end, to spot slow/anomalous tests. LAZYGIT_TEST_TIMING: /tmp/test_timings.txt - run: | - mkdir -p /tmp/code_coverage - ./scripts/run_integration_tests.sh - - name: Upload code coverage artifacts - if: ${{ !matrix.race }} - uses: actions/upload-artifact@v7 - with: - name: coverage-integration-${{ matrix.git-version }}-${{ github.run_id }} - path: /tmp/code_coverage + run: ./scripts/run_integration_tests.sh build: runs-on: ubuntu-latest env: @@ -196,43 +176,6 @@ jobs: with: # If you change this, make sure to also update scripts/golangci-lint-shim.sh version: v2.15.0 - upload-coverage: - # List all jobs that produce coverage files - needs: [unit-tests, integration-tests] - if: github.event.pull_request.head.repo.full_name == github.repository - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v7 - - - name: Setup Go - uses: actions/setup-go@v7 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Download all coverage artifacts - uses: actions/download-artifact@v8 - with: - path: /tmp/code_coverage - - - name: Combine coverage files - run: | - # Find all directories in /tmp/code_coverage and create a comma-separated list - COVERAGE_DIRS=$(find /tmp/code_coverage -mindepth 1 -maxdepth 1 -type d -printf '/tmp/code_coverage/%f,' | sed 's/,$//') - echo "Coverage directories: $COVERAGE_DIRS" - # Run the combine command with the generated list - go tool covdata textfmt -i=$COVERAGE_DIRS -o coverage.out - echo "Combined coverage:" - go tool cover -func coverage.out | tail -1 | awk '{print $3}' - - - name: Upload to Codacy - run: | - CODACY_PROJECT_TOKEN="${CODACY_PROJECT_TOKEN}" \ - bash <(curl -Ls https://coverage.codacy.com/get.sh) report \ - --force-coverage-parser go -r coverage.out - - env: - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} check-for-fixups: runs-on: ubuntu-latest if: github.ref != 'refs/heads/master' diff --git a/README.md b/README.md index 8e2bf8a46..e40b06b6c 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ A simple terminal UI for git commands
-[![GitHub Releases](https://img.shields.io/github/downloads/jesseduffield/lazygit/total)](https://github.com/jesseduffield/lazygit/releases) [![Go Report Card](https://goreportcard.com/badge/github.com/jesseduffield/lazygit)](https://goreportcard.com/report/github.com/jesseduffield/lazygit) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/f46416b715d74622895657935fcada21)](https://app.codacy.com/gh/jesseduffield/lazygit/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/f46416b715d74622895657935fcada21)](https://app.codacy.com/gh/jesseduffield/lazygit/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage) [![golangci-lint](https://img.shields.io/badge/linted%20by-golangci--lint-brightgreen)](https://golangci-lint.run/) [![GitHub tag](https://img.shields.io/github/v/tag/jesseduffield/lazygit?color=blue)](https://github.com/jesseduffield/lazygit/releases/latest) [![homebrew](https://img.shields.io/homebrew/v/lazygit?color=blue)](https://formulae.brew.sh/formula/lazygit) +[![GitHub Releases](https://img.shields.io/github/downloads/jesseduffield/lazygit/total)](https://github.com/jesseduffield/lazygit/releases) [![golangci-lint](https://img.shields.io/badge/linted%20by-golangci--lint-brightgreen)](https://golangci-lint.run/) [![GitHub tag](https://img.shields.io/github/v/tag/jesseduffield/lazygit?color=blue)](https://github.com/jesseduffield/lazygit/releases/latest) [![homebrew](https://img.shields.io/homebrew/v/lazygit?color=blue)](https://formulae.brew.sh/formula/lazygit) diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index 0c659ebfa..1d6dcbaa4 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -7,17 +7,16 @@ if [ -n "$LAZYGIT_GOCOVERDIR" ]; then # Go expects us to either be running the test binary directly or running `go test`, but because # we're doing both and because we want to combine coverage data for both, we need to be a little # hacky. To capture the coverage data for the test runner we pass the test.gocoverdir positional - # arg, but if we do that then the GOCOVERDIR env var (which you typically pass to the test binary) will be overwritten by the test runner. So we're passing LAZYGIT_COCOVERDIR instead + # arg, but if we do that then the GOCOVERDIR env var (which you typically pass to the test binary) will be overwritten by the test runner. So we're passing LAZYGIT_GOCOVERDIR instead # and then internally passing that to the test binary as GOCOVERDIR. - go test -timeout 30m -cover -coverpkg=github.com/jesseduffield/lazygit/pkg/... pkg/integration/clients/*.go -args -test.gocoverdir="/tmp/code_coverage" + # + # Go doesn't create the coverage directory itself. The lazygit binary runs in + # the directory of the test's repo, so it also needs an absolute path. + mkdir -p "$LAZYGIT_GOCOVERDIR" + LAZYGIT_GOCOVERDIR=$(cd "$LAZYGIT_GOCOVERDIR" && pwd) + export LAZYGIT_GOCOVERDIR + go test -timeout 30m -cover -coverpkg=github.com/jesseduffield/lazygit/pkg/... pkg/integration/clients/*.go -args -test.gocoverdir="$LAZYGIT_GOCOVERDIR" EXITCODE=$? - - # We're merging the coverage data for the sake of having fewer artefacts to upload. - # We can't merge inline so we're merging to a tmp dir then moving back to the original. - mkdir -p /tmp/code_coverage_merged - go tool covdata merge -i=/tmp/code_coverage -o=/tmp/code_coverage_merged - rm -rf /tmp/code_coverage - mv /tmp/code_coverage_merged /tmp/code_coverage else go test -timeout 30m pkg/integration/clients/*.go EXITCODE=$?