Skip to content

Commit a6f30c6

Browse files
committed
update
1 parent 477cb24 commit a6f30c6

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

.github/actions/list-pr/action.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: 'List Pull Requests'
2+
description: 'list and put output pull requests'
3+
inputs:
4+
owner:
5+
description: 'The repository owner'
6+
required: true
7+
repository:
8+
description: 'The repository name'
9+
required: true
10+
token:
11+
description: 'The GitHub token used to create an authenticated client'
12+
default: ${{ github.token }}
13+
required: false
14+
labels:
15+
description: 'The labels on pull requests'
16+
required: false
17+
default: ''
18+
hours:
19+
description: 'Pull requests created within this many hours will be listed'
20+
required: false
21+
default: ''
22+
outputs:
23+
result:
24+
description: 'Pull requests to be listed'
25+
value: ${{ steps.list-pr.outputs.result }}
26+
runs:
27+
using: "composite"
28+
steps:
29+
# See https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests
30+
- name: List PRs
31+
uses: actions/github-script@v7
32+
id: list-pr
33+
with:
34+
token: ${{ inputs.token }}
35+
result-encoding: string
36+
script: |
37+
const resp = await github.rest.pulls.list({
38+
owner: '${{ inputs.owner }}',
39+
repo: '${{ inputs.repository }}',
40+
state: 'open',
41+
sort: 'created',
42+
per_page: 100
43+
}).catch(
44+
e => {
45+
core.setFailed(e.message)
46+
}
47+
);
48+
49+
const pr_numbers = resp.data.map(pr => pr.number);
50+
core.info(`prs: ${pr_numbers.join(",")}`);
51+
52+
const prs = resp.data.map(pr => {
53+
return {
54+
number: pr.number,
55+
title: pr.title,
56+
body: pr.body,
57+
state: pr.state,
58+
draft: pr.draft,
59+
created_at: pr.created_at,
60+
updated_at: pr.updated_at,
61+
closed_at: pr.closed_at,
62+
merged_at: pr.merged_at,
63+
html_url: pr.html_url,
64+
base: pr.base.ref,
65+
head: pr.head.ref,
66+
labels: pr.labels.map(label => label.name)
67+
};
68+
});

.github/workflows/per-pr.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: 'Per PR'
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'main'
7+
paths:
8+
- '.github/workflows/per-pr.yml'
9+
- '!**/*.md'
10+
schedule:
11+
- cron: '0 12 * * *'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
list-pr:
19+
name: List PyTorch pull requests
20+
runs-on: ubuntu-latest
21+
outputs:
22+
prs: ${{ steps.list-pr.outputs.prs }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
# List PRs created in the past 24 hours
28+
- name: List PyTorch PRs
29+
id: list-pr
30+
uses: ./.github/actions/list-pr
31+
with:
32+
token: ${{ secrets.COSDT_BOT_TOKEN }}
33+
owner: pytorch
34+
repository: pytorch
35+
hours: 24
36+
37+
dispatch-pr:
38+
name: 'Dispatch PR events for #${{ matrix.pr.number }}'
39+
runs-on: ubuntu-latest
40+
needs:
41+
- list-pr
42+
strategy:
43+
matrix:
44+
pr: ${{ fromJson(needs.list-pr.outputs.prs) }}
45+
steps:
46+
- name: Print pull request info
47+
run: |
48+
echo ${{ matrix.pr }}
49+
50+
- name: Dispatch PR events to be out-of-tree test infra
51+
uses: peter-evans/repository-dispatch@v3
52+
with:
53+
token: ${{ secrets.COSDT_BOT_TOKEN }}
54+
repository: cosdt/pytorch-integration-tests
55+
event-type: pytorch-pr-event
56+
client-payload: |-
57+
{
58+
"pull_request": {
59+
number: ${{ matrix.pr.number }}
60+
}
61+
}

0 commit comments

Comments
 (0)