Skip to content

Commit

Permalink
ci: add ability to provide logging options to tests
Browse files Browse the repository at this point in the history
Signed-off-by: lvlcn-t <[email protected]>
  • Loading branch information
lvlcn-t committed Nov 17, 2024
1 parent 88c63e3 commit cb31835
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
name: Tests

on: [push]
on:
push:
workflow_dispatch:
inputs:
log_format:
description: "Log format"
required: false
default: "text"
type: string
log_level:
description: "Log level"
required: false
default: "info"
type: string

permissions:
contents: read
Expand All @@ -20,7 +33,24 @@ jobs:
go install github.com/mfridman/tparse@latest
go mod download
- name: Run all go tests
- name: Set log format and level
id: inputs
run: |
if [ -z "${{ inputs.log_format }}" ]; then
echo "LOG_FORMAT=text" >> $GITHUB_OUTPUT
else
echo "LOG_FORMAT=${{ inputs.log_format }}" >> $GITHUB_OUTPUT
fi
if [ -z "${{ inputs.log_level }}" ]; then
echo "LOG_LEVEL=info" >> $GITHUB_OUTPUT
else
echo "LOG_LEVEL=${{ inputs.log_level }}" >> $GITHUB_OUTPUT
fi
- name: Run go unit tests
env:
LOG_FORMAT: ${{ steps.inputs.outputs.LOG_FORMAT }}
LOG_LEVEL: ${{ steps.inputs.outputs.LOG_LEVEL }}
run: |
go test -v -count=1 -test.short -race ./... -json -coverpkg ./... \
| tee output.jsonl | tparse -notests -follow -all || true
Expand All @@ -40,7 +70,28 @@ jobs:
go install github.com/mfridman/tparse@latest
go mod download
- name: Run all go tests
- name: Set log format and level
id: inputs
run: |
if [ -z "${{ inputs.log_format }}" ]; then
echo "No log format provided, using default: text"
echo "LOG_FORMAT=text" >> $GITHUB_OUTPUT
else
echo "Log format provided: ${{ inputs.log_format }}"
echo "LOG_FORMAT=${{ inputs.log_format }}" >> $GITHUB_OUTPUT
fi
if [ -z "${{ inputs.log_level }}" ]; then
echo "No log level provided, using default: info"
echo "LOG_LEVEL=info" >> $GITHUB_OUTPUT
else
echo "Log level provided: ${{ inputs.log_level }}"
echo "LOG_LEVEL=${{ inputs.log_level }}" >> $GITHUB_OUTPUT
fi
- name: Run go e2e tests
env:
LOG_FORMAT: ${{ steps.inputs.outputs.LOG_FORMAT }}
LOG_LEVEL: ${{ steps.inputs.outputs.LOG_LEVEL }}
run: |
go test -v -count=1 -race ./... -json -coverpkg ./... \
| tee output.jsonl | tparse -notests -follow -all || true
Expand Down

0 comments on commit cb31835

Please sign in to comment.