Skip to content

add caching by default with an input to disable it #7

add caching by default with an input to disable it

add caching by default with an input to disable it #7

Workflow file for this run

---
name: 'Run Go Tests'
on:
workflow_call:
inputs:
go-version:
required: false
type: string
default: "1.22"
path:
required: true
type: string
description: "working directory"
runs_on:
default: "['ubuntu-latest']"
type: string
description: "github runner tags"
timeout-minutes:
default: 30
type: number
description: "Workflow timeout"
golangci-lint-version:
description: 'Golangci-lint version'
type: string
default: latest
golangci-lint-args:
description: 'Golangci-lint arguments'
type: string
default: ''
golangci-lint-skip-cache:
description: 'Skip cache if enabled'
type: boolean
default: false
golangci-lint-only-new-issues:
description: 'only run on new issues in local PR diff'
type: boolean
default: false
golangci-lint-problem-matchers:
description: 'run with golangci problem matchers'
type: boolean
default: false
disable_caching:

Check failure on line 42 in .github/workflows/go-tests.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/go-tests.yaml

Invalid workflow file

You have an error in your yaml syntax on line 42
description: 'disable caching for go dependencies"
type: boolean
default: false
debug_enabled:
default: false
required: false
type: boolean
description: "run tmate for troubleshooting"
jobs:
go-tests:
permissions:
contents: read
pull-requests: read
checks: write
id-token: write
runs-on: ${{ fromJson(inputs.runs_on) }}
timeout-minutes: ${{ inputs.timeout-minutes }}
defaults:
run:
shell: bash
working-directory: ${{ inputs.path }}
steps:
# Security policy go-tests is configured in step security app
# Policy can be seen here https://app.stepsecurity.io/github/celo-org/actions/policies/go-tests
# disable-sudo is set to false if debug is true, because tmate requires root to work.
- name: Harden Runner
if: runner.environment == 'github-hosted'
uses: step-security/harden-runner@v2
with:
disable-sudo: ${{ !inputs.debug_enabled }}
policy: go-tests
# Only turns on tmate if workflow_dispatch set debug to true.
# limit-access-to-actor or some other security precaution should be added
# so anyone with the link can't ssh in without a key.
# Currently detaches and runs concurrently with workflow, can change
# if needed
- name: Setup tmate session
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
if: inputs.debug_enabled == true
with:
detached: true
limit-access-to-actor: true
- name: 'Checkout'
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
cache: ${{ !inputs.disable_caching }}
- name: Ensure dependencies are up to date
run: go mod tidy
- name: Verify dependencies
run: go mod verify
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8
with:
version: ${{ inputs.golangci-lint-version }}
args: "${{ inputs.gologanci-lint-args }} --timeout=${{ inputs.timeout-minutes }}m"
skip-cache: ${{ inputs.golangci-lint-skip-cache }}
problem-matchers: ${{ inputs.golangci-lint-problem-matchers }}
only-new-issues: ${{ inputs.golangci-lint-only-new-issues }}
working-directory: ${{ inputs.path }}
# Make sure build works. This may not be necessary, since golangci might be able to find the same issues.
# have to investigate further
- name: Build
run: go build -v ./...
# Run tests
- name: Go Tests
uses: robherley/go-test-action@b19f6aadabfb1ad85079065b21aa2af132466468
with:
moduleDirectory: ${{ inputs.path }}