Skip to content

fix(run): Initialize env map if nil #4439

fix(run): Initialize env map if nil

fix(run): Initialize env map if nil #4439

Workflow file for this run

name: Go static checks
on:
push:
branches: [stable]
pull_request:
types: [opened, synchronize, reopened]
branches: [staging]
paths:
- '**'
- '!.github/**'
- '.github/workflows/gochecks.yaml'
jobs:
gochecks:
runs-on: ubuntu-latest
name: All
env:
RUNGOGENERATE: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
go-version: 1.22.0
cache: false
- name: Set Go variables
id: goenv
run: |
{
echo "cache=$(go env GOCACHE)"
echo "modcache=$(go env GOMODCACHE)"
echo "mod=$(go env GOMOD)"
} >>"$GITHUB_OUTPUT"
- name: Go caches
uses: actions/cache@v4
with:
path: |
${{ steps.goenv.outputs.cache }}
${{ steps.goenv.outputs.modcache }}
key: ${{ github.job }}-${{ runner.os }}-go-${{ hashFiles(steps.goenv.outputs.mod) }}
restore-keys: |
${{ github.job }}-${{ runner.os }}-go-
- name: Check that go.mod is tidy
uses: protocol/multiple-go-modules@v1.4
with:
run: |
git config --global --add safe.directory '*'
go mod tidy
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
echo "go.sum was added by go mod tidy"
exit 1
fi
git diff --exit-code -- go.sum go.mod
- name: gofumpt
if: success() || failure() # run this step even if the previous one failed
uses: golangci/golangci-lint-action@v4
with:
version: v1.56.2
args: --timeout=30m --no-config --disable-all --enable=gofumpt --out-format=colored-line-number
skip-cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.56.2
args: --timeout=30m --out-format=colored-line-number
skip-cache: true
- name: go generate
uses: protocol/multiple-go-modules@v1.4
if: (success() || failure()) && env.RUNGOGENERATE == 'true'
with:
run: |
git clean -fd # make sure there aren't untracked files / directories
go generate ./...
# check if go generate modified or added any files
if ! $(git add . && git diff-index HEAD --exit-code --quiet); then
echo "go generate caused changes to the repository:"
git status --short
exit 1
fi