diff --git a/cmake/QtPublicSbomOpsHelpers.cmake b/cmake/QtPublicSbomOpsHelpers.cmake index f870581f049..88df68445bd 100644 --- a/cmake/QtPublicSbomOpsHelpers.cmake +++ b/cmake/QtPublicSbomOpsHelpers.cmake @@ -499,6 +499,23 @@ function(_qt_internal_sbom_generate_reuse_source_sbom) endif() set(source_sbom_path "\${QT_SBOM_OUTPUT_PATH_WITHOUT_EXT}.source.spdx") + file(TO_CMAKE_PATH "$ENV{QT_QA_LICENSE_TEST_DIR}/$ENV{QT_SOURCE_SBOM_TEST_SCRIPT}" + full_path_to_license_test) + set(verify_source_sbom " + message(STATUS \"Verifying source SBOM ${source_sbom_path} using qtqa tst_licenses.pl ${full_path_to_license_test}\") + if(NOT EXISTS \"${full_path_to_license_test}\") + message(FATAL_ERROR \"Source SBOM check has failed: The tst_licenses.pl script could not be found at ${full_path_to_license_test}\") + endif() + execute_process( + COMMAND perl \"\$ENV{QT_SOURCE_SBOM_TEST_SCRIPT}\" -sbomonly -sbom \"${source_sbom_path}\" + WORKING_DIRECTORY \"\$ENV{QT_QA_LICENSE_TEST_DIR}\" + RESULT_VARIABLE res + COMMAND_ECHO STDOUT + ) + if(NOT res EQUAL 0) + message(FATAL_ERROR \"Source SBOM check has failed: \${res}\") + endif() +") set(content " message(STATUS \"Generating source SBOM using reuse tool: ${source_sbom_path}\") @@ -508,6 +525,9 @@ function(_qt_internal_sbom_generate_reuse_source_sbom) RESULT_VARIABLE res ) ${handle_error} + if(\"\$ENV{VERIFY_SOURCE_SBOM}\" STREQUAL \"ON\") + ${verify_source_sbom} + endif() ") file(GENERATE OUTPUT "${file_op}" CONTENT "${content}") diff --git a/coin/instructions/coin_module_build_template_v2.yaml b/coin/instructions/coin_module_build_template_v2.yaml index 07c31f111b8..5dd1bb819c0 100644 --- a/coin/instructions/coin_module_build_template_v2.yaml +++ b/coin/instructions/coin_module_build_template_v2.yaml @@ -1,6 +1,7 @@ type: Group instructions: - !include "{{qt/qtbase}}/prepare_building_env.yaml" + - !include "{{qt/qtbase}}/prepare_source_sbom_check.yaml" - type: Group instructions: - type: Group diff --git a/coin/instructions/coin_qtbase_build_template_v2.yaml b/coin/instructions/coin_qtbase_build_template_v2.yaml index f792dbf3af3..f49a69bef0a 100644 --- a/coin/instructions/coin_qtbase_build_template_v2.yaml +++ b/coin/instructions/coin_qtbase_build_template_v2.yaml @@ -1,6 +1,7 @@ type: Group instructions: - !include "{{qt/qtbase}}/prepare_building_env.yaml" + - !include "{{qt/qtbase}}/prepare_source_sbom_check.yaml" - type: Group instructions: - !include "{{qt/qtbase}}/cmake_qtbase_build_instructions.yaml" diff --git a/coin/instructions/prepare_license_test.yaml b/coin/instructions/prepare_license_test.yaml new file mode 100644 index 00000000000..52cd0c38be6 --- /dev/null +++ b/coin/instructions/prepare_license_test.yaml @@ -0,0 +1,47 @@ +type: Group +instructions: + - type: ChangeDirectory + directory: "{{.AgentWorkingDir}}" + - type: EnvironmentVariable + variableName: QTQA_LICHECK_BRANCH + variableValue: "{{ slice .Env.TESTED_MODULE_BRANCH_COIN 5 }}" + enable_if: + condition: runtime + env_var: TESTED_MODULE_BRANCH_COIN + contains_value: "tqtc/" + - type: EnvironmentVariable + variableName: QTQA_LICHECK_BRANCH + variableValue: "{{ .Env.TESTED_MODULE_BRANCH_COIN }}" + disable_if: + condition: runtime + env_var: TESTED_MODULE_BRANCH_COIN + contains_value: "tqtc/" + + # The command must not have whitespace directly after any piping, + # as whitespace directly after pipes will be interpreted as part of the command. + - type: ExecuteCommand + command: ["bash", "-c", "git clone --depth=1 -b {{ .Env.QTQA_LICHECK_BRANCH }} git://{{.Env.QT_COIN_GIT_DAEMON}}/qt-project/qt/qtqa qt/qtqa-latest ||git clone --depth=1 -b dev git://{{.Env.QT_COIN_GIT_DAEMON}}/qt-project/qt/qtqa qt/qtqa-latest"] + maxTimeInSeconds: 600 + maxTimeBetweenOutput: 600 + userMessageOnFailure: > + Failed to clone qtqa sources. Please investigate why. + disable_if: + condition: property + property: host.os + equals_value: Windows + - type: ExecuteCommand + command: ["cmd.exe", "/C", "git clone --depth=1 -b {{ .Env.QTQA_LICHECK_BRANCH }} git://{{.Env.QT_COIN_GIT_DAEMON}}/qt-project/qt/qtqa qt/qtqa-latest ||git clone --depth=1 -b dev git://{{.Env.QT_COIN_GIT_DAEMON}}/qt-project/qt/qtqa qt/qtqa-latest"] + executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution + maxTimeInSeconds: 600 + maxTimeBetweenOutput: 600 + userMessageOnFailure: > + Failed to clone qtqa sources. Please investigate why. + enable_if: + condition: property + property: host.os + equals_value: Windows + - type: EnvironmentVariable + variableName: QT_MODULE_TO_TEST + variableValue: "{{.SourceDir}}" + userMessageOnFailure: > + Failed to set QT_MODULE_TO_TEST environment variable. This should not happen. diff --git a/coin/instructions/prepare_source_sbom_check.yaml b/coin/instructions/prepare_source_sbom_check.yaml new file mode 100644 index 00000000000..a8d588a5222 --- /dev/null +++ b/coin/instructions/prepare_source_sbom_check.yaml @@ -0,0 +1,52 @@ +type: Group +instructions: + # need qemu toolchains update to have perl script verifying source SBOM + - type: Group + instructions: + - type: EnvironmentVariable + variableName: VERIFY_SOURCE_SBOM + variableValue: "OFF" + enable_if: + condition: and + conditions: + - condition: property + property: host.os + equals_value: Linux + - condition: property + property: target.arch + equals_value: MIPS64 + - type: Group + instructions: + - type: EnvironmentVariable + variableName: VERIFY_SOURCE_SBOM + variableValue: "OFF" + enable_if: + condition: and + conditions: + - condition: property + property: host.os + equals_value: Windows + - condition: property + property: target.arch + equals_value: AARCH64 + - type: Group + instructions: + - !include "{{qt/qtbase}}/prepare_license_test.yaml" + - type: Group + instructions: + - type: EnvironmentVariable + variableName: QT_QA_LICENSE_TEST_DIR + variableValue: "{{.AgentWorkingDir}}" + - type: EnvironmentVariable + variableName: QT_SOURCE_SBOM_TEST_SCRIPT + variableValue: "qt{{.Env.CI_PATH_SEP}}qtqa-latest{{.Env.CI_PATH_SEP}}tests{{.Env.CI_PATH_SEP}}prebuild{{.Env.CI_PATH_SEP}}license{{.Env.CI_PATH_SEP}}tst_licenses.pl" + userMessageOnFailure: > + Failed to set QT_SOURCE_SBOM_TEST_SCRIPT environment variable. This should not happen. + enable_if: + condition: property + property: features + contains_value: GenerateSBOM + + + + diff --git a/coin/instructions/run_license_check.yaml b/coin/instructions/run_license_check.yaml index c7bae237aa7..514f53c35c8 100644 --- a/coin/instructions/run_license_check.yaml +++ b/coin/instructions/run_license_check.yaml @@ -1,35 +1,6 @@ type: Group instructions: - - type: ChangeDirectory - directory: "{{.AgentWorkingDir}}" - - type: EnvironmentVariable - variableName: QTQA_LICHECK_BRANCH - variableValue: "{{ slice .Env.TESTED_MODULE_BRANCH_COIN 5 }}" - enable_if: - condition: runtime - env_var: TESTED_MODULE_BRANCH_COIN - contains_value: "tqtc/" - - type: EnvironmentVariable - variableName: QTQA_LICHECK_BRANCH - variableValue: "{{ .Env.TESTED_MODULE_BRANCH_COIN }}" - disable_if: - condition: runtime - env_var: TESTED_MODULE_BRANCH_COIN - contains_value: "tqtc/" - - # The command must not have whitespace directly after any piping, - # as whitespace directly after pipes will be interpreted as part of the command. - - type: ExecuteCommand - command: ["bash", "-c", "git clone --depth=1 -b {{ .Env.QTQA_LICHECK_BRANCH }} git://{{.Env.QT_COIN_GIT_DAEMON}}/qt-project/qt/qtqa qt/qtqa-latest ||git clone --depth=1 -b dev git://{{.Env.QT_COIN_GIT_DAEMON}}/qt-project/qt/qtqa qt/qtqa-latest"] - maxTimeInSeconds: 600 - maxTimeBetweenOutput: 600 - userMessageOnFailure: > - Failed to clone qtqa sources. Please investigate why. - - type: EnvironmentVariable - variableName: QT_MODULE_TO_TEST - variableValue: "{{.SourceDir}}" - userMessageOnFailure: > - Failed to set QT_MODULE_TO_TEST environment variable. This should not happen. + - !include "{{qt/qtbase}}/prepare_license_test.yaml" - type: ExecuteCommand command: perl qt/qtqa-latest/tests/prebuild/license/tst_licenses.pl maxTimeInSeconds: 7200 diff --git a/coin/module_config.yaml b/coin/module_config.yaml index 187f08481a5..1a60f0391b0 100644 --- a/coin/module_config.yaml +++ b/coin/module_config.yaml @@ -12,7 +12,12 @@ machine_type: cores: 4 instructions: + Build: + # to be turned on when the module source SBOM pass the license check + - type: EnvironmentVariable + variableName: VERIFY_SOURCE_SBOM + variableValue: "OFF" - !include "{{qt/qtbase}}/coin_qtbase_build_template_v2.yaml" Test: