fix(pkg): Add --force
flag to sourcing and prevent check on unsourc…
#22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go static checks | |
on: | |
push: | |
branches: [staging] | |
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@v4 | |
with: | |
go-version: 1.21.2 | |
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@v3 | |
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@v3 | |
with: | |
version: v1.53.3 | |
args: --no-config --disable-all --enable=gofumpt --out-format=colored-line-number | |
skip-cache: true | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: v1.53.3 | |
args: --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 |