Skip to content

Bikeshedding.... Adding in the go test output as a comment. #10

Bikeshedding.... Adding in the go test output as a comment.

Bikeshedding.... Adding in the go test output as a comment. #10

Workflow file for this run

name: Unit Testing
on: [push, pull_request]
jobs:
go-tests:
name: Run Go unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "~1.21" # Use the version of Go in your project
- name: Generate test coverage
run: go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./... > test_output.txt
- name: Generate test coverage report
run: go tool cover -html=./cover.out -o ./cover.html
- name: Upload coverage report
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: ./cover.html
- name: Read test output
id: test-output
run: echo "::set-output name=results::$(cat test_output.txt)"
- name: Post test output as comment
if: github.event.pull_request != null
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
## Go Test Output
```
${{ steps.test-output.outputs.results }}
```
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# python-tests:
# name: Run Python unit tests
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: 3.x
# - name: Install dependencies
# run: pip install -r requirements.txt
# - name: Run unit tests
# run: pytest