Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to go 1.22 #8125

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
*
!.git
!.goreleaser*
!.golangci*
!.mockery.yaml
!build/scripts
!cmd
!examples
!go.*
!integration
!LICENSE
!Makefile*
!pkg
!tools.go
.editorconfig
.dockerignore
.github
.gitignore
*.md
*.toml
docs
eksctl
examples
logo
userdocs
CNAME
DCO
LICENSE
6 changes: 1 addition & 5 deletions .github/actions/setup-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 #v5.0.0
with:
go-version: 1.21.x
go-version: 1.22.x
cache: false
- name: Cache go-build and mod
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 #v4.0.0
Expand All @@ -19,7 +19,3 @@ runs:
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
- name: Setup deps
shell: bash
run: |
make install-build-deps
49 changes: 0 additions & 49 deletions .github/workflows/build-all-distros-nightly.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/cache-dependencies.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/ecr-publish-build.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ecr-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
13 changes: 8 additions & 5 deletions .github/workflows/test-and-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- name: Lint
run: |
PATH=$PATH:$(go env GOPATH)/bin make lint

image:
name: Build and check image
runs-on: ubuntu-latest
Expand All @@ -40,8 +41,10 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
with:
fetch-depth: 0
- name: Setup build environment
uses: ./.github/actions/setup-build
- name: build
run: |
PATH=$PATH:$(go env GOPATH)/bin make -f Makefile.docker check-build-image-manifest-up-to-date
- name: Build image
id: push
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc #v6.11.0
with:
context: .
file: ./Dockerfile
push: false
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# options for analysis running
run:
go: "1.21"
go: "1.22"

# default concurrency is a available CPU number
concurrency: 4
Expand Down
15 changes: 0 additions & 15 deletions .requirements

This file was deleted.

15 changes: 1 addition & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ then head to the [main docs](https://eksctl.io/) for more information.

This project is written in Go. To be able to contribute you will need:

1. A working Go installation of Go >= 1.12. You can check the
1. A working Go installation of Go >= 1.22. You can check the
[official installation guide](https://golang.org/doc/install).

2. Make sure that `$(go env GOPATH)/bin` is in your shell's `PATH`. You can do so by
Expand Down Expand Up @@ -344,19 +344,6 @@ To run the tests simply run the following after `install-build-deps`:
make test
```

If you prefer to use Docker, the same way it is used in CI, you can use the
following command:

```bash
make -f Makefile.docker test
```

> NOTE: It is not the most convenient way of working on the project, as
> binaries are built inside the container and cannot be tested manually,
> also majority of end-users consume binaries and not Docker images.
> It is recommended to use `make build` etc, unless there is an issue in CI
> that need troubleshooting.

#### Running the integration tests

> NOTE: Some parts of the integration tests are not configurable and therefore
Expand Down
26 changes: 13 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
ARG BUILD_IMAGE=public.ecr.aws/eksctl/eksctl-build:833f4464e865a6398788bf6cbc5447967b8974b7
FROM $BUILD_IMAGE as build
# syntax=docker/dockerfile:1
FROM public.ecr.aws/docker/library/golang:1.22.10 AS builder

WORKDIR /src
COPY . .

COPY . /src
RUN --mount=type=cache,target=/go/pkg/mod <<EOT
go mod download
EOT

RUN make test
RUN make build \
&& cp ./eksctl /out/usr/local/bin/eksctl
RUN make build-integration-test \
&& mkdir -p /out/usr/local/share/eksctl \
&& cp -r integration/data/*.yaml integration/scripts /out/usr/local/share/eksctl \
&& cp ./eksctl-integration-test /out/usr/local/bin/eksctl-integration-test
RUN <<EOT
make build
chown 65532 eksctl
EOT

FROM scratch
COPY --from=build /out /
ENTRYPOINT ["eksctl"]
FROM public.ecr.aws/eks-distro/kubernetes/go-runner:v0.16.4-eks-1-31-11 AS go-runner
COPY --from=builder /src/eksctl /eksctl
ENTRYPOINT ["/eksctl"]
32 changes: 15 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
include Makefile.common
include Makefile.docs
include Makefile.docker

version_pkg := github.com/weaveworks/eksctl/pkg/version

Expand Down Expand Up @@ -33,11 +32,15 @@ endif

##@ Dependencies
.PHONY: install-all-deps
install-all-deps: install-build-deps install-site-deps ## Install all dependencies for building both binary and user docs)
install-all-deps: install-site-deps ## Install all dependencies for building both binary and user docs)

.PHONY: install-build-deps
install-build-deps: ## Install dependencies (packages and tools)
build/scripts/install-build-deps.sh
.PHONY: install-tools
install-tools: ## Install dependencies for code generation and test execution
go install github.com/golangci/golangci-lint/cmd/golangci-lint
go install github.com/cloudflare/cfssl/cmd/...@latest
go install github.com/maxbrunsfeld/counterfeiter/v6
go install github.com/vektra/mockery/v2
go install github.com/vburenin/ifacemaker

##@ Build

Expand Down Expand Up @@ -77,32 +80,32 @@ $(info will launch integration tests for Kubernetes version $(INTEGRATION_TEST_V
endif

.PHONY: lint
lint: ## Run linter over the codebase
lint: install-tools ## Run linter over the codebase
golangci-lint run --timeout=30m

.PHONY: test
test: ## Lint, generate and run unit tests. Also ensure that integration tests compile
test: install-tools ## Lint, generate and run unit tests. Also ensure that integration tests compile
$(MAKE) lint
$(MAKE) unit-test
$(MAKE) build-integration-test

.PHONY: unit-test
unit-test: check-all-generated-files-up-to-date unit-test-no-generate

.PHONY: unit-test-no-generate ## Run unit test only
unit-test-no-generate:
.PHONY: unit-test-no-generate
unit-test-no-generate: install-tools ## Run unit test only
CGO_ENABLED=0 go test -tags=release ./pkg/... ./cmd/... $(UNIT_TEST_ARGS)

.PHONY: unit-test-race
unit-test-race: ## Run unit test with race detection
unit-test-race: install-tools ## Run unit test with race detection
CGO_ENABLED=1 go test -race ./pkg/... ./cmd/... $(UNIT_TEST_ARGS)

.PHONY: build-integration-test
build-integration-test: $(all_generated_code) ## Ensure integration tests compile
@# Compile integration test binary without running any.
@# Required as build failure aren't listed when running go build below. See also: https://github.com/golang/go/issues/15513
go test -tags integration -run=^$$ ./integration/...
@# Build integration test binary:
@# Build integration test binary:
go build -tags integration -o ./eksctl-integration-test ./integration/main.go

.PHONY: integration-test
Expand Down Expand Up @@ -139,7 +142,7 @@ delete-integration-test-dev-cluster: build ## Delete the test cluster for use wh
##@ Code Generation

.PHONY: generate-always
generate-always: pkg/addons/default/assets/aws-node.yaml ## Generate code (required for every build)
generate-always: install-tools ## Generate code (required for every build)
go generate ./pkg/apis/eksctl.io/v1alpha5/generate.go
go generate ./pkg/nodebootstrap
go generate ./pkg/addons
Expand Down Expand Up @@ -179,15 +182,11 @@ $(generated_code_deep_copy_helper): $(deep_copy_helper_input) ## Generate Kuber
$(generated_code_aws_sdk_mocks): $(call godeps,pkg/eks/mocks/mocks.go) ## Generate AWS SDK mocks
AWS_SDK_GO_DIR=$(AWS_SDK_GO_DIR) go generate ./pkg/eks/mocks


.PHONY: generate-kube-reserved
generate-kube-reserved: ## Update instance list with respective specs
@cd ./pkg/nodebootstrap/ && go run reserved_generate.go

##@ Release
# .PHONY: eksctl-image
# eksctl-image: ## Build the eksctl image that has release artefacts and no build dependencies
# $(MAKE) -f Makefile.docker $@

.PHONY: prepare-release
prepare-release: ## Create release
Expand All @@ -200,4 +199,3 @@ prepare-release-candidate: ## Create release candidate
.PHONY: print-version
print-version: ## Prints the upcoming release number
@go run pkg/version/generate/release_generate.go print-version

2 changes: 0 additions & 2 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ git_org := $(shell dirname $(full_repo_name))
eksctl_version := $(shell go run pkg/version/generate/release_generate.go print-version)

unique_tag = $(shell printf "%s-%s-%s" `git rev-parse @` $(build_image_tag) $(built_at))

eksctl_image_name ?= weaveworks/eksctl:latest
Loading
Loading