Skip to content

Commit

Permalink
ci: enable cache for tools
Browse files Browse the repository at this point in the history
We can't cache image as the free storage from GitHub is too small.
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Nov 28, 2023
1 parent f9ce897 commit c7f6a6d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 23 deletions.
30 changes: 16 additions & 14 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: "pull request labeler"
on:
- pull_request_target
# Disable this workflow for now until this repo is open source and GitHub doesn't charge us for CI

jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/labeler@v4
with:
dot: true
#name: "pull request labeler"
#on:
#- pull_request_target

#jobs:
#triage:
#permissions:
#contents: read
#pull-requests: write
#runs-on: ubuntu-latest
#steps:
#- uses: actions/checkout@v4
#- uses: actions/labeler@v4
#with:
#dot: true
11 changes: 11 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,26 @@ on:
pull_request:
branches: [ "main" ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true

jobs:
build:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4

- name: binary-cache
uses: actions/cache@v3
with:
path: ./bin
key: ${{ runner.os }}-${{ hashFiles('./Makefile') }}

- name: format go
run: |
make fmt-go
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ on:
- "./docs"
- "**/*.md"

concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true

env:
IN_CI: true

jobs:
unit-test:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -33,6 +38,7 @@ jobs:
run: make unit-test

plugins-integration-test:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -60,6 +66,7 @@ jobs:
path: ./test-envoy

controller-test:
timeout-minutes: 10
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -74,5 +81,11 @@ jobs:
# working-directory doesn't affect the cache path
cache-dependency-path: ./controller/go.sum

- name: binary cache
uses: actions/cache@v3
with:
path: ./controller/bin
key: ${{ runner.os }}-${{ hashFiles('./controller/Makefile') }}

- name: Test
run: make test
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
deadline: 10m
deadline: 5m

linters:
enable:
Expand Down
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ ifeq ($(IN_CI), true)
MOUNT_GOMOD_CACHE =
endif

LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
@mkdir -p $(LOCALBIN)

.PHONY: gen-proto
gen-proto: build-dev-tools $(GO_TARGETS)
# format the generated Go code so the `fmt-go` task can pass
Expand Down Expand Up @@ -110,19 +114,22 @@ build-dev-tools:
fi

.PHONY: lint-go
lint-go:
go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run --config=.golangci.yml
lint-go: $(LOCALBIN)
test -x $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/[email protected]
$(LOCALBIN)/golangci-lint run --config=.golangci.yml

.PHONY: fmt-go
fmt-go:
fmt-go: $(LOCALBIN)
go mod tidy
go run github.com/rinchsan/gosimports/cmd/[email protected] -w -local ${PROJECT_NAME} .
test -x $(LOCALBIN)/gosimports || GOBIN=$(LOCALBIN) go install github.com/rinchsan/gosimports/cmd/[email protected]
$(LOCALBIN)/gosimports -w -local ${PROJECT_NAME} .

# Don't use `buf format` to format the protobuf files! Buf's code style is different from Envoy.
# That will break lots of things.
.PHONY: lint-proto
lint-proto:
go run github.com/bufbuild/buf/cmd/[email protected] lint
lint-proto: $(LOCALBIN)
test -x $(LOCALBIN)/buf || GOBIN=$(LOCALBIN) go install github.com/bufbuild/buf/cmd/[email protected]
$(LOCALBIN)/buf lint

.PHONY: lint-spell
lint-spell: build-dev-tools
Expand All @@ -135,8 +142,9 @@ lint-spell-local:
codespell --skip '.git,.idea,test-envoy,go.mod,go.sum,*.svg' --check-filenames --check-hidden --ignore-words ./.ignore_words

.PHONY: lint-editorconfig
lint-editorconfig:
go run github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
lint-editorconfig: $(LOCALBIN)
test -x $(LOCALBIN)/editorconfig-checker || GOBIN=$(LOCALBIN) go install github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
$(LOCALBIN)/editorconfig-checker

.PHONY: lint
lint: lint-go lint-proto lint-spell lint-editorconfig
Expand Down

0 comments on commit c7f6a6d

Please sign in to comment.