From a6eb2a4f7324aea414dcb9e07f70d22b83010b2c Mon Sep 17 00:00:00 2001 From: Vladyslav Podorozhnyi Date: Wed, 24 Jan 2024 10:11:43 +0100 Subject: [PATCH] Integration tests workflow improvement (#217) * Update full-integration-tests.yaml * Add optional input on integration test directory. * Add exclusion list - directories from exclusion list should be also splited on multiple batches * Add exclusion list - directories from exclusion list should be also splited on multiple batches * Add exclusion list - directories from exclusion list should be also splited on multiple batches * Add exclusion list - directories from exclusion list should be also splited on multiple batches * Add exclusion list - directories from exclusion list should be also splited on multiple batches * Add exclusion list - directories from exclusion list should be also splited on multiple batches * Add exclusion list - directories from exclusion list should be also splited on multiple batches * Add exclusion list - directories from exclusion list should be also splited on multiple batches * Update full-integration-tests.yaml --- .github/workflows/full-integration-tests.yaml | 70 +++++++++++++++---- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/.github/workflows/full-integration-tests.yaml b/.github/workflows/full-integration-tests.yaml index 5aaa8a5..feb6e2b 100644 --- a/.github/workflows/full-integration-tests.yaml +++ b/.github/workflows/full-integration-tests.yaml @@ -1,3 +1,5 @@ +## Workflow is only for Magento 2 Main repo - app/code and dev/tests/integration are supported only +## 3rd party modules are not supported yet name: Integration Tests - Full Test Suite run-name: ${{ github.actor }} is running Full Integration Test Suite @@ -12,6 +14,10 @@ on: type: string description: "head SHA" required: true + test_directory: + type: string + description: "Test directory to run integration tests" + required: false permissions: contents: write @@ -49,10 +55,24 @@ jobs: name: Calculate Matrix for testsuite working-directory: dev/tests/integration run: | + + ### TODO: rebuild all that hell to node-js + + if [ -n "${{ github.event.inputs.test_directory }}" ]; then + echo "testsuite_dirs=['${{ github.event.inputs.test_directory }}']" >> "$GITHUB_OUTPUT" + exit 0 + fi + OUTPUT_FILE="integration-testsuites.json" TESTSUITE_DIR="./testsuite/Magento" CODE_DIR="../../../app/code" - MAX_DIRS_PER_LINE=15 + MAX_DIRS_PER_LINE=1 + + ## variable with array of exclusion list of directories - they will be handled separately and splitted on more batches + EXCLUSION_LIST=("./testsuite/Magento/Catalog" "./testsuite/Magento/Bundle" "./testsuite/Magento/AsynchronousOperations" "./testsuite/Magento/Sales") + + ## variable with array of exclusion list of files - separate run will be executed for each file (separate place in tests matrix) + STANDALONE_TESTS=("./testsuite/Magento/AsynchronousOperations/Model/MassScheduleTest.php" "./testsuite/Magento/Catalog/Observer/SwitchPriceAttributeScopeOnConfigChangeTest.php") # Initialize variables dir_count=0 @@ -80,7 +100,11 @@ jobs: # Iterate over the directories and populate the JSON content while IFS= read -r -d '' dir; do - add_dir_to_line "${dir}" + # if dir is in EXCLUSION_LIST then skip it + if [[ " ${EXCLUSION_LIST[@]} " =~ " ${dir} " ]]; then + continue + fi + add_dir_to_line "${dir}" done < <(find "$TESTSUITE_DIR" -mindepth 1 -maxdepth 1 -type d -print0) # Add app/code integration test directories @@ -88,7 +112,36 @@ jobs: relative_dir="${dir}" # Convert absolute path to relative add_dir_to_line "$relative_dir" done < <(find "$CODE_DIR" -mindepth 4 -maxdepth 4 -type d -name 'Integration' -print0) - + + # Handle exclusion list + # run over EXCLUSION_LIST, find all "*Test.php" files, and put them in array. Exclude directories. + EXCLUSION_LIST_FILES=() + for dir in "${EXCLUSION_LIST[@]}"; do + while IFS= read -r -d '' file; do + # check if file is in STANDALONE_TESTS + if [[ " ${STANDALONE_TESTS[@]} " =~ " ${file} " ]]; then + continue + fi + EXCLUSION_LIST_FILES+=("$file") + done < <(find "$dir" -mindepth 1 -type f -name '*Test.php' -print0) + done + + ## run over EXCLUSION_LIST_FILES and call add_dir_to_line for each file + MAX_DIRS_PER_LINE=10 + dir_count=MAX_DIRS_PER_LINE-1 + add_dir_to_line "" + for file in "${EXCLUSION_LIST_FILES[@]}"; do + add_dir_to_line "$file" + done + + ## run over STANDALONE_TESTS and call add_dir_to_line for each file + MAX_DIRS_PER_LINE=1 + dir_count=MAX_DIRS_PER_LINE-1 + add_dir_to_line "" + for file in "${STANDALONE_TESTS[@]}"; do + add_dir_to_line "$file" + done + # Handle the last line if it's not empty if [ -n "$current_line" ]; then json_content="$json_content$current_line" @@ -158,17 +211,6 @@ jobs: run_magento_integration_tests_real_suite: 0 base_directory: "./main" - # TODO: this have to be removed after we analyse and fix all tests - # added now because it kills too many tests that are going to be running - - name: Skip invalid tests - working-directory: ./main - run: | - echo "Patch file dev/tests/integration/testsuite/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/DownloadableTest.php" - echo "Add new line after line 47" - sed -i '47 a $this->markTestSkipped('"'"'TODO: skipped temporary due to execution errors'"'"');' dev/tests/integration/testsuite/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/DownloadableTest.php - echo "Patch complete" - # here bash code that perform the patch ends - - name: Create Mage-OS testsuite working-directory: ./main/dev/tests/integration run: |