Skip to content

Commit 1c80774

Browse files
committed
github-ci: don't run ee tests for outside pull requests by default
Such pull requests may be labeled with `full-ci`. It will run tests with Tarantool EE. To avoid security problems, the label must be reset manually for every run.
1 parent f8e9c70 commit 1c80774

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

.github/workflows/testing.yml

+27-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: testing
33
on:
44
push:
55
pull_request:
6+
pull_request_target:
7+
types: [labeled]
68
workflow_dispatch:
79

810
jobs:
@@ -12,8 +14,12 @@ jobs:
1214
#
1315
# The main trick is described here:
1416
# https://github.com/Dart-Code/Dart-Code/pull/2375
15-
if: github.event_name == 'push' ||
16-
github.event.pull_request.head.repo.full_name != github.repository
17+
#
18+
# Also we want to run it always for manually triggered workflows.
19+
if: (github.event_name == 'push') ||
20+
(github.event_name == 'pull_request' &&
21+
github.event.pull_request.head.repo.full_name != github.repository) ||
22+
(github.event_name == 'workflow_dispatch')
1723

1824
runs-on: ubuntu-latest
1925

@@ -65,8 +71,18 @@ jobs:
6571
run: make bench-deps bench DURATION=1x COUNT=1
6672

6773
run-tests-ee:
68-
if: github.event_name == 'push' ||
69-
github.event.pull_request.head.repo.full_name != github.repository
74+
# The same as for run-tests-ce, but it does not run on pull requests from
75+
# forks by default. Tests will run only when the pull request is labeled
76+
# with `full-ci`. To avoid security problems, the label must be reset
77+
# manually for every run.
78+
#
79+
# We need to use `pull_request_target` because it has access to base
80+
# repository secrets unlike `pull_request`.
81+
if: (github.event_name == 'push') ||
82+
(github.event_name == 'pull_request_target' &&
83+
github.event.pull_request.head.repo.full_name != github.repository &&
84+
github.event.label.name == 'full-ci') ||
85+
(github.event_name == 'workflow_dispatch')
7086

7187
runs-on: ubuntu-latest
7288

@@ -86,6 +102,13 @@ jobs:
86102
steps:
87103
- name: Clone the connector
88104
uses: actions/checkout@v2
105+
# This is needed for pull_request_target because this event runs in the
106+
# context of the base commit of the pull request. It works fine for
107+
# `push` and `workflow_dispatch` because the default behavior is used
108+
# if `ref` and `repository` are empty.
109+
with:
110+
ref: ${{github.event.pull_request.head.ref}}
111+
repository: ${{github.event.pull_request.head.repo.full_name}}
89112

90113
- name: Setup Tarantool ${{ matrix.sdk-version }}
91114
run: |

0 commit comments

Comments
 (0)