Skip to content

Commit

Permalink
Extend GitHub Action (#9)
Browse files Browse the repository at this point in the history
* Disable gomnd and execinquery (deprecated)
* Add GOPROXY
* Split workflows
* Replace for loop with range
* Disable enterprise runners
* Remove Windows support
  • Loading branch information
gruz0 authored May 13, 2024
1 parent c1d3202 commit 4bd167b
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 21 deletions.
96 changes: 83 additions & 13 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,95 @@
# Original: https://github.com/golangci/golangci-lint/blob/master/.github/workflows/pr.yml
name: Go

on:
push:
branches: [ "main" ]
branches:
- main
pull_request:
branches: [ "main" ]

env:
GO_VERSION: '1.22'

jobs:
deps:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v4
- name: Check go mod
run: |
make deps
git diff --exit-code go.mod
git diff --exit-code go.sum
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run build
run: make build

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Build
run: make build
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run tests
run: make test

- name: Test
run: make test
# All of these tasks require paid GitHub plan
# tests-on-windows:
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v4
# - name: Install Go
# uses: actions/setup-go@v5
# with:
# go-version: ${{ env.GO_VERSION }}
# - name: Run build
# run: make.exe build
# - name: Run tests
# run: make.exe test
#
# tests-on-macos:
# runs-on: macos-latest
# steps:
# - uses: actions/checkout@v4
# - name: Install Go
# uses: actions/setup-go@v5
# with:
# go-version: ${{ env.GO_VERSION }}
# - name: Run tests
# run: make test
#
# tests-on-unix:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# golang:
# - '1.21'
# - '1.22'
# steps:
# - uses: actions/checkout@v4
# - name: Install Go
# uses: actions/setup-go@v5
# with:
# go-version: ${{ matrix.golang }}
# - uses: actions/cache@v4
# with:
# path: ~/go/pkg/mod
# key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }}
# restore-keys: |
# ${{ runner.os }}-go-${{ matrix.golang }}-
# - name: Run tests
# run: make test
24 changes: 24 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Original: https://github.com/golangci/golangci-lint/blob/master/.github/workflows/pr.yml
name: Lint
on:
push:
branches:
- main
pull_request:

env:
GO_VERSION: '1.22'

jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: lint
uses: golangci/golangci-lint-action@v5.3.0
with:
version: latest
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
linters:
enable-all: true
disable:
- gomnd
- execinquery
- ifshort
- nosnakecase
- scopelint
Expand Down
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export GOPROXY = https://proxy.golang.org

GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
Expand All @@ -17,13 +19,6 @@ ENVANALYZER_CMD_DIR=$(CMD_DIR)/$(ENVANALYZER_BINARY_NAME)
YAMLANALYZER_BINARY_NAME=yamlanalyzer
YAMLANALYZER_CMD_DIR=$(CMD_DIR)/$(YAMLANALYZER_BINARY_NAME)

ifeq ($(OS),Windows_NT)
WEB3SAFE_BINARY_NAME:= $(WEB3SAFE_BINARY_NAME).exe
DOTENVANALYZER_BINARY_NAME:= $(DOTENVANALYZER_BINARY_NAME).exe
ENVANALYZER_BINARY_NAME:= $(ENVANALYZER_BINARY_NAME).exe
YAMLANALYZER_BINARY_NAME:= $(YAMLANALYZER_BINARY_NAME).exe
endif

build: clean
$(GOBUILD) -o $(BIN_DIR)/$(WEB3SAFE_BINARY_NAME) $(WEB3SAFE_CMD_DIR)/...
$(GOBUILD) -o $(BIN_DIR)/$(DOTENVANALYZER_BINARY_NAME) $(DOTENVANALYZER_CMD_DIR)/...
Expand Down
2 changes: 1 addition & 1 deletion internal/yamlanalyzer/yamlanalyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func traverse(value interface{}) []string {
}

if value.Kind() == reflect.Slice || value.Kind() == reflect.Array {
for i := 0; i < value.Len(); i++ {
for i := range make([]struct{}, value.Len()) {
processQueue(value.Index(i), fmt.Sprintf("%s[%d]", path, i))
}

Expand Down

0 comments on commit 4bd167b

Please sign in to comment.