From bf6d2a3e8e500ec748790ac76352df322a8e84b0 Mon Sep 17 00:00:00 2001 From: Sunil Thaha Date: Thu, 19 Oct 2023 14:20:32 +1000 Subject: [PATCH] ci: use make fmt to check for formatting Signed-off-by: Sunil Thaha --- .github/workflows/pr-checks.yaml | 14 +++++++----- automation/presubmit-tests/gofmt.sh | 35 ----------------------------- 2 files changed, 8 insertions(+), 41 deletions(-) delete mode 100755 automation/presubmit-tests/gofmt.sh diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 0432e974..d556c616 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -17,15 +17,17 @@ jobs: make docs git diff --exit-code - gofmt: + fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@main - uses: actions/setup-go@main with: go-version-file: go.mod - - name: run gofmt test - run: ./automation/presubmit-tests/gofmt.sh + - name: Install all tools + uses: ./.github/tools-cache + - name: make fmt + run: make fmt && git diff --exit-code escapes_detect: runs-on: ubuntu-latest @@ -71,7 +73,7 @@ jobs: run: make govulncheck bundle: - needs: [docs, golangci, gofmt, vulnerability_detect, escapes_detect] + needs: [docs, golangci, fmt, vulnerability_detect, escapes_detect] runs-on: ubuntu-latest steps: - uses: actions/checkout@main @@ -87,7 +89,7 @@ jobs: git diff --exit-code build-images: - needs: [docs, golangci, gofmt, vulnerability_detect, escapes_detect] + needs: [docs, golangci, fmt, vulnerability_detect, escapes_detect] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -115,7 +117,7 @@ jobs: additional_tags: ${{ steps.additional_tags.outputs.result }} e2e: - needs: [docs, golangci, gofmt, vulnerability_detect, escapes_detect] + needs: [docs, golangci, fmt, vulnerability_detect, escapes_detect] env: KIND_VERSION: "0.15.0" GO111MODULE: "on" diff --git a/automation/presubmit-tests/gofmt.sh b/automation/presubmit-tests/gofmt.sh deleted file mode 100755 index 5f223d90..00000000 --- a/automation/presubmit-tests/gofmt.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -# This file is part of the Kepler project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Copyright 2022 The Kepler Contributors. -# - -set -e - -echo "Checking go format" -sources="./cmd/ ./pkg/" -unformatted=$(gofmt -e -d -s -l $sources) -if [ ! -z "$unformatted" ]; then - # Some files are not gofmt. - echo >&2 "The following Go files must be formatted with gofmt:" - for fn in $unformatted; do - echo >&2 " $fn" - done - echo >&2 "Please run 'make format'." - exit 1 -fi - -exit 0