Skip to content
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
46 changes: 46 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: integration

on:
push:
branches:
- main
pull_request:

permissions:
actions: none
checks: none
contents: read
deployments: none
issues: none
packages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none

# Cancel in-progress runs for pull requests when developers push
# additional changes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
integration-test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

- name: Setup Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: "~1.24"

- name: Create KinD cluster
uses: helm/kind-action@92086f6be054225fa813e0a4b13787fc9088faab # v1.13.0
with:
cluster_name: integration-test

- name: Run integration tests
run: go test -tags=integration -v -timeout=8m ./...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
coder-logstream-kube
coder-logstream-kube-*
build
build/
87 changes: 87 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Colors for output
GREEN := $(shell printf '\033[32m')
RESET := $(shell printf '\033[0m')
BOLD := $(shell printf '\033[1m')

# Shell source files - use shfmt to find them (respects .editorconfig)
SHELL_SRC_FILES := $(shell shfmt -f .)

.PHONY: all
all: build

.PHONY: build
build:
go build ./...

.PHONY: test
test:
go test ./... -race

.PHONY: test/integration
test/integration:
go test -tags=integration -v -timeout=8m ./...

.PHONY: lint
lint: lint/go lint/shellcheck

.PHONY: lint/go
lint/go:
golangci-lint run --timeout=5m

.PHONY: lint/shellcheck
lint/shellcheck: $(SHELL_SRC_FILES)
echo "--- shellcheck"
shellcheck --external-sources $(SHELL_SRC_FILES)

.PHONY: fmt
fmt: fmt/go fmt/shfmt

.PHONY: fmt/go
fmt/go:
go fmt ./...

.PHONY: fmt/shfmt
fmt/shfmt: $(SHELL_SRC_FILES)
ifdef FILE
# Format single shell script
if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.sh ]]; then \
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET) $(FILE)"; \
shfmt -w "$(FILE)"; \
fi
else
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET)"
# Only do diff check in CI, errors on diff.
ifdef CI
shfmt -d $(SHELL_SRC_FILES)
else
shfmt -w $(SHELL_SRC_FILES)
endif
endif

.PHONY: clean
clean:
rm -f coder-logstream-kube

.PHONY: kind/create
kind/create:
./scripts/kind-setup.sh create

.PHONY: kind/delete
kind/delete:
./scripts/kind-setup.sh delete

.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the project"
@echo " test - Run unit tests"
@echo " test/integration - Run integration tests (requires KinD cluster)"
@echo " lint - Run all linters"
@echo " lint/go - Run golangci-lint"
@echo " lint/shellcheck - Run shellcheck on shell scripts"
@echo " fmt - Format all code"
@echo " fmt/go - Format Go code"
@echo " fmt/shfmt - Format shell scripts"
@echo " kind/create - Create KinD cluster for integration tests"
@echo " kind/delete - Delete KinD cluster"
@echo " clean - Remove build artifacts"
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,42 @@ Kubernetes provides an [informers](https://pkg.go.dev/k8s.io/client-go/informers

- [`SSL_CERT_FILE`](https://go.dev/src/crypto/x509/root_unix.go#L19): Specifies the path to an SSL certificate.
- [`SSL_CERT_DIR`](https://go.dev/src/crypto/x509/root_unix.go#L25): Identifies which directory to check for SSL certificate files.

## Development

### Running Tests

Unit tests can be run with:

```console
go test ./... -race
```

### Integration Tests

Integration tests run against a real Kubernetes cluster using [KinD (Kubernetes in Docker)](https://kind.sigs.k8s.io/).

**Prerequisites:**
- [Docker](https://docs.docker.com/get-docker/)
- [KinD](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
- [kubectl](https://kubernetes.io/docs/tasks/tools/)

**Setup and run:**

```console
# Create a KinD cluster
./scripts/kind-setup.sh create

# Run integration tests
go test -tags=integration -v ./...

# Clean up when done
./scripts/kind-setup.sh delete
```

The integration tests validate:
- Pod event streaming with real Kubernetes informers
- ReplicaSet event handling
- Multi-namespace support
- Label selector filtering

Loading