Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
73 changes: 57 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# Detect the root directory of this Makefile
# Explicitly strip the trailing slash from the path
# We will add the slash manually when required to prevent double slashes in the paths
ROOT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
PROJECT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))

export PATH := $(PATH):$(PWD)/bin
## Location to install dependencies to
# If you are setting this externally then you must use an absolute path
LOCALBIN ?= $(PROJECT_DIR)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

Comment thread
fontivan marked this conversation as resolved.
# YAMLLINT_VERSION defines the yamllint version to download from GitHub releases.
YAMLLINT_VERSION ?= 1.35.1

# YQ_VERSION defines the yq version to download from GitHub releases.
YQ_VERSION ?= v4.45.4

# Prefer binaries in the local bin directory over system binaries.
export PATH := $(abspath $(LOCALBIN)):$(PATH)
export CARGO_TERM_COLOR := always

# The 'all' target is the default goal.
Expand All @@ -14,40 +27,62 @@ all: yamllint rust-ci
.PHONY: clean
clean:
@rm -rf target
@rm -rf bin
@rm -rf $(LOCALBIN)

.PHONY: test
test: rust-test
@echo "All testing tasks completed successfully."

# Konflux targets

.PHONY: sync-git-submodules
sync-git-submodules: ## Sync git submodules (honors SKIP_SUBMODULE_SYNC=yes)
@echo "Checking git submodules"
@if [ "$(SKIP_SUBMODULE_SYNC)" != "yes" ]; then \
echo "Syncing git submodules"; \
git submodule sync --recursive; \
git submodule update --init --recursive; \
else \
echo "Skipping submodule sync"; \
fi

Comment thread
coderabbitai[bot] marked this conversation as resolved.
.PHONY: konflux-filter-unused-redhat-repos
konflux-filter-unused-redhat-repos: ## Filter unused repositories from redhat.repo files in both runtime and build lock folders
konflux-filter-unused-redhat-repos: sync-git-submodules ## Filter unused repositories from redhat.repo files in both runtime and build lock folders
@echo "Filtering unused repositories from runtime lock folder..."
$(MAKE) -C $(ROOT_DIR)/telco5g-konflux/scripts/rpm-lock filter-unused-repos REPO_FILE=$(ROOT_DIR)/.konflux/lock-runtime/redhat.repo
$(MAKE) -C $(PROJECT_DIR)/telco5g-konflux/scripts/rpm-lock filter-unused-repos REPO_FILE=$(PROJECT_DIR)/.konflux/lock-runtime/redhat.repo
@echo "Filtering unused repositories from build lock folder..."
$(MAKE) -C $(ROOT_DIR)/telco5g-konflux/scripts/rpm-lock filter-unused-repos REPO_FILE=$(ROOT_DIR)/.konflux/lock-build/redhat.repo
$(MAKE) -C $(PROJECT_DIR)/telco5g-konflux/scripts/rpm-lock filter-unused-repos REPO_FILE=$(PROJECT_DIR)/.konflux/lock-build/redhat.repo
@echo "Filtering completed for both lock folders."

.PHONY: konflux-update-tekton-task-refs
konflux-update-tekton-task-refs: ## Update task references in Tekton pipeline files
konflux-update-tekton-task-refs: sync-git-submodules ## Update task references in Tekton pipeline files
@echo "Updating task references in Tekton pipeline files..."
$(MAKE) -C $(ROOT_DIR)/telco5g-konflux/scripts/tekton update-task-refs PIPELINE_FILES="$(shell find $(ROOT_DIR)/.tekton -name '*.yaml' -not -name 'OWNERS' | tr '\n' ' ')"
$(MAKE) -C $(PROJECT_DIR)/telco5g-konflux/scripts/tekton update-task-refs \
PIPELINE_FILES="$$(find $(PROJECT_DIR)/.tekton -type f \( -name '*.yaml' -o -name '*.yml' \) -print0 | xargs -0 -r printf '%s ')"
@echo "Task references updated successfully."

.PHONY: yamllint
yamllint: ## Download yamllint and lint YAML files in the repository
.PHONY: yamllint-download
yamllint-download: sync-git-submodules $(LOCALBIN) ## Download yamllint
@echo "Downloading yamllint..."
$(MAKE) -C $(ROOT_DIR)/telco5g-konflux/scripts/download download-yamllint DOWNLOAD_INSTALL_DIR=$(ROOT_DIR)/bin
$(MAKE) -C $(PROJECT_DIR)/telco5g-konflux/scripts/download \
download-yamllint \
DOWNLOAD_INSTALL_DIR=$(LOCALBIN) \
DOWNLOAD_YAMLLINT_VERSION=$(YAMLLINT_VERSION)
@echo "Yamllint downloaded successfully."

.PHONY: yamllint
yamllint: yamllint-download ## Lint YAML files in the repository
@echo "Running yamllint on repository YAML files..."
yamllint -c $(ROOT_DIR)/.yamllint.yaml .
yamllint -c $(PROJECT_DIR)/.yamllint.yaml .
@echo "YAML linting completed successfully."

.PHONY: yq
yq: ## Download yq
yq: sync-git-submodules $(LOCALBIN) ## Download yq
@echo "Downloading yq..."
$(MAKE) -C $(ROOT_DIR)/telco5g-konflux/scripts/download download-yq DOWNLOAD_INSTALL_DIR=$(ROOT_DIR)/bin
$(MAKE) -C $(PROJECT_DIR)/telco5g-konflux/scripts/download \
download-yq \
DOWNLOAD_INSTALL_DIR=$(LOCALBIN) \
DOWNLOAD_YQ_VERSION=$(YQ_VERSION)
@echo "Yq downloaded successfully."

.PHONY: yq-sort-and-format
Expand All @@ -65,10 +100,16 @@ konflux-all: konflux-filter-unused-redhat-repos konflux-update-tekton-task-refs

# Rust build targets

.PHONY: rust-compile
rust-compile: sync-git-submodules rust-deps ## Compile the Rust code
@echo "Compiling Rust code..."
cargo build --release --bin recert
@echo "Compilation completed successfully."

.PHONY: rust-deps
rust-deps: ## Install Rust build dependencies (protobuf-compiler, rustfmt, rust, clippy)
@echo "Installing Rust build dependencies..."
hack/rust-deps.sh
$(PROJECT_DIR)/hack/rust-deps.sh
@echo "Dependencies installed successfully."

.PHONY: rust-fmt
Expand Down Expand Up @@ -96,7 +137,7 @@ rust-test: ## Run Rust tests
@echo "Tests completed successfully."

.PHONY: rust-ci
rust-ci: rust-deps rust-fmt rust-check rust-clippy rust-test ## Run all Rust CI checks (used for Github actions workflow)
rust-ci: rust-deps rust-fmt rust-check rust-clippy rust-test rust-compile ## Run all Rust CI checks (used for Github actions workflow)
@echo "All Rust CI checks completed successfully."

.PHONY: help
Expand Down