Native Gang Scheduling (Proof of Concept) #3324
Workflow file for this run
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
| # Copyright 2025 SAP SE | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Test and Report Coverage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - '*' | |
| jobs: | |
| test-without-docker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Test quickly without Docker | |
| run: go test -v ./... | |
| test-with-docker: | |
| # We don't need to run this longer test if the previous one already failed. | |
| needs: test-without-docker | |
| runs-on: ubuntu-latest | |
| services: | |
| dind: | |
| image: docker:rc-dind-rootless | |
| ports: | |
| - 2375:2375 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Run tests with Docker and calculate coverage | |
| run: | | |
| export GITHUB_ACTIONS=1 | |
| export POSTGRES_CONTAINER=1 | |
| echo "Running tests..." | |
| go test -v \ | |
| -coverpkg=./... \ | |
| -coverprofile=profile.cov ./... | |
| go tool cover -func profile.cov > func_coverage.txt | |
| - name: Upload coverage files | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: pr-func-coverage | |
| path: | | |
| func_coverage.txt | |
| # Steps below are only executed if the workflow is triggered by a pull request | |
| - name: Delete old coverage comments (PR only) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const coverageCommentTag = '<!-- coverage-comment -->'; | |
| for (const comment of comments) { | |
| if (comment.body.includes(coverageCommentTag)) { | |
| await github.rest.issues.deleteComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: comment.id, | |
| }); | |
| } | |
| } | |
| - name: Download coverage files (PR only) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: pr-func-coverage | |
| path: . | |
| - name: Post coverage comment (PR only) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: actions/github-script@v8 | |
| # For external contributors, posting comments fail due to permission issues. | |
| continue-on-error: true | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| // Read pkg module coverage report | |
| let coverageReport = ''; | |
| let coveragePercentage = 'unknown'; | |
| try { | |
| coverageReport = fs.readFileSync('func_coverage.txt', 'utf8'); | |
| const lines = coverageReport.trim().split('\n'); | |
| const lastLine = lines[lines.length - 1]; | |
| const coverageMatch = lastLine.match(/total:\s+\(statements\)\s+(\d+\.\d+)%/); | |
| coveragePercentage = coverageMatch ? coverageMatch[1] : 'unknown'; | |
| coveragePercentage = coverageMatch ? coverageMatch[1] : 'unknown'; | |
| } catch (error) { | |
| coverageReport = 'No coverage data available'; | |
| } | |
| let commentBody = '<!-- coverage-comment -->\n'; | |
| commentBody += '## Test Coverage Report\n\n'; | |
| // Pkg module coverage | |
| commentBody += '<details>\n'; | |
| commentBody += '<summary>Test Coverage 📊: '; | |
| commentBody += coveragePercentage; | |
| commentBody += '%</summary>\n\n'; | |
| commentBody += '```text\n'; | |
| commentBody += coverageReport; | |
| commentBody += '```\n'; | |
| commentBody += '</details>\n\n'; | |
| // Post the comment | |
| await github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: commentBody, | |
| }); |