From 2b36c65c932b144720eb48961d753d54e7ab7e63 Mon Sep 17 00:00:00 2001 From: Tobias Reiher Date: Fri, 18 Aug 2023 16:23:25 +0200 Subject: [PATCH] Deduplicate code generation in CI --- .gitlab-ci.yml | 36 +++++++++++++++++++++++++++++++++++- Makefile | 16 ++++++++-------- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7c34fa22d..9df70fdad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -154,14 +154,34 @@ checks: - *setup_python - make check +code_generation: + extends: .testing + services: + - image:recordflux + - cpu:4 + - mem:4 + script: + - *setup_python + - make generate_apps + artifacts: + paths: + - examples/apps/*/build/generated + +.update_timestamps_of_generated_code: &update_timestamps_of_generated_code + - touch examples/apps/*/build/generated/* + tests: extends: .testing + needs: + - setup + - code_generation services: - image:recordflux - cpu:8 - mem:16 script: - git fetch --unshallow + - *update_timestamps_of_generated_code - *setup_gnat - *setup_gnat_cross - *setup_python @@ -188,6 +208,9 @@ python_compatibility: gnat_pro_compatibility: extends: .testing + needs: + - setup + - code_generation services: - image:recordflux - cpu:2 @@ -204,6 +227,7 @@ gnat_pro_compatibility: CLEAN_RECORDFLUX_SETUP: 1 script: - git fetch --unshallow + - *update_timestamps_of_generated_code - *setup_gnat - *activate_nvm - *setup_python @@ -212,6 +236,9 @@ gnat_pro_compatibility: gnat_fsf_compatibility: extends: .testing + needs: + - setup + - code_generation services: - image:recordflux - cpu:2 @@ -224,6 +251,7 @@ gnat_fsf_compatibility: CLEAN_RECORDFLUX_SETUP: 1 script: - git fetch --unshallow + - *update_timestamps_of_generated_code - $CI_PROJECT_DIR/alr -n init --lib alire - pushd alire - $CI_PROJECT_DIR/alr toolchain --select --local gnat_native=$GNAT_VERSION gprbuild=22.0.1 @@ -238,6 +266,9 @@ gnat_fsf_compatibility: gnat_community_compatibility: extends: .testing + needs: + - setup + - code_generation services: - image:recordflux - cpu:2 @@ -250,6 +281,7 @@ gnat_community_compatibility: CLEAN_RECORDFLUX_SETUP: 1 script: - git fetch --unshallow + - *update_timestamps_of_generated_code - curl -L "https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_package.sh" -o install_package.sh - curl -L "https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_script.qs" -o install_script.qs - if [ $GNAT_VERSION == "2021" ]; then @@ -306,8 +338,9 @@ verification_python_tests: verification_apps: extends: .testing - dependencies: + needs: - setup + - code_generation services: - image:recordflux - cpu:4 @@ -318,6 +351,7 @@ verification_apps: - "ping" - "dhcp_client" script: + - *update_timestamps_of_generated_code - *setup_gnat - *setup_spark - *setup_python diff --git a/Makefile b/Makefile index 01c31ea54..43e2e0798 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,8 @@ ADASAT_HEAD = f948e2271aec51f9313fa41ff3c00230a483f9e8 SHELL = /bin/bash PYTEST = python3 -m pytest -n$(TEST_PROCS) -vv --timeout=7200 +APPS := $(filter-out __init__.py,$(notdir $(wildcard examples/apps/*))) + export PYTHONPATH := $(MAKEFILE_DIR) # Switch to a specific revision of the git repository. @@ -151,10 +153,7 @@ test_optimized: PYTHONOPTIMIZE=1 $(PYTEST) tests/unit tests/integration tests/compilation test_apps: - $(MAKE) -C examples/apps/ping test_python - $(MAKE) -C examples/apps/ping test_spark - $(MAKE) -C examples/apps/dhcp_client test - $(MAKE) -C examples/apps/spdm_responder test + $(foreach app,$(APPS),$(MAKE) -C examples/apps/$(app) test || exit;) test_compilation: # Skip test for FSF GNAT to prevent violations of restriction "No_Secondary_Stack" in AUnit units @@ -198,9 +197,7 @@ prove_python_tests: $(GNATPROVE_CACHE_DIR) $(PYTEST) tests/verification prove_apps: $(GNATPROVE_CACHE_DIR) - $(MAKE) -C examples/apps/ping prove - $(MAKE) -C examples/apps/dhcp_client prove - $(MAKE) -C examples/apps/spdm_responder prove + $(foreach app,$(APPS),$(MAKE) -C examples/apps/$(app) prove || exit;) prove_property_tests: $(GNATPROVE_CACHE_DIR) $(PYTEST) tests/property_verification @@ -243,11 +240,14 @@ printenv_gnat: alr printenv \ ) || true -.PHONY: generate +.PHONY: generate generate_apps generate: tools/generate_spark_test_code.py +generate_apps: + $(foreach app,$(APPS),$(MAKE) -C examples/apps/$(app) generate || exit;) + .PHONY: doc html_doc pdf_doc doc: html_doc pdf_doc