Skip to content

Commit 26f2146

Browse files
authored
Improved Github Actions for ocl-open-140 (#384)
* Improved Github Actions for ocl-open-140 * Remove scheduled workflow from release branches, as only default branch can run on schedule * Likewise, on-demand workflow is only valid if it's on the default branch
1 parent be776e6 commit 26f2146

File tree

3 files changed

+139
-71
lines changed

3 files changed

+139
-71
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ===---
2+
# Main opencl-clang building script
3+
# ===---
4+
5+
name: Build opencl-clang
6+
inputs:
7+
ref_llvm:
8+
description: 'LLVM ref to build with'
9+
required: true
10+
ref_translator:
11+
description: 'SPIRV-LLVM-Translator ref to build with'
12+
required: true
13+
ref_opencl-clang:
14+
description: 'opencl-clang ref to build with'
15+
required: true
16+
build_type:
17+
description: 'Build type to pass to CMake'
18+
required: false
19+
default: Release
20+
21+
runs:
22+
using: 'composite'
23+
steps:
24+
25+
# Setup git credentials to make applying patches possible
26+
- run: |
27+
git config --global user.email "[email protected]"
28+
git config --global user.name "Action Bot"
29+
shell: bash
30+
31+
- name: Checkout LLVM
32+
uses: actions/checkout@v3
33+
with:
34+
repository: llvm/llvm-project
35+
path: llvm-project
36+
ref: ${{ inputs.ref_llvm }}
37+
38+
- name: Checkout SPIRV-LLVM-Translator
39+
uses: actions/checkout@v3
40+
with:
41+
repository: KhronosGroup/SPIRV-LLVM-Translator
42+
path: llvm-project/SPIRV-LLVM-Translator
43+
ref: ${{ inputs.ref_translator }}
44+
45+
- name: Checkout opencl-clang
46+
uses: actions/checkout@v3
47+
with:
48+
path: llvm-project/opencl-clang
49+
ref: ${{ inputs.ref_opencl-clang }}
50+
51+
- name: Configure
52+
shell: bash
53+
run: |
54+
mkdir build && cd build
55+
cmake ${{ github.workspace }}/llvm-project/llvm \
56+
-DLLVM_ENABLE_PROJECTS="clang" \
57+
-DLLVM_EXTERNAL_PROJECTS="llvm-spirv;opencl-clang" \
58+
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=${{ github.workspace }}/llvm-project/SPIRV-LLVM-Translator \
59+
-DLLVM_EXTERNAL_OPENCL_CLANG_SOURCE_DIR=${{ github.workspace }}/llvm-project/opencl-clang \
60+
-DCMAKE_BUILD_TYPE=${{ inputs.build_type }} \
61+
-DLLVM_TARGETS_TO_BUILD="X86" \
62+
-G "Unix Makefiles"
63+
64+
- name: Build
65+
shell: bash
66+
run: |
67+
cd build
68+
make opencl-clang -j8

.github/workflows/check-in-tree-build.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# ===---
2+
# Running on push & pull_request.
3+
# This workflow parses the destination branch
4+
# to choose correct dependencies revisions
5+
# ===---
6+
7+
name: On push & pull-request verification
8+
run-name: '${{ github.event_name }}: ${{ github.base_ref }} ${{ github.ref_name }}' # github.base_ref null for 'on: push'
9+
10+
on:
11+
push:
12+
branches:
13+
- master
14+
- ocl-open-*
15+
pull_request:
16+
branches:
17+
- master
18+
- ocl-open-*
19+
types:
20+
- opened
21+
- reopened
22+
- synchronize # commit pushed to the PR
23+
- ready_for_review # moved from draft state
24+
25+
jobs:
26+
27+
verify_default_branch:
28+
name: Verify for `master` branch
29+
# ref_name for 'on: push'
30+
# base_ref for 'on: pull_request'
31+
if: ${{ (github.event_name == 'push' && github.ref_name == 'master') || (github.event_name == 'pull_request' && github.base_ref == 'master') }}
32+
runs-on: ubuntu-22.04
33+
steps:
34+
35+
- name: Checkout opencl-clang sources for action files
36+
uses: actions/checkout@v3
37+
38+
- name: Run build-opencl-clang action
39+
uses: ./.github/actions/build-opencl-clang
40+
with:
41+
ref_llvm: main
42+
ref_translator: main
43+
ref_opencl-clang: ${{ github.ref }}
44+
45+
verify_release_branch:
46+
name: Verify for `ocl-open-*` release branch
47+
# ref_name for 'on: push'
48+
# base_ref for 'on: pull_request'
49+
if: ${{ github.ref_name != 'master' && github.base_ref != 'master' }}
50+
runs-on: ubuntu-22.04
51+
steps:
52+
53+
- name: Checkout opencl-clang sources for action files
54+
uses: actions/checkout@v3
55+
56+
# This step will fail when the branch naming scheme 'ocl-open-XXX' changes!
57+
- name: Parse LLVM version from branch name
58+
id: check-llvm-version
59+
run: |
60+
BRANCH="${{ github.base_ref }}" # on: pull_request, otherwise null
61+
BRANCH=${BRANCH:-${{ github.ref_name }}} # on: push
62+
LLVM_VERSION_LONG=$(echo $BRANCH | grep -oP '\d+') # Eg. 150 for LLVM 15
63+
LLVM_VERSION_SHORT=${LLVM_VERSION_LONG::-1} # Eg. 15 for LLVM 15
64+
echo "llvm_version=$LLVM_VERSION_SHORT" >> $GITHUB_OUTPUT
65+
66+
- name: Run build-opencl-clang action
67+
uses: ./.github/actions/build-opencl-clang
68+
with:
69+
ref_llvm: release/${{ steps.check-llvm-version.outputs.llvm_version }}.x
70+
ref_translator: llvm_release_${{ steps.check-llvm-version.outputs.llvm_version }}0
71+
ref_opencl-clang: ${{ github.ref }}

0 commit comments

Comments
 (0)