Skip to content

Commit a520271

Browse files
committed
feat: add scopes action
This change adds support to `mergify ci scope`. It introduces a new input called `action` to define if we will process junit files or detect and upload scopes. Change-Id: I395d69f8426e859445963b83c6959a0961d65754
1 parent 590d01f commit a520271

File tree

3 files changed

+66
-11
lines changed

3 files changed

+66
-11
lines changed

.github/workflows/ci.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,29 @@ jobs:
3737
semgrep --config=auto --error
3838
yamllint .
3939
40-
test:
40+
test-scope:
41+
runs-on: ubuntu-24.04
42+
steps:
43+
- name: Checkout 🛎️
44+
uses: actions/checkout@v5.0.0
45+
46+
- name: Trying action
47+
id: scopes-detection
48+
uses: ./
49+
with:
50+
action: scopes
51+
52+
- name: Check scopes
53+
env:
54+
SCOPES: ${{ steps.scopes-detection.outputs.scopes }}
55+
EVERYTHING: ${{ fromJSON(steps.scopes-detection.outputs.scopes).everything }}
56+
EVERYTHING_BOOL: ${{ fromJSON(steps.scopes-detection.outputs.scopes).everything == 'true' }}
57+
run: |
58+
echo "SCOPES: $SCOPES"
59+
test "$EVERYTHING" == "true"
60+
test "$EVERYTHING_BOOL" == "true"
61+
62+
test-junit:
4163
timeout-minutes: 5
4264
runs-on: ubuntu-latest
4365
steps:
@@ -48,9 +70,11 @@ jobs:
4870
docker compose up -d
4971
sleep 1
5072
docker compose logs
73+
5174
- name: Run action
5275
uses: ./
5376
with:
77+
action: junit-process
5478
token: fake-valid-token
5579
report_path: zfixtures/*.xml
5680
mergify_api_url: http://localhost:1080
@@ -60,6 +84,7 @@ jobs:
6084
continue-on-error: true
6185
uses: ./
6286
with:
87+
action: junit-process
6388
token: fake-valid-token
6489
report_path: zfixtures/junit_example.xml
6590
mergify_api_url: http://localhost:1085

.mergify.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ shared:
1919
merge_method: squash
2020
CheckRuns: &CheckRuns
2121
- check-success=linters
22-
- check-success=test
22+
- check-success=test-junit
23+
- check-success=test-scopes
24+
25+
26+
scopes:
27+
source:
28+
files:
29+
# Used by .github/workflow/ci.yml to test the action
30+
everything: {}
2331

2432
queue_rules:
2533
- name: hotfix

action.yml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
name: gha-ci-issues
2-
description: Upload JUnit XML report to Mergify CI Insights
1+
name: gha-mergify-ci
2+
description: The Mergify CI integration with GitHub Actions
33
author: Mergify
44
branding:
55
icon: at-sign
66
color: blue
77
inputs:
8+
action:
9+
description: |
10+
The Mergify CI action:
11+
* junit-process: process Junit XML files with Mergify CI Insights (Upload and Quarantine)
12+
* scopes: detect and upload pull requests scopes to Mergify Merge Queue
13+
# Backward compat
14+
default: junit-process
815
token:
9-
required: true
1016
description: Mergify CI token
17+
mergify_api_url:
18+
description: URL of the Mergify API
19+
default: https://api.mergify.com
1120
job_name:
1221
description: |
1322
Override the job name, must be used in case of matrix job to avoid
1423
having the same name for all jobs
1524
report_path:
16-
required: true
1725
description: Path of the files to upload
18-
mergify_api_url:
19-
required: false
20-
description: URL of the Mergify API
21-
default: https://api.mergify.com
2226
flaky_test_detection:
23-
required: false
2427
description: Mark test execution as part of a flaky test detection process
2528
default: "false"
29+
outputs:
30+
scopes:
31+
description: stringified JSON mapping with names of all scopes matching any of changed files
32+
value: ${{ steps.scopes-detection.outputs.scopes }}
2633
runs:
2734
using: composite
2835
steps:
@@ -38,6 +45,7 @@ runs:
3845
3946
- shell: bash
4047
id: junit-process
48+
if: inputs.action == 'junit-process'
4149
env:
4250
MERGIFY_API_URL: ${{ inputs.mergify_api_url }}
4351
MERGIFY_TEST_FLAKY_DETECTION: ${{ inputs.flaky_test_detection }}
@@ -47,3 +55,17 @@ runs:
4755
run: |
4856
set -x -e
4957
mergify ci junit-process ${FILES}
58+
59+
- name: Detect scopes
60+
if: inputs.action == 'scopes'
61+
id: scopes-detection
62+
shell: bash
63+
run: mergify ci scopes --write $RUNNER_TEMP/mergify-scopes.json
64+
65+
- name: Upload scopes to Mergify API
66+
shell: bash
67+
if: inputs.token && inputs.action == 'scopes'
68+
env:
69+
MERGIFY_TOKEN: ${{ inputs.token }}
70+
MERGIFY_API_URL: ${{ inputs.mergify_api_url }}
71+
run: mergify ci scopes-send --file $RUNNER_TEMP/mergify-scopes.json

0 commit comments

Comments
 (0)