-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (131 loc) · 4.62 KB
/
ci.yml
File metadata and controls
155 lines (131 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: CI
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize, reopened, labeled]
permissions:
contents: write
pull-requests: write
jobs:
vet_build_test:
name: Vet & Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run go vet
run: go vet ./...
- name: Build all packages
run: go build ./...
run-test:
name: Run Test (${{ matrix.name }})
runs-on: ${{ matrix.os }}
needs: [vet_build_test]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
name: Linux
- os: windows-latest
name: Windows
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install Microsoft core fonts
if: runner.os == 'Linux'
run: |
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
sudo apt-get update -q
sudo apt-get install -y ttf-mscorefonts-installer
- name: Run examples
shell: bash
run: go test -v -count=1 ./...
go-generate:
name: Run all Generates & Commit
runs-on: ubuntu-latest
needs: [vet_build_test]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Download SYCL Linux
run: |
wget -q -O /tmp/sycl_linux.tar.gz https://github.com/intel/llvm/releases/download/v6.3.0/sycl_linux.tar.gz
mkdir -p /tmp/sycl_linux
tar -xzf /tmp/sycl_linux.tar.gz -C /tmp/sycl_linux
- name: Add SYCL bin to PATH
run: |
ls -hl /tmp/sycl_linux
echo "/tmp/sycl_linux/bin" >> $GITHUB_PATH
- name: Install ocloc
run: |
wget -qO- https://repositories.intel.com/gpu/intel-graphics.key \
| sudo gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg
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" \
| sudo tee /etc/apt/sources.list.d/intel-gpu.list
sudo apt-get update -q
sudo apt-get install -y intel-ocloc libigdfcl2 libigc2
- name: Run go generate
run: |
go generate ./...
gofmt -w .
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11
args: --fix
env:
CGO_ENABLED: "0"
- name: Check for changes
id: diff
run: |
if [ -n "$(git diff --name-only)" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit and push to PR branch
if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request'
id: push_to_pr
continue-on-error: true
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore: run go generate"
git push
- name: Comment on PR if push failed
if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request' && steps.push_to_pr.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
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.'
})
- name: Create Pull Request
if: steps.diff.outputs.changed == 'true' && github.event_name == 'push'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: run go generate"
title: "chore: run go generate"
body: |
Automated PR created by CI.
`go generate .` detected generated file differences and applied updates.
branch: auto/go-generate
delete-branch: true