From a819548650a2c452ab189ea43afadcb2dd6f4778 Mon Sep 17 00:00:00 2001 From: Lukas Dullinger <129603980+itislu@users.noreply.github.com> Date: Fri, 26 Jul 2024 04:48:22 +0200 Subject: [PATCH 1/4] ci: Use reusable workflow for regression test --- .github/workflows/regression_test.yaml | 76 ++++++++++++ .github/workflows/test.yaml | 164 ++----------------------- 2 files changed, 88 insertions(+), 152 deletions(-) create mode 100644 .github/workflows/regression_test.yaml diff --git a/.github/workflows/regression_test.yaml b/.github/workflows/regression_test.yaml new file mode 100644 index 00000000..cf538f29 --- /dev/null +++ b/.github/workflows/regression_test.yaml @@ -0,0 +1,76 @@ +# .github/workflows/regression_test.yaml +name: Regression Test + +on: + workflow_call: + inputs: + test_mode: + required: true + type: string + outputs: + source_failed_count: + description: Number of failed test cases on source branch + value: ${{ jobs.regression_test.outputs.source_failed_count }} + target_failed_count: + description: Number of failed test cases on target branch + value: ${{ jobs.regression_test.outputs.target_failed_count }} + +env: + HOME: /home/runner + TESTER_DIR: /home/runner/42_minishell_tester + SCRIPTS_DIR: /home/runner/scripts + SOURCE_FAILED_COUNT: 0 + TARGET_FAILED_COUNT: 0 + +jobs: + regression_test: + name: Regression Test + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + source_failed_count: ${{ env.SOURCE_FAILED_COUNT }} + target_failed_count: ${{ env.TARGET_FAILED_COUNT }} + steps: + - name: Checkout source branch of pull request + uses: actions/checkout@v4 + + - name: Set up test environment + uses: ./.github/actions/setup + + - name: 🌱 Test source branch of pull request + run: | + make re CC=clang-12 + ${{ env.TESTER_DIR }}/tester.sh ${{ inputs.test_mode }} > ${{ env.HOME }}/source_test_result.txt + env: + GH_BRANCH: SOURCE_FAILED_COUNT + + - name: Save tester output to home directory + run: mv -f tester_output ${{ env.HOME }} || true + + - name: 📝 Print all test cases that failed on source branch + run: ${{ env.SCRIPTS_DIR }}/print_all_failed_test_cases.sh + env: + RESULT_FILE: ${{ env.HOME }}/source_test_result.txt + TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output + + - name: Checkout target branch of pull request + uses: actions/checkout@v4 + with: + ref: ${{ github.base_ref }} + + - name: 🎯 Test target branch of pull request + run: | + make re CC=clang-12 + ${{ env.TESTER_DIR }}/tester.sh ${{ inputs.test_mode }} > ${{ env.HOME }}/target_test_result.txt + env: + GH_BRANCH: TARGET_FAILED_COUNT + + - name: Checkout source branch of pull request + uses: actions/checkout@v4 + + - name: 📜 Summarize regression test result + uses: ./.github/actions/summary_test_result + env: + SOURCE_FAILED_COUNT: ${{ env.SOURCE_FAILED_COUNT }} + TARGET_FAILED_COUNT: ${{ env.TARGET_FAILED_COUNT }} + TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f5efe038..898054dd 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -93,168 +93,28 @@ jobs: mand_regression_test: name: Mandatory Part Regression Test - runs-on: ubuntu-latest needs: compilation_test - timeout-minutes: 10 - steps: - - name: Checkout source branch of pull request - uses: actions/checkout@v4 - - name: Set up test environment - uses: ./.github/actions/setup - - name: 🌱 Test source branch of pull request - run: | - make re CC=clang-12 - ${{ env.TESTER_DIR }}/tester.sh m > ${{ env.HOME }}/source_test_result.txt - env: - GH_BRANCH: SOURCE_FAILED_COUNT - - name: Save tester output to home directory - run: mv -f tester_output ${{ env.HOME }} || true - - name: 📝 Print all test cases that failed on source branch - run: ${{ env.SCRIPTS_DIR }}/print_all_failed_test_cases.sh - env: - RESULT_FILE: ${{ env.HOME }}/source_test_result.txt - TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output - - name: Checkout target branch of pull request - uses: actions/checkout@v4 - with: - ref: ${{ github.base_ref }} - - name: 🎯 Test target branch of pull request - run: | - make re CC=clang-12 - ${{ env.TESTER_DIR }}/tester.sh m > ${{ env.HOME }}/target_test_result.txt - env: - GH_BRANCH: TARGET_FAILED_COUNT - - name: Checkout source branch of pull request - uses: actions/checkout@v4 - - name: 📜 Summarize regression test result - uses: ./.github/actions/summary_test_result - env: - SOURCE_FAILED_COUNT: ${{ env.SOURCE_FAILED_COUNT }} - TARGET_FAILED_COUNT: ${{ env.TARGET_FAILED_COUNT }} - TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output + uses: ./.github/workflows/regression_test.yaml + with: + test_mode: 'm' bonus_regression_test: name: Bonus Part Regression Test - runs-on: ubuntu-latest needs: compilation_test - timeout-minutes: 10 - steps: - - name: Checkout source branch of pull request - uses: actions/checkout@v4 - - name: Set up test environment - uses: ./.github/actions/setup - - name: 🌱 Test source branch of pull request - run: | - make re CC=clang-12 - ${{ env.TESTER_DIR }}/tester.sh b > ${{ env.HOME }}/source_test_result.txt - env: - GH_BRANCH: SOURCE_FAILED_COUNT - - name: Save tester output to home directory - run: mv -f tester_output ${{ env.HOME }} || true - - name: 📝 Print all test cases that failed on source branch - run: ${{ env.SCRIPTS_DIR }}/print_all_failed_test_cases.sh - env: - RESULT_FILE: ${{ env.HOME }}/source_test_result.txt - TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output - - name: Checkout target branch of pull request - uses: actions/checkout@v4 - with: - ref: ${{ github.base_ref }} - - name: 🎯 Test target branch of pull request - run: | - make re CC=clang-12 - ${{ env.TESTER_DIR }}/tester.sh b > ${{ env.HOME }}/target_test_result.txt - env: - GH_BRANCH: TARGET_FAILED_COUNT - - name: Checkout source branch of pull request - uses: actions/checkout@v4 - - name: 📜 Summarize regression test result - uses: ./.github/actions/summary_test_result - env: - SOURCE_FAILED_COUNT: ${{ env.SOURCE_FAILED_COUNT }} - TARGET_FAILED_COUNT: ${{ env.TARGET_FAILED_COUNT }} - TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output + uses: ./.github/workflows/regression_test.yaml + with: + test_mode: 'b' empty_env_regression_test: name: Empty Env Regression Test - runs-on: ubuntu-latest needs: compilation_test - timeout-minutes: 10 - steps: - - name: Checkout source branch of pull request - uses: actions/checkout@v4 - - name: Set up test environment - uses: ./.github/actions/setup - - name: 🌱 Test source branch of pull request - run: | - make re CC=clang-12 - ${{ env.TESTER_DIR }}/tester.sh ne > ${{ env.HOME }}/source_test_result.txt - env: - GH_BRANCH: SOURCE_FAILED_COUNT - - name: Save tester output to home directory - run: mv -f tester_output ${{ env.HOME }} || true - - name: 📝 Print all test cases that failed on source branch - run: ${{ env.SCRIPTS_DIR }}/print_all_failed_test_cases.sh - env: - RESULT_FILE: ${{ env.HOME }}/source_test_result.txt - TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output - - name: Checkout target branch of pull request - uses: actions/checkout@v4 - with: - ref: ${{ github.base_ref }} - - name: 🎯 Test target branch of pull request - run: | - make re CC=clang-12 - ${{ env.TESTER_DIR }}/tester.sh ne > ${{ env.HOME }}/target_test_result.txt - env: - GH_BRANCH: TARGET_FAILED_COUNT - - name: Checkout source branch of pull request - uses: actions/checkout@v4 - - name: 📜 Summarize regression test result - uses: ./.github/actions/summary_test_result - env: - SOURCE_FAILED_COUNT: ${{ env.SOURCE_FAILED_COUNT }} - TARGET_FAILED_COUNT: ${{ env.TARGET_FAILED_COUNT }} - TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output + uses: ./.github/workflows/regression_test.yaml + with: + test_mode: 'ne' hardcore_regression_test: name: Hardcore Regression Test - runs-on: ubuntu-latest needs: compilation_test - timeout-minutes: 10 - steps: - - name: Checkout source branch of pull request - uses: actions/checkout@v4 - - name: Set up test environment - uses: ./.github/actions/setup - - name: 🌱 Test source branch of pull request - run: | - make re CC=clang-12 - ${{ env.TESTER_DIR }}/tester.sh d > ${{ env.HOME }}/source_test_result.txt - env: - GH_BRANCH: SOURCE_FAILED_COUNT - - name: Save tester output to home directory - run: mv -f tester_output ${{ env.HOME }} || true - - name: 📝 Print all test cases that failed on source branch - run: ${{ env.SCRIPTS_DIR }}/print_all_failed_test_cases.sh - env: - RESULT_FILE: ${{ env.HOME }}/source_test_result.txt - TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output - - name: Checkout target branch of pull request - uses: actions/checkout@v4 - with: - ref: ${{ github.base_ref }} - - name: 🎯 Test target branch of pull request - run: | - make re CC=clang-12 - ${{ env.TESTER_DIR }}/tester.sh d > ${{ env.HOME }}/target_test_result.txt - env: - GH_BRANCH: TARGET_FAILED_COUNT - - name: Checkout source branch of pull request - uses: actions/checkout@v4 - - name: 📜 Summarize regression test result - uses: ./.github/actions/summary_test_result - env: - SOURCE_FAILED_COUNT: ${{ env.SOURCE_FAILED_COUNT }} - TARGET_FAILED_COUNT: ${{ env.TARGET_FAILED_COUNT }} - TESTER_OUTPUT_DIR: ${{ env.HOME }}/tester_output + uses: ./.github/workflows/regression_test.yaml + with: + test_mode: 'd' From 2d15c9043a0169d2385db61ba40b888d241a5f58 Mon Sep 17 00:00:00 2001 From: Lukas Dullinger <129603980+itislu@users.noreply.github.com> Date: Fri, 26 Jul 2024 04:50:32 +0200 Subject: [PATCH 2/4] ci: Use matrix for reusable regression test --- .github/workflows/regression_test.yaml | 7 ++++- .github/workflows/test.yaml | 40 +++++++++++--------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/.github/workflows/regression_test.yaml b/.github/workflows/regression_test.yaml index cf538f29..0138189b 100644 --- a/.github/workflows/regression_test.yaml +++ b/.github/workflows/regression_test.yaml @@ -5,8 +5,13 @@ on: workflow_call: inputs: test_mode: + description: Test mode (m, b, ne, d, a) required: true type: string + test_name: + description: Name of the test + required: false + type: string outputs: source_failed_count: description: Number of failed test cases on source branch @@ -24,7 +29,7 @@ env: jobs: regression_test: - name: Regression Test + name: ${{ inputs.test_name }} runs-on: ubuntu-latest timeout-minutes: 10 outputs: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 898054dd..6ccd1728 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -91,30 +91,22 @@ jobs: - name: Combine memory leak test results run: echo "All memory leak tests finished" - mand_regression_test: - name: Mandatory Part Regression Test - needs: compilation_test - uses: ./.github/workflows/regression_test.yaml - with: - test_mode: 'm' - - bonus_regression_test: - name: Bonus Part Regression Test - needs: compilation_test - uses: ./.github/workflows/regression_test.yaml - with: - test_mode: 'b' - - empty_env_regression_test: - name: Empty Env Regression Test - needs: compilation_test - uses: ./.github/workflows/regression_test.yaml - with: - test_mode: 'ne' - - hardcore_regression_test: - name: Hardcore Regression Test + regression_test: + name: Regression Test needs: compilation_test + strategy: + fail-fast: false + matrix: + include: + - test_mode: m + test_name: Mandatory Part + - test_mode: b + test_name: Bonus Part + - test_mode: ne + test_name: Empty Env + - test_mode: d + test_name: Hardcore uses: ./.github/workflows/regression_test.yaml with: - test_mode: 'd' + test_mode: ${{ matrix.test_mode }} + test_name: ${{ matrix.test_name }} From a810fd1a6e83651ac7573ced262c1c33daa4aa64 Mon Sep 17 00:00:00 2001 From: Lukas Dullinger <129603980+itislu@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:18:48 +0200 Subject: [PATCH 3/4] fix: Update tester_output dirname after change to tester --- .github/workflows/regression_test.yaml | 2 +- .github/workflows/test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/regression_test.yaml b/.github/workflows/regression_test.yaml index 0138189b..962656e1 100644 --- a/.github/workflows/regression_test.yaml +++ b/.github/workflows/regression_test.yaml @@ -50,7 +50,7 @@ jobs: GH_BRANCH: SOURCE_FAILED_COUNT - name: Save tester output to home directory - run: mv -f tester_output ${{ env.HOME }} || true + run: mv -f tester_output* ${{ env.HOME }}/tester_output || true - name: 📝 Print all test cases that failed on source branch run: ${{ env.SCRIPTS_DIR }}/print_all_failed_test_cases.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6ccd1728..20249cdf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -76,7 +76,7 @@ jobs: GH_BRANCH: IGNORE continue-on-error: true - name: Save tester output to home directory - run: mv -f tester_output ${{ env.HOME }} || true + run: mv -f tester_output* ${{ env.HOME }}/tester_output || true - name: 📝 Print all test cases that leaked on source branch run: ${{ env.SCRIPTS_DIR }}/print_leak_test_cases.sh env: From ba20b8bce4f714b1d54d06b45f202c7f1d713759 Mon Sep 17 00:00:00 2001 From: Lukas Dullinger <129603980+itislu@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:54:46 +0200 Subject: [PATCH 4/4] ci: Combine matrix jobs for easier repo rules admin --- .github/workflows/test.yaml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 20249cdf..1708a286 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -31,6 +31,14 @@ jobs: - name: 🔨 Compile with Makefile run: make CC="${{ matrix.compiler }}" + combine_compilation_test_results: + name: Combine Compilation Test Results + needs: compilation_test + runs-on: ubuntu-latest + steps: + - name: Combine compilation test results + run: echo "All compilation tests finished" + prepare_test_matrix: name: Prepare Test Matrix needs: compilation_test @@ -85,7 +93,7 @@ jobs: combine_memory_leak_test_results: name: Combine Memory Leak Test Results - needs: [memory_leak_test] + needs: memory_leak_test runs-on: ubuntu-latest steps: - name: Combine memory leak test results @@ -110,3 +118,11 @@ jobs: with: test_mode: ${{ matrix.test_mode }} test_name: ${{ matrix.test_name }} + + combine_regression_test_results: + name: Combine Regression Test Results + needs: regression_test + runs-on: ubuntu-latest + steps: + - name: Combine regression test results + run: echo "All regression tests finished"