Skip to content

Commit a246cdb

Browse files
authored
[SYCL] Add windows testing triggered by a comment (#7704)
Trying to trigger windows build and testing if a specific comment is posted. The are complications: 1. For some reason, a workflow triggered by a comment is not displayed in the PR status(where all github actions are displayed). So, trying to update it manually. 2. The github hash provided for the default branch rather than for the PR branch.
1 parent 463ab33 commit a246cdb

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

.github/workflows/sycl_windows_build_and_test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
type: string
88
required: false
99
default: "default"
10+
build_ref:
11+
type: string
12+
required: false
1013

1114
jobs:
1215
build:
@@ -26,6 +29,7 @@ jobs:
2629
- uses: actions/checkout@v3
2730
with:
2831
path: src
32+
ref: ${{ inputs.build_ref || github.ref }}
2933
fetch-depth: 1
3034
- name: Register cleanup after job is finished
3135
uses: ./src/devops/actions/cleanup
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Test windows on the comment
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
windows_test_preparation:
9+
runs-on: ubuntu-latest
10+
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/start Windows testing' }}
11+
steps:
12+
- name: react_to_comment
13+
uses: actions/github-script@v4
14+
with:
15+
script: |
16+
const {owner, repo} = context.issue;
17+
github.reactions.createForIssueComment({
18+
owner,
19+
repo,
20+
comment_id: context.payload.comment.id,
21+
content: "rocket",
22+
});
23+
- name: get_pr_sha
24+
id: sha
25+
uses: actions/github-script@v4
26+
with:
27+
result-encoding: string
28+
script: |
29+
const { owner, repo, number } = context.issue;
30+
const pr = await github.pulls.get({
31+
owner,
32+
repo,
33+
pull_number: number,
34+
});
35+
return pr.data.head.sha
36+
- name: update_pr_status_pending
37+
run: |
38+
gh api --method POST -H "Accept: application/vnd.github+json" /repos/$OWNER/$REPO/statuses/$SHA -f state='pending' -f target_url='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' -f description='The build started2!' -f context='Windows pre-commit'
39+
echo "REF == = = = = = = ${{ steps.sha.outputs.result }}"
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
OWNER: ${{ github.repository_owner }}
43+
REPO: ${{ github.event.repository.name }}
44+
SHA: ${{ steps.sha.outputs.result }}
45+
outputs:
46+
PR_SHA: ${{ steps.sha.outputs.result }}
47+
48+
49+
windows_default:
50+
name: Windows
51+
needs: [windows_test_preparation]
52+
if: github.repository == 'intel/llvm'
53+
uses: ./.github/workflows/sycl_windows_build_and_test.yml
54+
with:
55+
build_ref: ${{ needs.windows_test_preparation.outputs.PR_SHA }}
56+
57+
windows_test_completion:
58+
runs-on: ubuntu-latest
59+
needs: [windows_default]
60+
steps:
61+
- name: update_pr_status_success
62+
if: always() && success()
63+
run: |
64+
gh api --method POST -H "Accept: application/vnd.github+json" /repos/$OWNER/$REPO/statuses/$SHA -f state='success' -f target_url='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' -f description='The build started2!' -f context='Windows pre-commit'
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
OWNER: ${{ github.repository_owner }}
68+
REPO: ${{ github.event.repository.name }}
69+
SHA: ${{ steps.sha.outputs.result }}
70+
- name: update_pr_status_failure
71+
if: failure()
72+
run: |
73+
gh api --method POST -H "Accept: application/vnd.github+json" /repos/$OWNER/$REPO/statuses/$SHA -f state='failure' -f target_url='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' -f description='The build started2!' -f context='Windows pre-commit'
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
OWNER: ${{ github.repository_owner }}
77+
REPO: ${{ github.event.repository.name }}
78+
SHA: ${{ steps.sha.outputs.result }}
79+
80+
# windows_default:
81+
# runs-on: ubuntu-latest
82+
# needs: [windows_test_preparation]
83+
# steps:
84+
# - name: print_ref
85+
# run: |
86+
# echo "REF == = = = = = = ${{github.ref}}"
87+
# echo "REF == = = = = = = ${{ needs.windows_test_preparation.outputs.PR_SHA }}"

0 commit comments

Comments
 (0)