Skip to content

Improved Github Actions for ocl-open-140 #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 27, 2022
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
68 changes: 68 additions & 0 deletions .github/actions/build-opencl-clang/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# ===---
# Main opencl-clang building script
# ===---

name: Build opencl-clang
inputs:
ref_llvm:
description: 'LLVM ref to build with'
required: true
ref_translator:
description: 'SPIRV-LLVM-Translator ref to build with'
required: true
ref_opencl-clang:
description: 'opencl-clang ref to build with'
required: true
build_type:
description: 'Build type to pass to CMake'
required: false
default: Release

runs:
using: 'composite'
steps:

# Setup git credentials to make applying patches possible
- run: |
git config --global user.email "[email protected]"
git config --global user.name "Action Bot"
shell: bash

- name: Checkout LLVM
uses: actions/checkout@v3
with:
repository: llvm/llvm-project
path: llvm-project
ref: ${{ inputs.ref_llvm }}

- name: Checkout SPIRV-LLVM-Translator
uses: actions/checkout@v3
with:
repository: KhronosGroup/SPIRV-LLVM-Translator
path: llvm-project/SPIRV-LLVM-Translator
ref: ${{ inputs.ref_translator }}

- name: Checkout opencl-clang
uses: actions/checkout@v3
with:
path: llvm-project/opencl-clang
ref: ${{ inputs.ref_opencl-clang }}

- name: Configure
shell: bash
run: |
mkdir build && cd build
cmake ${{ github.workspace }}/llvm-project/llvm \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_EXTERNAL_PROJECTS="llvm-spirv;opencl-clang" \
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=${{ github.workspace }}/llvm-project/SPIRV-LLVM-Translator \
-DLLVM_EXTERNAL_OPENCL_CLANG_SOURCE_DIR=${{ github.workspace }}/llvm-project/opencl-clang \
-DCMAKE_BUILD_TYPE=${{ inputs.build_type }} \
-DLLVM_TARGETS_TO_BUILD="X86" \
-G "Unix Makefiles"

- name: Build
shell: bash
run: |
cd build
make opencl-clang -j8
71 changes: 0 additions & 71 deletions .github/workflows/check-in-tree-build.yml

This file was deleted.

71 changes: 71 additions & 0 deletions .github/workflows/on-push-verification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# ===---
# Running on push & pull_request.
# This workflow parses the destination branch
# to choose correct dependencies revisions
# ===---

name: On push & pull-request verification
run-name: '${{ github.event_name }}: ${{ github.base_ref }} ${{ github.ref_name }}' # github.base_ref null for 'on: push'

on:
push:
branches:
- master
- ocl-open-*
pull_request:
branches:
- master
- ocl-open-*
types:
- opened
- reopened
- synchronize # commit pushed to the PR
- ready_for_review # moved from draft state

jobs:

verify_default_branch:
name: Verify for `master` branch
# ref_name for 'on: push'
# base_ref for 'on: pull_request'
if: ${{ (github.event_name == 'push' && github.ref_name == 'master') || (github.event_name == 'pull_request' && github.base_ref == 'master') }}
runs-on: ubuntu-22.04
steps:

- name: Checkout opencl-clang sources for action files
uses: actions/checkout@v3

- name: Run build-opencl-clang action
uses: ./.github/actions/build-opencl-clang
with:
ref_llvm: main
ref_translator: main
ref_opencl-clang: ${{ github.ref }}

verify_release_branch:
name: Verify for `ocl-open-*` release branch
# ref_name for 'on: push'
# base_ref for 'on: pull_request'
if: ${{ github.ref_name != 'master' && github.base_ref != 'master' }}
runs-on: ubuntu-22.04
steps:

- name: Checkout opencl-clang sources for action files
uses: actions/checkout@v3

# This step will fail when the branch naming scheme 'ocl-open-XXX' changes!
- name: Parse LLVM version from branch name
id: check-llvm-version
run: |
BRANCH="${{ github.base_ref }}" # on: pull_request, otherwise null
BRANCH=${BRANCH:-${{ github.ref_name }}} # on: push
LLVM_VERSION_LONG=$(echo $BRANCH | grep -oP '\d+') # Eg. 150 for LLVM 15
LLVM_VERSION_SHORT=${LLVM_VERSION_LONG::-1} # Eg. 15 for LLVM 15
echo "llvm_version=$LLVM_VERSION_SHORT" >> $GITHUB_OUTPUT

- name: Run build-opencl-clang action
uses: ./.github/actions/build-opencl-clang
with:
ref_llvm: release/${{ steps.check-llvm-version.outputs.llvm_version }}.x
ref_translator: llvm_release_${{ steps.check-llvm-version.outputs.llvm_version }}0
ref_opencl-clang: ${{ github.ref }}