From 63a1c60209c02bf6e743012a513c770d209264ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Pazos?= Date: Tue, 30 Jul 2024 12:12:22 -0300 Subject: [PATCH] chore: some gh actions --- .github/workflows/checks.yml | 66 ++++++++++++++++++++++++++++++++++++ Makefile | 5 +++ 2 files changed, 71 insertions(+) create mode 100644 .github/workflows/checks.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..1370d15 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,66 @@ +name: "checks" + +on: + push: + branches: + - main + pull_request: + +env: + GO_VERSION: 1.21.8 + +jobs: + # shellcheck should be a dependency for jobs that run any scripts, + # as wrong shell scripts can be harmful. + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + severity: warning + + go-lint: + permissions: + contents: read # for actions/checkout to fetch code + pull-requests: read # for golangci/golangci-lint-action to fetch pull requests + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + args: --verbose + version: v1.59.1 + + go-mod-tidy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Check go mod tidy + run: | + go mod tidy + make assert-no-changed-files + + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Run Tests + run: go test ./... diff --git a/Makefile b/Makefile index 8b79ed4..cd52f9e 100644 --- a/Makefile +++ b/Makefile @@ -41,3 +41,8 @@ packages-minor-autoupdate: . != \"github.com/thanos-io/thanos\" \ ))" \ | tr -d '\n' | tr -d ' ' + +.PHONY: assert-no-changed-files +assert-no-changed-files: + @git update-index --refresh + @git diff-index --quiet HEAD -- \ No newline at end of file