Skip to content

Commit 49ff125

Browse files
authored
[ci] Run CI on PR commit on simulation of merge (#13379)
1 parent ec78472 commit 49ff125

File tree

6 files changed

+55
-3
lines changed

6 files changed

+55
-3
lines changed

.github/workflows/ci-docker-build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ on:
66
image_tag:
77
description: "Image Tag"
88
type: string
9-
required: true
9+
default: ${{ github.sha }}
10+
checkout_ref:
11+
description: "Reference of the branch or commit sha"
12+
type: string
13+
default: ${{ github.sha }}
1014
outputs:
1115
image-tag-version-cleaned:
1216
description: "Image tag after formatting"
@@ -24,6 +28,8 @@ jobs:
2428
version: ${{ steps.meta.outputs.version }}
2529
steps:
2630
- uses: actions/checkout@v6
31+
with:
32+
ref: ${{ inputs.checkout_ref }}
2733

2834
- name: Set up Docker Buildx
2935
uses: docker/setup-buildx-action@v3
@@ -61,6 +67,8 @@ jobs:
6167
version: ${{ steps.meta.outputs.version }}
6268
steps:
6369
- uses: actions/checkout@v6
70+
with:
71+
ref: ${{ inputs.checkout_ref }}
6472

6573
- name: Set up Docker Buildx
6674
uses: docker/setup-buildx-action@v3

.github/workflows/ci-license-check.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Verify licenses
22

33
on:
44
workflow_call:
5+
inputs:
6+
checkout_ref:
7+
description: "Reference of the branch or commit sha"
8+
type: string
9+
default: ${{ github.sha }}
510

611
jobs:
712
license-check:
@@ -11,6 +16,8 @@ jobs:
1116

1217
- name: OpenCTI checkout
1318
uses: actions/checkout@v6
19+
with:
20+
ref: ${{ inputs.checkout_ref }}
1421

1522
- name: Runner information
1623
continue-on-error: true

.github/workflows/ci-main.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,43 @@ name: OpenCTI CI
22
on:
33
workflow_dispatch:
44
push:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
57

6-
# Test stability 6
78
jobs:
89
wf-build-image:
910
name: Build image
1011
uses: ./.github/workflows/ci-docker-build.yml
1112
with:
12-
image_tag: ${{ github.sha }}
13+
checkout_ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
1314
secrets: inherit
1415

1516
wf-api-test:
1617
name: API test
1718
uses: ./.github/workflows/ci-test-api.yml
1819
needs: wf-build-image
20+
with:
21+
checkout_ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
1922
secrets: inherit
2023

2124
wf-frontend-test:
2225
name: Frontend test
2326
uses: ./.github/workflows/ci-test-frontend.yml
27+
with:
28+
checkout_ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
2429
secrets: inherit
2530

2631
wf-client-python-test:
2732
name: Client Python
2833
uses: ./.github/workflows/ci-test-client-python.yml
2934
needs: wf-build-image
35+
with:
36+
checkout_ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
3037
secrets: inherit
3138

3239
wf-license-check:
3340
name: License check
3441
uses: ./.github/workflows/ci-license-check.yml
42+
with:
43+
checkout_ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
3544
secrets: inherit

.github/workflows/ci-test-api.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Run OpenCTI api tests
22

33
on:
44
workflow_call:
5+
inputs:
6+
checkout_ref:
7+
description: "Reference of the branch or commit sha"
8+
type: string
9+
default: ${{ github.sha }}
510

611
jobs:
712
run-opencti-integration-test:
@@ -11,6 +16,8 @@ jobs:
1116
steps:
1217
- name: OpenCTI checkout
1318
uses: actions/checkout@v6
19+
with:
20+
ref: ${{ inputs.checkout_ref }}
1421

1522
- name: Runner information
1623
continue-on-error: true
@@ -125,6 +132,8 @@ jobs:
125132
steps:
126133
- name: OpenCTI checkout
127134
uses: actions/checkout@v6
135+
with:
136+
ref: ${{ inputs.checkout_ref }}
128137

129138
- name: Runner information
130139
continue-on-error: true
@@ -196,6 +205,8 @@ jobs:
196205
steps:
197206
- name: OpenCTI checkout
198207
uses: actions/checkout@v6
208+
with:
209+
ref: ${{ inputs.checkout_ref }}
199210

200211
- name: Runner information
201212
continue-on-error: true

.github/workflows/ci-test-client-python.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Run Client Python - PyCti tests
22

33
on:
44
workflow_call:
5+
inputs:
6+
checkout_ref:
7+
description: "Reference of the branch or commit sha"
8+
type: string
9+
default: ${{ github.sha }}
510

611
jobs:
712
client-python-test:
@@ -14,6 +19,8 @@ jobs:
1419
steps:
1520
- name: OpenCTI checkout
1621
uses: actions/checkout@v6
22+
with:
23+
ref: ${{ inputs.checkout_ref }}
1724

1825
- name: Runner information
1926
continue-on-error: true

.github/workflows/ci-test-frontend.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Run OpenCTI frontend tests
22

33
on:
44
workflow_call:
5+
inputs:
6+
checkout_ref:
7+
description: "Reference of the branch or commit sha"
8+
type: string
9+
default: ${{ github.sha }}
510

611
jobs:
712
opencti-frontend-test:
@@ -10,6 +15,8 @@ jobs:
1015
steps:
1116
- name: OpenCTI checkout
1217
uses: actions/checkout@v6
18+
with:
19+
ref: ${{ inputs.checkout_ref }}
1320

1421
- name: Runner information
1522
continue-on-error: true
@@ -49,6 +56,7 @@ jobs:
4956
uses: actions/checkout@v6
5057
with:
5158
path: frontend-e2e-test
59+
ref: ${{ inputs.checkout_ref }}
5260

5361
- name: Runner information
5462
continue-on-error: true
@@ -195,6 +203,8 @@ jobs:
195203
steps:
196204
- name: OpenCTI checkout
197205
uses: actions/checkout@v6
206+
with:
207+
ref: ${{ inputs.checkout_ref }}
198208

199209
- name: Runner information
200210
continue-on-error: true

0 commit comments

Comments
 (0)