|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + types: [opened, synchronize, reopened, labeled] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + vet_build_test: |
| 15 | + name: Vet & Build |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + os: [ubuntu-latest, windows-latest] |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - uses: actions/setup-go@v5 |
| 25 | + with: |
| 26 | + go-version-file: go.mod |
| 27 | + |
| 28 | + - name: Find and remove all .cpp files |
| 29 | + run: | |
| 30 | + find . -name "*.cpp" -type f -delete |
| 31 | + shell: bash |
| 32 | + |
| 33 | + - name: Run go vet |
| 34 | + run: go vet ./... |
| 35 | + |
| 36 | + - name: Build all packages |
| 37 | + run: go build ./... |
| 38 | + |
| 39 | + - name: Build cmd/gen |
| 40 | + run: go build ./cmd/gen |
| 41 | + |
| 42 | + |
| 43 | + run-test: |
| 44 | + name: Run Test (${{ matrix.name }}) |
| 45 | + runs-on: ${{ matrix.os }} |
| 46 | + needs: [vet_build_test] |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + include: |
| 51 | + - os: ubuntu-latest |
| 52 | + name: Linux |
| 53 | + cmake_extra_args: -DCMAKE_INSTALL_PREFIX=/usr/local |
| 54 | + install_cmd: >- |
| 55 | + sudo cmake --install level-zero-build && |
| 56 | + sudo cp level-zero-build/lib/libze_null.so /usr/local/lib/ && |
| 57 | + sudo ldconfig |
| 58 | + - os: windows-latest |
| 59 | + name: Windows |
| 60 | + cmake_extra_args: "" |
| 61 | + install_cmd: >- |
| 62 | + for dll in $(find level-zero-build -name "*.dll"); |
| 63 | + do cp "$dll" /c/Windows/System32/; |
| 64 | + done |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - uses: actions/setup-go@v5 |
| 69 | + with: |
| 70 | + go-version-file: go.mod |
| 71 | + |
| 72 | + - name: Download Intel Level Zero Source Code |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + # The apt runtime package (libze1) does NOT ship libze_null, which is |
| 76 | + # required for ZE_ENABLE_NULL_DRIVER=1. Build from source instead so the |
| 77 | + # loader and the null driver are both present |
| 78 | + RELEASE=$(curl -sf https://api.github.com/repos/oneapi-src/level-zero/releases/latest \ |
| 79 | + | jq -r '.tag_name') |
| 80 | + git clone https://github.com/oneapi-src/level-zero.git --depth=1 \ |
| 81 | + --branch "$RELEASE" level-zero-src |
| 82 | +
|
| 83 | + - name: Build & Install Intel Level Zero |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + cmake -S level-zero-src -B level-zero-build \ |
| 87 | + -DCMAKE_BUILD_TYPE=Release \ |
| 88 | + -DBUILD_TESTING=OFF \ |
| 89 | + ${{ matrix.cmake_extra_args }} |
| 90 | + cmake --build level-zero-build --config Release --parallel $(nproc) |
| 91 | + ${{ matrix.install_cmd }} |
| 92 | +
|
| 93 | + - name: Run examples |
| 94 | + shell: bash |
| 95 | + env: |
| 96 | + # Activate the Level Zero null driver (ze_null) so the loader |
| 97 | + # can enumerate a fake device on runners without real Intel GPU hardware. |
| 98 | + ZE_ENABLE_NULL_DRIVER: "1" |
| 99 | + run: go test -v -count=1 ./... |
| 100 | + |
| 101 | + go-generate: |
| 102 | + name: Run all Generates & Commit |
| 103 | + runs-on: ubuntu-latest |
| 104 | + needs: [vet_build_test] |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + with: |
| 108 | + ref: ${{ github.head_ref || github.ref_name }} |
| 109 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + |
| 111 | + - uses: actions/setup-go@v5 |
| 112 | + with: |
| 113 | + go-version-file: go.mod |
| 114 | + |
| 115 | + - name: Download SYCL Linux |
| 116 | + run: | |
| 117 | + wget -q -O /tmp/sycl_linux.tar.gz https://github.com/intel/llvm/releases/download/v6.3.0/sycl_linux.tar.gz |
| 118 | + mkdir -p /tmp/sycl_linux |
| 119 | + tar -xzf /tmp/sycl_linux.tar.gz -C /tmp/sycl_linux |
| 120 | +
|
| 121 | + - name: Add SYCL bin to PATH |
| 122 | + run: | |
| 123 | + ls -hl /tmp/sycl_linux |
| 124 | + echo "/tmp/sycl_linux/bin" >> $GITHUB_PATH |
| 125 | +
|
| 126 | + - name: Install ocloc |
| 127 | + run: | |
| 128 | + wget -qO- https://repositories.intel.com/gpu/intel-graphics.key \ |
| 129 | + | sudo gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg |
| 130 | + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu $(. /etc/os-release && echo $VERSION_CODENAME) unified" \ |
| 131 | + | sudo tee /etc/apt/sources.list.d/intel-gpu.list |
| 132 | + sudo apt-get update -q |
| 133 | + sudo apt-get install -y intel-ocloc libigdfcl2 libigc2 |
| 134 | +
|
| 135 | + - name: Run go generate |
| 136 | + run: | |
| 137 | + go generate ./... |
| 138 | + gofmt -w . |
| 139 | +
|
| 140 | + - name: Run golangci-lint |
| 141 | + uses: golangci/golangci-lint-action@v9 |
| 142 | + with: |
| 143 | + version: v2.11 |
| 144 | + args: --fix |
| 145 | + env: |
| 146 | + CGO_ENABLED: "0" |
| 147 | + |
| 148 | + - name: Check for changes |
| 149 | + id: diff |
| 150 | + run: | |
| 151 | + if [ -n "$(git diff --name-only)" ]; then |
| 152 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 153 | + fi |
| 154 | +
|
| 155 | + - name: Commit and push to PR branch |
| 156 | + if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request' |
| 157 | + id: push_to_pr |
| 158 | + continue-on-error: true |
| 159 | + run: | |
| 160 | + git config user.name "github-actions[bot]" |
| 161 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 162 | + git add -A |
| 163 | + git commit -m "chore: run go generate" |
| 164 | + git push |
| 165 | +
|
| 166 | + - name: Comment on PR if push failed |
| 167 | + if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request' && steps.push_to_pr.outcome == 'failure' |
| 168 | + uses: actions/github-script@v7 |
| 169 | + with: |
| 170 | + script: | |
| 171 | + github.rest.issues.createComment({ |
| 172 | + issue_number: context.issue.number, |
| 173 | + owner: context.repo.owner, |
| 174 | + repo: context.repo.repo, |
| 175 | + body: '`go generate` produced file changes but could not be pushed automatically (likely a fork PR). Please run `go generate ./... && gofmt -w .` locally and push the changes.' |
| 176 | + }) |
| 177 | +
|
| 178 | + - name: Create Pull Request |
| 179 | + if: steps.diff.outputs.changed == 'true' && github.event_name == 'push' |
| 180 | + uses: peter-evans/create-pull-request@v7 |
| 181 | + with: |
| 182 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 183 | + commit-message: "chore: run go generate" |
| 184 | + title: "chore: run go generate" |
| 185 | + body: | |
| 186 | + Automated PR created by CI. |
| 187 | +
|
| 188 | + `go generate .` detected generated file differences and applied updates. |
| 189 | + branch: auto/go-generate |
| 190 | + delete-branch: true |
| 191 | + |
0 commit comments