mirror of
https://github.com/jwetzell/psn-go.git
synced 2026-08-13 19:33:49 +00:00
add github action to test decoders
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
name: "Test Decoders"
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
paths:
|
||||
- 'internal/decoders/**'
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
paths:
|
||||
- 'internal/decoders/**'
|
||||
|
||||
jobs:
|
||||
test_decoders:
|
||||
name: "test decoders"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: ^1.23
|
||||
|
||||
# When you execute your unit tests, make sure to use the "-coverprofile" flag to write a
|
||||
# coverage profile to a file. You will need the name of the file (e.g. "coverage.txt")
|
||||
# in the next step as well as the next job.
|
||||
- name: Test
|
||||
run: go test -cover -coverprofile=coverage.txt ./internal/decoders/...
|
||||
|
||||
- name: Archive code coverage results
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: decoders-code-coverage
|
||||
path: decoders_coverage.txt # Make sure to use the same file name you chose for the "-coverprofile" in the "Test" step
|
||||
|
||||
code_coverage:
|
||||
name: "Code coverage report"
|
||||
if: github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch
|
||||
runs-on: ubuntu-latest
|
||||
needs: test_decoders
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: fgrosse/go-coverage-report@v1.1.1 # Consider using a Git revision for maximum security
|
||||
with:
|
||||
coverage-artifact-name: "decoders-code-coverage" # can be omitted if you used this default value
|
||||
coverage-file-name: "decoders_coverage.txt" # can be omitted if you used this default value
|
||||
Reference in New Issue
Block a user