codecov #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: codecov | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| coverage: | |
| name: Run tests and upload coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| - name: Run unit tests with coverage | |
| run: go test $(go list ./... | grep -v /integration) -coverprofile=unit.out -covermode=atomic | |
| - name: Prepare integration coverage dir | |
| run: | | |
| mkdir -p integration/covdata | |
| chmod 0777 integration/covdata | |
| - name: Clean structure for integration tests | |
| run: | | |
| mkdir -p ./integration/files | |
| rm -rf ./integration/files/* | |
| cp ./integration/keepFiles/test_data.txt ./integration/files/ | |
| rm -rf ./sftpserver/testdir | |
| rm -f ./sftpserver/test.txt | |
| echo "cleaned up, ready for next test" | |
| - name: Run integration tests | |
| # The Docker image used by these tests is built with `go build -cover` | |
| # and bind-mounts integration/covdata to /covdata. Each container | |
| # writes Go binary-coverage data there on graceful shutdown. | |
| run: go test -v ./integration -count=1 | |
| - name: Convert integration binary coverage to text format | |
| run: go tool covdata textfmt -i=integration/covdata -o=integration.out | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./unit.out,./integration.out | |
| fail_ci_if_error: true |