feat(api): configurable upload timeout, default 10m (#160) #474
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: Go | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || (!github.event.pull_request.draft && !contains(github.event.pull_request.title, 'WIP')) | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| cache: true | |
| - name: Run go vet | |
| run: go vet ./internal/... | |
| - name: Run tests | |
| run: go test -coverprofile=cover.out.raw -coverpkg=./internal/... ./internal/... | |
| - name: Deduplicate coverage blocks | |
| # Workaround for fgrosse/go-coverage-report#61: merge duplicate coverage blocks | |
| # When using -coverpkg, Go creates duplicate entries for each test package | |
| run: | | |
| head -1 cover.out.raw > cover.out | |
| tail -n +2 cover.out.raw | awk '{ | |
| key = $1 | |
| stmt = $2 | |
| count = $3 + 0 | |
| if (count > counts[key]) counts[key] = count | |
| stmts[key] = stmt | |
| } END { | |
| for (key in stmts) print key, stmts[key], counts[key] + 0 | |
| }' | sort >> cover.out | |
| - name: Archive code coverage results | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4 | |
| with: | |
| name: code-coverage | |
| path: cover.out | |
| - name: Download artifact (main.breakdown) | |
| id: download-main-breakdown | |
| uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| branch: main | |
| workflow_conclusion: success | |
| name: main.breakdown | |
| if_no_artifact_found: warn | |
| - name: Check test coverage | |
| id: coverage | |
| uses: vladopajic/go-test-coverage/action/source@679e6807f68f2440a4c43d386442a1d0041838a9 # v2 | |
| with: | |
| profile: cover.out | |
| git-token: ${{ github.ref_name == 'main' && secrets.GITHUB_TOKEN || '' }} | |
| git-branch: badges | |
| breakdown-file-name: ${{ github.ref_name == 'main' && 'main.breakdown' || '' }} | |
| diff-base-breakdown-file-name: ${{ steps.download-main-breakdown.outputs.found_artifact == 'true' && 'main.breakdown' || '' }} | |
| - name: Upload artifact (main.breakdown) | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4 | |
| if: github.ref_name == 'main' | |
| with: | |
| name: main.breakdown | |
| path: main.breakdown | |
| if-no-files-found: error | |
| build: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || (!github.event.pull_request.draft && !contains(github.event.pull_request.title, 'WIP')) | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Build x64 DLL | |
| run: | | |
| docker run --rm -v "${{ github.workspace }}:/go/work" -w /go/work x1unix/go-mingw:1.24 \ | |
| go build -buildvcs=false \ | |
| -ldflags "-X main.BuildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -X main.BuildCommit=${{ github.sha }}" \ | |
| -o dist/ocap_recorder_x64.dll -buildmode=c-shared ./cmd/ocap_recorder | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4 | |
| with: | |
| name: dll-artifacts | |
| path: dist/ocap_recorder_x64.dll | |
| code_coverage: | |
| name: "Code coverage report" | |
| if: github.event_name == 'pull_request' && !github.event.pull_request.draft | |
| runs-on: ubuntu-latest | |
| needs: test | |
| permissions: | |
| contents: read | |
| actions: read | |
| pull-requests: write | |
| steps: | |
| - uses: fgrosse/go-coverage-report@cbeb2ab2e32591d690337146ba02a911cc566f3f # v1.3.0 | |
| with: | |
| coverage-artifact-name: "code-coverage" | |
| coverage-file-name: "cover.out" | |
| root-package: "github.com/OCAP2/extension/v5" |