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

go1.22 and k8s1.29 support #145

Merged
merged 19 commits into from
Apr 26, 2024
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
55 changes: 55 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: golangci-lint
on:
push:
branches:
- master
- main
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.57.2

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
47 changes: 8 additions & 39 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,18 @@ on:

jobs:
tests:

runs-on: ubuntu-latest

steps:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.14.6'
- name: Checkout code
uses: actions/checkout@v2
with:
path: ./src/github.com/${{ github.repository }}
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
path: |
./src/github.com/${{ github.repository }}/vendor
~/go/bin
${{ github.workspace }}/kubebuilder_2.3.1_linux_amd64
key: ${{ runner.os }}-build-depcache-${{ hashFiles('**/Gopkg.lock') }}
restore-keys: |
${{ runner.os }}-build-depcache-
- name: Setup test tooling
run: |
GO111MODULE=on go get github.com/onsi/ginkgo/[email protected]
if ! [[ -x $(go env GOPATH)/bin/golangci-lint ]]; then echo "golangci-lint not found; fetching"; curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0; fi
if ! [[ -d ${{ github.workspace }}/kubebuilder_2.3.1_linux_amd64 ]]; then echo "kubebuilder not found; fetching"; curl -sSfL https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_linux_amd64.tar.gz | tar zxvf -; fi
if ! [[ -x $(go env GOPATH)/bin/dep ]]; then echo "deplint not found; fetching"; curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh; fi
if ! [[ -x $(go env GOPATH)/bin/kustomize ]]; then echo "kustomize not found; fetching"; GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/v3; fi
- name: Download dependencies
run: |
export GOPATH=$(go env GOPATH):$(pwd)
echo "Running dep ensure into ./src/github.com/${{ github.repository }}/vendor"
cd ./src/github.com/${{ github.repository }}
dep ensure --vendor-only
- name: Configure
run: |
export GOPATH=$(go env GOPATH)
export PATH=$GOPATH/bin:$PATH
./configure --with-kubebuilder=${{ github.workspace }}/kubebuilder_2.3.1_linux_amd64/bin --with-kubectl=${{ github.workspace }}/kubebuilder_2.3.1_linux_amd64/bin/kubectl
working-directory: ./src/github.com/${{ github.repository }}
go-version: '1.22'
cache-dependency-path: |
go.sum
go.sum
- name: Run Tests
run: |
export GOPATH=$(go env GOPATH):$(pwd)
cd ./src/github.com/${{ github.repository }}
make check
make test
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Go workspace file
go.work

# Dependency directories
vendor/

# Build output directory
release/

# Environment variables file
.env

# Coverage output
cover.out

# Specific directories
/wave
bin/

# OS generated files
**/.DS_Store

# Tool-specific files
kubebuilder
*.code-workspace
.idea
.vscode
default.etcd/

3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
run:
tests: false
timeout: 30m
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Download the dependencies using [`dep`](https://github.com/golang/dep).
```bash
cd $GOPATH/src/github.com # Create this directory if it doesn't exist
git clone [email protected]:<YOUR_FORK>/wave wave-k8s/wave
dep ensure # Installs dependencies to vendor folder.
go mod tidy
```

## Testing
Expand Down
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# Build the manager binary
FROM golang:1.12 as builder
FROM golang:1.22 as builder

ARG VERSION=undefined

# Install Dep
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh

# Copy in the go src
# Set the working directory
WORKDIR /go/src/github.com/wave-k8s/wave
COPY Gopkg.lock Gopkg.lock
COPY Gopkg.toml Gopkg.toml

# Fetch dependencies before copying code (should cache unless Gopkg's change)
RUN dep ensure --vendor-only
# Copy the go mod and sum files
COPY go.mod go.sum ./

# Fetch dependencies, leveraging Docker cache layers
RUN go mod download

COPY pkg/ pkg/
COPY cmd/ cmd/
# Copy the rest of the source code
COPY . .

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o wave -ldflags="-X main.VERSION=${VERSION}" github.com/wave-k8s/wave/cmd/manager
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o wave -ldflags="-X main.VERSION=${VERSION}" ./cmd/manager

# Copy the controller-manager into a thin image
FROM alpine:3.11
Expand Down
Loading
Loading