Skip to content

[FEAT] Seperate test workflow and add bonus part test #1

[FEAT] Seperate test workflow and add bonus part test

[FEAT] Seperate test workflow and add bonus part test #1

name: Mandatory regression Test
on:
pull_request:
jobs:
regression_test:
name: Regression Test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout source branch of pull request
uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/apt
key: ${{ runner.os }}-apt-${{ hashFiles('**/apt-get.txt') }}
restore-keys: |
${{ runner.os }}-apt-
- name: Set up build environment
run: |
sudo apt-get update
sudo apt-get install -y build-essential clang-12 valgrind
- name: Set up testing framework
run: |
git clone https://github.com/LeaYeh/42_minishell_tester.git
cp -r 42_minishell_tester $HOME
chmod +x $HOME/42_minishell_tester/tester.sh
find .github/scripts -type f -name "*.sh" -exec chmod +x {} \;
cp .github/scripts/*.sh $HOME
- name: 🌱 Test source branch of pull request
run: |
make fclean test
$HOME/42_minishell_tester/tester.sh b > $HOME/source_test_result.txt
env:
GH_BRANCH: "SOURCE_FAILED_COUNT"
- name: 📝 Print all test cases that failed on source branch
run: |
export RESULT_FILE="$HOME/source_test_result.txt"
$HOME/print_all_failed_test_cases.sh
- 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 fclean test
$HOME/42_minishell_tester/tester.sh b > $HOME/target_test_result.txt
env:
GH_BRANCH: "TARGET_FAILED_COUNT"
- name: 🆚 Compare failed count
id: comparison
run: |
echo "TARGET_FAILED_COUNT: $TARGET_FAILED_COUNT"
echo "SOURCE_FAILED_COUNT: $SOURCE_FAILED_COUNT"
if [ $SOURCE_FAILED_COUNT -gt $TARGET_FAILED_COUNT ]; then
echo "SOURCE_FAILED_COUNT is greater than TARGET_FAILED_COUNT"
exit 1
else
echo "SOURCE_FAILED_COUNT is less than or equal to TARGET_FAILED_COUNT"
exit 0
fi
env:
SOURCE_FAILED_COUNT: ${{ env.SOURCE_FAILED_COUNT }}
TARGET_FAILED_COUNT: ${{ env.TARGET_FAILED_COUNT }}
continue-on-error: true
# Can fail the job
- name: 📈 Show the regressions between SOURCE and TARGET branch
if: steps.comparison.outcome == 'failure'
run: $HOME/print_changed_test_cases.sh
# Cannot fail the job
- name: 📉 Show the improvements between SOURCE and TARGET branch
if: steps.comparison.outcome == 'success'
run: $HOME/print_changed_test_cases.sh || true