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
5 changes: 0 additions & 5 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ blocks:
task:
jobs:
- name: "make build / ci"
env_vars:
- name: CALICO_CRD_PATH
value: config/crd/
- name: CALICO_ADMISSION_POLICY_PATH
value: admission/
commands:
- make build
- make ci
33 changes: 5 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# The tests in this directory use the projectcalico.org/v3 API group for CRDs.
CALICO_API_GROUP ?= projectcalico.org/v3

# If ../metadata.mk exists, we're running this logic from within the calico repository.
# If it does not, then we're in the api repo and we should use the local metadata.mk.
ifneq ("$(wildcard ../metadata.mk)", "")
Expand All @@ -15,7 +12,6 @@ LOCAL_CHECKS = lint-cache-dir check-copyright
BINDIR ?= bin
BUILD_DIR ?= build
TOP_SRC_DIRS = pkg
KIND_CONFIG = $(KIND_DIR)/kind-single.config

##############################################################################
# Download and include ../lib.Makefile before anything else
Expand All @@ -39,14 +35,13 @@ DOCKER_RUN := mkdir -p ../.go-pkg-cache bin $(GOMOD_CACHE) && \
--net=host \
--init \
$(EXTRA_DOCKER_ARGS) \
$(DOCKER_GIT_WORKTREE_ARGS) \
-e LOCAL_USER_ID=$(LOCAL_USER_ID) \
-e GOCACHE=/go-cache \
$(GOARCH_FLAGS) \
-e GOPATH=/go \
-e OS=$(BUILDOS) \
-e GOOS=$(BUILDOS) \
-e "GOFLAGS=$(GOFLAGS)" \
-e GOFLAGS=$(GOFLAGS) \
-v $(CURDIR):/go/src/$(PACKAGE_NAME):rw \
-v $(CURDIR)/../.go-pkg-cache:/go-cache:rw \
-w /go/src/$(PACKAGE_NAME)
Expand All @@ -59,18 +54,6 @@ build: gen-files examples
# Regenerate all files if the gen exes changed or any "types.go" files changed
.PHONY: gen-files
gen-files .generate_files: lint-cache-dir clean-generated
# Generate CRDs without descriptions
$(DOCKER_RUN) $(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) controller-gen crd:allowDangerousTypes=true,crdVersions=v1,deprecatedV1beta1CompatibilityPreserveUnknownFields=false,maxDescLen=0 paths=./pkg/apis/... output:crd:dir=config/crd/'
# Remove the first yaml separator line.
$(DOCKER_RUN) $(CALICO_BUILD) sh -c 'find ./config/crd -name "*.yaml" | xargs sed -i 1d'
# Run prettier to fix indentation
docker run --rm --user $(id -u):$(id -g) -v $(CURDIR)/config/crd/:/work/config/crd/ tmknom/prettier --write --parser=yaml /work
# Patch in manual tweaks to the generated CRDs.
# - Add nullable to IPAM block allocations field to allow null values in the allocations array.
# - Remove the profiles CRD. Profiles are backed by Namespaces in Kubernetes and the CRD is not needed.
patch -p2 < patches/0001-Add-nullable-to-IPAM-block-allocations-field.patch
rm -f config/crd/projectcalico.org_profiles.yaml

# Generate defaults
$(DOCKER_RUN) $(CALICO_BUILD) \
sh -c '$(GIT_CONFIG_SSH) defaulter-gen \
Expand All @@ -79,7 +62,6 @@ gen-files .generate_files: lint-cache-dir clean-generated
--extra-peer-dirs "$(PACKAGE_NAME)/pkg/apis/projectcalico/v3" \
--output-file zz_generated.defaults.go \
"$(PACKAGE_NAME)/pkg/apis/projectcalico/v3"'

# Generate deep copies
$(DOCKER_RUN) $(CALICO_BUILD) \
sh -c '$(GIT_CONFIG_SSH) deepcopy-gen \
Expand Down Expand Up @@ -160,14 +142,9 @@ WHAT?=.
GINKGO_FOCUS?=.*

.PHONY:ut
ut: kind-cluster-create
mkdir -p report
$(DOCKER_RUN) \
--privileged \
-e KUBECONFIG=/kubeconfig.yaml \
-v $(KIND_KUBECONFIG):/kubeconfig.yaml \
$(CALICO_BUILD) \
sh -c 'cd /go/src/$(PACKAGE_NAME) && ginkgo -r --focus="$(GINKGO_FOCUS)" $(WHAT)'
ut:
$(DOCKER_RUN) --privileged $(CALICO_BUILD) \
sh -c 'cd /go/src/$(PACKAGE_NAME) && ginkgo -r -focus="$(GINKGO_FOCUS)" $(WHAT)'

## Check if generated files are out of date
.PHONY: check-generated-files
Expand All @@ -184,4 +161,4 @@ check-generated-files: .generate_files
###############################################################################
.PHONY: ci
## Run what CI runs
ci: clean check-generated-files static-checks build ut
ci: clean check-generated-files build ut static-checks
7 changes: 6 additions & 1 deletion Makefile.local
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ endif
# List of files that we should keep even if they've changed upstream;
# At the moment, we keep the README because this repository has
# its own README; the upstream one isn't relevant to this repository.
KEEP_LOCAL_FILES := README.md
KEEP_LOCAL_FILES := README.md Makefile

# The commit message/PR title to use when we commit our changes
ifneq ($(origin CALICO_GIT_REF), file)
Expand Down Expand Up @@ -110,6 +110,11 @@ pull-upstream-changes:
cp $(CALICO_TEMP_DIR)/lib.Makefile .
cp $(CALICO_TEMP_DIR)/metadata.mk .

# Remove monorepo-only directories and files that don't belong in the
# standalone API repo. The bgpfilter_test.go file requires a kind cluster.
rm -rf config/ admission/ patches/
rm -f pkg/apis/projectcalico/v3/bgpfilter_test.go

# Restores any files that we want to keep even if they're different
# upstream. For example, `README.md` is different in this repository
# than the equivalent file in the upstream repository.
Expand Down
Loading