Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/actions/list-pr/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: 'List Pull Requests'
description: 'list and put output pull requests'
inputs:
owner:
description: 'The repository owner'
required: true
repository:
description: 'The repository name'
required: true
token:
description: 'The GitHub token used to create an authenticated client'
default: ${{ github.token }}
required: false
labels:
description: 'The labels on pull requests'
required: false
default: ''
hours:
description: 'Pull requests created within this many hours will be listed'
required: false
default: '24'
outputs:
prs:
description: 'Pull requests to be listed'
value: ${{ steps.list-pr.outputs.result }}
runs:
using: "composite"
steps:
# See https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests
- name: List PRs
uses: actions/github-script@v7
id: list-pr
with:
github-token: ${{ inputs.token }}
result-encoding: string
script: |
const timeRange = parseInt("24") * 60 * 60 * 1000;
const sinceTime = new Date(Date.now() - timeRange).toISOString();
const input_labels = "";
const labels = input_labels
? input_labels.split(/[,\n]/).map(label => label.trim())
: [];

const iterator = await github.paginate.iterator(github.rest.pulls.list, {
owner: "pytorch",
repo: "pytorch",
state: "open",
sort: "created",
direction: "desc",
per_page: 100,
});

const prs = [];
for await (const resp of iterator) {
const filtered_prs = resp.data.filter(pr => {
const hasLabel = labels.length === 0
|| labels.every(label => pr.labels.some(prLabel => prLabel.name === label));

const createdAt = new Date(pr.created_at);
const isWithinTimeRange = createdAt >= new Date(sinceTime);

return hasLabel && isWithinTimeRange;
});

prs.push(...filtered_prs);
}

if (prs.length > 0) {
const pr_urls = prs.map(pr => pr.html_url);
core.info(`prs: ${pr_urls.join("\n")}`);
}

const result = prs.map(pr => ({
pull_request: {
number: pr.number,
title: pr.title,
state: pr.state,
draft: pr.draft,
created_at: pr.created_at,
updated_at: pr.updated_at,
closed_at: pr.closed_at,
merged_at: pr.merged_at,
html_url: pr.html_url,
base: pr.base.ref,
head: pr.head.ref,
labels: pr.labels.map(label => label.name),
}
}));

return JSON.stringify(result);
6 changes: 5 additions & 1 deletion .github/workflows/_ascend_npu_build_torch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
required: true
type: string
description: 'The docker image which will be used to build'
pr-number:
required: false
type: number
description: 'The number of pull request'
ref:
required: false
type: string
Expand All @@ -30,7 +34,7 @@ defaults:

jobs:
build:
name: build torch
name: build torch for ${{ inputs.pr-number && format('#{0}', inputs.pr-numer) || inputs.ref }}
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.image }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ascend_npu_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
- '.github/workflows/_ascend_npu_build_torch_npu.yml'
- '.github/workflows/_ascend_npu_ut.yml'
- '.github/workflows/_ascend_npu_benchmark.yml'
- '.github/actions/**'
- '.ci/**'
- 'ascend_npu/**'
- 'src/**'
Expand All @@ -24,7 +23,6 @@ on:
- '.github/workflows/_ascend_npu_build_torch_npu.yml'
- '.github/workflows/_ascend_npu_ut.yml'
- '.github/workflows/_ascend_npu_benchmark.yml'
- '.github/actions/**'
- '.ci/**'
- 'ascend_npu/**'
- 'src/**'
Expand Down Expand Up @@ -71,10 +69,10 @@ on:
default: '/dev/davinci5'
description: 'The device selected to run on'

# Only cancel the previous runs when triggered by a pull_request event or a repository_dispatch event
# Only cancel the previous runs when triggered by a pull_request event
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'repository_dispatch' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
prepare:
Expand All @@ -98,6 +96,7 @@ jobs:
id: list-ref
if: ${{ github.event_name == 'repository_dispatch' }}
run: |
echo "pr_number=${{ github.event.client_payload.pull_request.number }}" >> $GITHUB_OUTPUT
echo "ref=refs/pull/${{ github.event.client_payload.pull_request.number }}/merge" >> $GITHUB_OUTPUT

build-torch:
Expand All @@ -110,6 +109,7 @@ jobs:
runner: ${{ needs.prepare.outputs.runner }}
image: ${{ needs.prepare.outputs.image }}
ref: ${{ needs.prepare.outputs.ref }}
pr-number: ${{ needs.prepare.outputs.pr-number }}

build:
name: Build torch_npu
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/dispatch-event.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Dispatch PyTorch events'

on:
schedule:
- cron: '0 12 * * *'

workflow_dispatch:
inputs:
labels:
required: false
type: string
default: ''
description: 'The labels on pull requests'
hours:
required: false
type: number
default: 24
description: 'Pull requests created within this many hours will be listed'

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

jobs:
list-pr:
name: List PyTorch pull requests
runs-on: ubuntu-latest
outputs:
prs: ${{ steps.list-pr.outputs.prs }}
steps:
- name: Checkout
uses: actions/checkout@v4

# List PRs created in the past 24 hours
- name: List PyTorch PRs
id: list-pr
uses: ./.github/actions/list-pr
with:
token: ${{ secrets.COSDT_BOT_TOKEN }}
owner: pytorch
repository: pytorch
labels: ${{ github.event.inputs.labels || '' }}
hours: ${{ github.event.inputs.hours || '24' }}

dispatch-pr:
name: 'Dispatch PR event - #${{ matrix.data.pull_request.number }}'
runs-on: ubuntu-latest
needs:
- list-pr
strategy:
fail-fast: false
max-parallel: 1
matrix:
data: ${{ fromJson(needs.list-pr.outputs.prs) }}
steps:
- name: Dispatch PR events to be out-of-tree test infra
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.COSDT_BOT_TOKEN }}
repository: cosdt/pytorch-integration-tests
event-type: pytorch-pr-event
client-payload: ${{ toJson(matrix.data) }}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Handle events from PyTorch
name: 'Redispatch PyTorch events'

on:
repository_dispatch:
types: [pytorch-pr-event]

jobs:
redispatch-pr-event:
name: Redispatch PyTorch event
name: Redispatch PyTorch events
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
Loading