blob: 6ddffa59c8f6e46f33e0b02d7a8702286583269d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
name: PR check
on:
pull_request_target:
branches:
- 'main'
paths-ignore:
- 'ydb/docs/**'
types:
- 'opened'
- 'synchronize'
- 'reopened'
- 'labeled'
jobs:
check-running-allowed:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.check-ownership-membership.outputs.result }}
steps:
- name: Check if running tests is allowed
id: check-ownership-membership
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
script: |
// This is used primarily in forks. Repository owner
// should be allowed to run anything.
const userLogin = context.payload.pull_request.user.login;
if (context.payload.repository.owner.login == userLogin) {
return true;
}
const response = await github.rest.orgs.checkMembershipForUser({
org: context.payload.organization.login,
username: userLogin,
});
// How to interpret membership status code:
// https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#check-organization-membership-for-a-user
if (response.status == '204') {
return true;
}
const labels = context.payload.pull_request.labels;
const okToTestLabel = labels.find(
label => label.name == 'ok-to-test'
);
return okToTestLabel !== undefined;
- name: comment-if-waiting-on-ok
if: steps.check-ownership-membership.outputs.result == 'false' &&
github.event.action == 'opened'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Hi! Thank you for contributing!\nThe tests on this PR will run after a maintainer adds an `ok-to-test` label to this PR manually. Thank you for your patience!'
});
build_and_test:
needs:
- check-running-allowed
if: needs.check-running-allowed.outputs.result == 'true'
uses: ./.github/workflows/build_and_test_ondemand.yml
with:
test_label_regexp: '(SMALL|MEDIUM)'
secrets: inherit
|