From 931cb76707fc7331b9fcbd851a4b5c5c7cd790aa Mon Sep 17 00:00:00 2001 From: "~ . ~" <156969148+wandmagic@users.noreply.github.com> Date: Sat, 30 Mar 2024 14:35:31 -0400 Subject: [PATCH 1/2] only validate on main and develop branch --- build/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build/Makefile b/build/Makefile index 048447a3..339472b2 100644 --- a/build/Makefile +++ b/build/Makefile @@ -184,7 +184,14 @@ validate-xml-content: $(GEN_XML_FILES) ## Validate XML files # .PHONY: validate-xml-by-cli validate-xml-by-cli: $(OSCAL_CLI_INSTALL_PATH) ## Validate XML files by directory using OSCAL CLI Tool - @echo "Validating XML files by directory using OSCAL CLI Tool" + @current_branch=$$(git rev-parse --abbrev-ref HEAD); \ + if [ "$$current_branch" = "main" ] || [ "$$current_branch" = "develop" ]; then \ + echo "Validating XML files by directory using OSCAL CLI Tool on branch $$current_branch"; \ + $(OSCAL_CLI_INSTALL_PATH)/bin/$(OSCAL_CLI_BIN) --version; \ + else \ + echo "Skipping XML validation: not on main or develop branch"; \ + exit + fi @$(OSCAL_CLI_INSTALL_PATH)/bin/$(OSCAL_CLI_BIN) --version @echo "latest oscal-cli version is $(OSCAL_CLI_VERSION)" @echo "Validating OSCAL content with $(OSCAL_CLI_INSTALL_PATH)/bin/oscal-cli version $(OSCAL_CLI_VERSION)" From d3ff4324bac7e013be56ce9744205ed92cd1f3a7 Mon Sep 17 00:00:00 2001 From: "~ . ~" <156969148+wandmagic@users.noreply.github.com> Date: Sat, 30 Mar 2024 14:43:45 -0400 Subject: [PATCH 2/2] Update Makefile --- build/Makefile | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/build/Makefile b/build/Makefile index 339472b2..c40d33cc 100644 --- a/build/Makefile +++ b/build/Makefile @@ -1,4 +1,5 @@ SHELL:=/usr/bin/env bash +BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD) .PHONY: help # Run "make" or "make help" to get a list of user targets @@ -184,14 +185,8 @@ validate-xml-content: $(GEN_XML_FILES) ## Validate XML files # .PHONY: validate-xml-by-cli validate-xml-by-cli: $(OSCAL_CLI_INSTALL_PATH) ## Validate XML files by directory using OSCAL CLI Tool - @current_branch=$$(git rev-parse --abbrev-ref HEAD); \ - if [ "$$current_branch" = "main" ] || [ "$$current_branch" = "develop" ]; then \ - echo "Validating XML files by directory using OSCAL CLI Tool on branch $$current_branch"; \ - $(OSCAL_CLI_INSTALL_PATH)/bin/$(OSCAL_CLI_BIN) --version; \ - else \ - echo "Skipping XML validation: not on main or develop branch"; \ - exit - fi +ifeq ($(BRANCH_NAME),develop) + @echo "Validating XML files by directory using OSCAL CLI Tool" @$(OSCAL_CLI_INSTALL_PATH)/bin/$(OSCAL_CLI_BIN) --version @echo "latest oscal-cli version is $(OSCAL_CLI_VERSION)" @echo "Validating OSCAL content with $(OSCAL_CLI_INSTALL_PATH)/bin/oscal-cli version $(OSCAL_CLI_VERSION)" @@ -203,7 +198,22 @@ validate-xml-by-cli: $(OSCAL_CLI_INSTALL_PATH) ## Validate XML files by director $(OSCAL_CLI_INSTALL_PATH)/bin/oscal-cli "$$example_type" validate "$$xml_file"; \ done \ done - +else ifeq ($(BRANCH_NAME),main) + @echo "Validating XML files by directory using OSCAL CLI Tool" + @$(OSCAL_CLI_INSTALL_PATH)/bin/$(OSCAL_CLI_BIN) --version + @echo "latest oscal-cli version is $(OSCAL_CLI_VERSION)" + @echo "Validating OSCAL content with $(OSCAL_CLI_INSTALL_PATH)/bin/oscal-cli version $(OSCAL_CLI_VERSION)" + @find $(SRC_DIR)/examples -mindepth 1 -maxdepth 1 -type d | while read example_dir; do \ + example_type=$$(basename "$$example_dir"); \ + echo "Processing example type: $$example_type"; \ + find "$$example_dir" -name '*.xml' | while read xml_file; do \ + echo "Validating $$xml_file with OSCAL CLI as $$example_type"; \ + $(OSCAL_CLI_INSTALL_PATH)/bin/oscal-cli "$$example_type" validate "$$xml_file"; \ + done \ + done +else + @echo "Skipping XML validation. Only runs on 'develop' and 'main' branches." +endif .PHONY: clean-xml-content clean-xml-content: ## Clean generated XML content @echo Cleaning XML content