44 pull_request :
55 types : [opened, reopened]
66jobs :
7+ determine_run_parameters :
8+ runs-on : ubuntu-24.04
9+ outputs :
10+ mutant_mode : ${{ steps.set_params.outputs.mutant_mode }}
11+ mutant_since_target : ${{ steps.set_params.outputs.mutant_since_target }}
12+ num_groups : ${{ steps.set_params.outputs.num_groups }}
13+ steps :
14+ - name : Determine Mutation Run Parameters
15+ id : set_params
16+ shell : bash
17+ run : |
18+ echo "--- Debug: Determining mutation run parameters for pricing ---"
19+ echo "Event name: ${{ github.event_name }}"
20+ echo "Ref name: ${{ github.ref_name }}"
21+ echo "Base ref (for PR): ${{ github.event.pull_request.base.ref }}"
22+ echo "PR title: ${{ github.event.pull_request.title }}"
23+ COMMIT_MESSAGES_LOG=$(echo "${{ join(github.event.commits.*.message, ' // ') }}" | head -c 500)
24+ echo "Commit messages in push (first 500 chars): ${COMMIT_MESSAGES_LOG}..."
25+ CONTAINS_MUTATE_FULL_IN_PUSH=$([[ "${{ contains(join(github.event.commits.*.message, ' '), '[mutate-full]') }}" == "true" ]] && echo "true" || echo "false")
26+ echo "Contains '[mutate-full]' in push commit messages: $CONTAINS_MUTATE_FULL_IN_PUSH"
27+ CONTAINS_MUTATE_FULL_IN_PR_TITLE=$([[ "${{ contains(github.event.pull_request.title, '[mutate-full]') }}" == "true" ]] && echo "true" || echo "false")
28+ echo "Contains '[mutate-full]' in PR title: $CONTAINS_MUTATE_FULL_IN_PR_TITLE"
29+ CONTAINS_MUTATE_FULL_IN_PR_BODY=$([[ "${{ contains(github.event.pull_request.body, '[mutate-full]') }}" == "true" ]] && echo "true" || echo "false")
30+ echo "Contains '[mutate-full]' in PR body: $CONTAINS_MUTATE_FULL_IN_PR_BODY"
31+ echo "---------------------------------------------"
32+
33+ FINAL_MUTANT_MODE="full"
34+ FINAL_NUM_GROUPS=32
35+ FINAL_SINCE_TARGET=""
36+
37+ IS_MUTATE_FULL_TRIGGERED="false"
38+ if [[ "${{ github.event_name }}" == "pull_request" && \
39+ ( "$CONTAINS_MUTATE_FULL_IN_PR_TITLE" == "true" || "$CONTAINS_MUTATE_FULL_IN_PR_BODY" == "true" ) ]]; then
40+ echo "Logic path: [mutate-full] in PR title/body."
41+ IS_MUTATE_FULL_TRIGGERED="true"
42+ elif [[ "${{ github.event_name }}" == "push" && "$CONTAINS_MUTATE_FULL_IN_PUSH" == "true" ]]; then
43+ echo "Logic path: [mutate-full] in push commit message(s)."
44+ IS_MUTATE_FULL_TRIGGERED="true"
45+ fi
46+
47+ if [[ "$IS_MUTATE_FULL_TRIGGERED" == "true" ]]; then
48+ echo "Action: Mode set to 'full' (NUM_GROUPS=32) due to [mutate-full] trigger."
49+ FINAL_MUTANT_MODE="full"
50+ FINAL_NUM_GROUPS=32
51+ else
52+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
53+ echo "Logic path: Pull request event (no [mutate-full] trigger)."
54+ echo "Action: Mode set to 'incremental' (NUM_GROUPS=4) for PR."
55+ FINAL_MUTANT_MODE="incremental"
56+ FINAL_NUM_GROUPS=4
57+ FINAL_SINCE_TARGET="origin/${{ github.event.pull_request.base.ref }}"
58+ echo "Incremental target: $FINAL_SINCE_TARGET"
59+ elif [[ "${{ github.event_name }}" == "push" ]]; then
60+ if [[ "${{ github.ref_name }}" == "master" || "${{ github.ref_name }}" == "main" ]]; then
61+ echo "Logic path: Push event to main branch (no [mutate-full] trigger)."
62+ echo "Action: Mode set to 'full' (NUM_GROUPS=32) for main branch."
63+ FINAL_MUTANT_MODE="full"
64+ FINAL_NUM_GROUPS=32
65+ else
66+ echo "Logic path: Push event to non-main branch ('${{ github.ref_name }}') (no [mutate-full] trigger)."
67+ echo "Action: Mode set to 'incremental' (NUM_GROUPS=4) for branch push."
68+ FINAL_MUTANT_MODE="incremental"
69+ FINAL_NUM_GROUPS=4
70+ FINAL_SINCE_TARGET="origin/master"
71+ echo "Incremental target: $FINAL_SINCE_TARGET"
72+ fi
73+ fi
74+ fi
75+
76+ echo "mutant_mode=${FINAL_MUTANT_MODE}" >> $GITHUB_OUTPUT
77+ echo "mutant_since_target=${FINAL_SINCE_TARGET}" >> $GITHUB_OUTPUT
78+ echo "num_groups=${FINAL_NUM_GROUPS}" >> $GITHUB_OUTPUT
79+
80+ echo "--- Final Parameters for pricing ---"
81+ echo "Mutant Mode: ${FINAL_MUTANT_MODE}"
82+ echo "Mutant Since Target: ${FINAL_SINCE_TARGET}"
83+ echo "Num Groups: ${FINAL_NUM_GROUPS}"
84+ echo "------------------------"
85+
786 test :
887 runs-on : ubuntu-24.04
988 strategy :
27106 {
28107 attachments: [{
29108 color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
30- text: `${process.env.AS_WORKFLOW}/${{ github.job }} ${{ job.status }} in ${process.env.AS_TOOK}\n${process.env.AS_COMMIT} in ${process.env.AS_REF}`,
109+ text: `${process.env.AS_WORKFLOW}/${{ github.job }} ${{ job.status }} in ${process.env.AS_TOOK}\n${process.env.AS_COMMIT} in ${process.env.AS_REF} for pricing `,
31110 }]
32111 }
33112 env :
@@ -37,12 +116,15 @@ jobs:
37116
38117 prepare_mutation_subjects_pricing :
39118 runs-on : ubuntu-24.04
119+ needs : determine_run_parameters
40120 outputs :
41121 subject_groups : ${{ steps.split_subjects.outputs.subject_groups }}
42122 env :
43123 WORKING_DIRECTORY : ecommerce/pricing
44124 steps :
45125 - uses : actions/checkout@v3
126+ with :
127+ fetch-depth : 0
46128 - uses : ruby/setup-ruby@v1
47129 with :
48130 ruby-version : ruby-3.3.7
@@ -51,8 +133,11 @@ jobs:
51133 - name : List and split subjects for pricing
52134 id : split_subjects
53135 working-directory : ${{ env.WORKING_DIRECTORY }}
136+ env :
137+ NUM_GROUPS_FROM_CI : ${{ needs.determine_run_parameters.outputs.num_groups }}
54138 run : |
55- SUBJECT_LIST_OUTPUT=$(RAILS_ENV=test bundle exec mutant environment subject list)
139+ echo "--- Preparing subjects for pricing ---"
140+ SUBJECT_LIST_OUTPUT=$(bundle exec mutant environment subject list)
56141
57142 mapfile -t subjects_array < <( \
58143 echo "$SUBJECT_LIST_OUTPUT" | \
69154 fi
70155
71156 total_subjects=${#subjects_array[@]}
72- NUM_GROUPS=32 # Define the number of parallel jobs
157+ NUM_GROUPS=${NUM_GROUPS_FROM_CI:-4}
158+ echo "Total subjects found: $total_subjects"
159+ echo "Number of parallel groups to create: $NUM_GROUPS"
73160 groups_json_array_content=""
74161
75162 for (( i=0; i<NUM_GROUPS; i++ )); do
@@ -90,9 +177,10 @@ jobs:
90177 done
91178 echo "Generated subject_groups for pricing: [$groups_json_array_content]"
92179 echo "subject_groups=[$groups_json_array_content]" >> $GITHUB_OUTPUT
180+ echo "-----------------------------------"
93181
94182 mutate :
95- needs : prepare_mutation_subjects_pricing
183+ needs : [determine_run_parameters, prepare_mutation_subjects_pricing]
96184 if : ${{ needs.prepare_mutation_subjects_pricing.outputs.subject_groups != '[]' && needs.prepare_mutation_subjects_pricing.outputs.subject_groups != '' }}
97185 runs-on : ubuntu-24.04
98186 strategy :
@@ -101,14 +189,19 @@ jobs:
101189 subject_group : ${{ fromJson(needs.prepare_mutation_subjects_pricing.outputs.subject_groups) }}
102190 env :
103191 WORKING_DIRECTORY : ecommerce/pricing
192+ MUTANT_MODE : ${{ needs.determine_run_parameters.outputs.mutant_mode }}
193+ MUTANT_SINCE_TARGET : ${{ needs.determine_run_parameters.outputs.mutant_since_target }}
104194 steps :
105195 - uses : actions/checkout@v3
196+ with :
197+ fetch-depth : 0
106198 - uses : ruby/setup-ruby@v1
107199 with :
108200 ruby-version : ruby-3.3.7
109201 bundler-cache : true
110202 working-directory : ${{ env.WORKING_DIRECTORY }}
111- - run : make mutate
203+ - name : Run mutation tests (parallel group for pricing)
204+ run : make mutate
112205 working-directory : ${{ env.WORKING_DIRECTORY }}
113206 env :
114207 CI_MUTATE_SUBJECTS : ${{ matrix.subject_group }}
@@ -141,4 +234,4 @@ jobs:
141234 }]
142235 }
143236 env :
144- SLACK_WEBHOOK_URL : ${{ secrets.CI_WEBHOOK }}
237+ SLACK_WEBHOOK_URL : ${{ secrets.CI_WEBHOOK }}
0 commit comments