Skip to content

Commit

Permalink
chore: Build tools only once in CI (#1551)
Browse files Browse the repository at this point in the history
  • Loading branch information
k15r authored Oct 23, 2024
1 parent 67f23f6 commit ac3cad7
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/template/prepare-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ runs:
- name: Deploy module release
if: ${{ inputs.release }}
shell: bash
run: make deploy
run: make --debug deploy

- name: Deploy module experimental
if: ${{ !inputs.release }}
shell: bash
run: make deploy-dev
run: make --debug deploy-dev

- name: Wait for manager readiness
shell: bash
Expand Down
25 changes: 23 additions & 2 deletions .github/template/setup-golang/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,29 @@ runs:
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
cache: false

- name: Cache Go
id: go-cache
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
./bin
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}

- name: Install Dependencies
shell: bash
if: steps.go-cache.outputs.cache-hit != 'true'
run: go mod download

- name: Install Tools
shell: bash
run: make install-tools
if: steps.go-cache.outputs.cache-hit != 'true'
run: make --debug install-tools

- name: Cheat make
shell: bash
if: steps.go-cache.outputs.cache-hit == 'true'
run: touch bin/*
2 changes: 1 addition & 1 deletion .github/workflows/pr-code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: "./.github/template/setup-golang"

- name: Run lint
run: make lint
run: make --debug lint

coverage:
runs-on: ubuntu-latest
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pr-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ on:


jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Golang
uses: ./.github/template/setup-golang

e2e:
needs: setup
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -53,6 +63,7 @@ jobs:
job-name: ${{ github.job }}-${{ matrix.ginkgo-labels }}

e2e-dev:
needs: setup
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -81,6 +92,7 @@ jobs:
job-name: ${{ github.job }}-${{ matrix.ginkgo-labels }}

e2e-istio:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -107,6 +119,7 @@ jobs:
job-name: ${{ github.job }}

e2e-self-mon:
needs: setup
strategy:
fail-fast: false
matrix:
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(TOOLS_PKG_NAMES_CL
install-tools: $(TOOLS_BIN_NAMES)

$(TOOLS_BIN_DIR):
mkdir -p $@
if [ ! -d $@ ]; then mkdir -p $@; fi

$(TOOLS_BIN_NAMES): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
cd $(TOOLS_MOD_DIR) && go build -o $@ -trimpath $(filter $(filter %/$(notdir $@),$(TOOLS_PKG_NAMES_CLEAN))%,$(TOOLS_PKG_NAMES))
Expand Down Expand Up @@ -77,7 +77,7 @@ help: ## Display this help.


##@ Development
lint-autofix: $(GOLANGCI_LINT) $(WSL)
lint-fix: $(GOLANGCI_LINT) $(WSL)
-$(WSL) --fix ./...
$(GOLANGCI_LINT) run --fix

Expand Down Expand Up @@ -182,6 +182,11 @@ endif
install: manifests $(KUSTOMIZE) ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

.PHONY: install-with-telemetry
install-with-telemetry: install
kubectl get ns kyma-system || kubectl create ns kyma-system
kubectl apply -f config/samples/operator_v1alpha1_telemetry.yaml -n kyma-system

.PHONY: uninstall
uninstall: manifests $(KUSTOMIZE) ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
Expand Down

0 comments on commit ac3cad7

Please sign in to comment.