forked from authzed/spicedb-operator
-
Notifications
You must be signed in to change notification settings - Fork 4
149 lines (146 loc) · 4.4 KB
/
build-test.yaml
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
---
name: "Build & Test"
on: # yamllint disable-line rule:truthy
push:
branches:
- "main"
merge_group:
types:
- "checks_requested"
pull_request:
branches:
- "*"
env:
GO_VERSION: "~1.20"
jobs:
paths-filter:
runs-on: "ubuntu-latest"
outputs:
codechange: "${{ steps.filter.outputs.codechange }}"
graphchange: "${{ steps.graph-filter.outputs.graphchange }}"
steps:
- uses: "actions/checkout@v4"
- uses: "dorny/paths-filter@v3"
id: "filter"
with:
filters: |
codechange:
- ".github/workflows/build-test.yaml"
- "Dockerfile.openshift"
- "go.mod"
- "go.sum"
- "cmd/**"
- "pkg/**"
- "e2e/**"
- "internal/**"
- uses: "dorny/paths-filter@v3"
id: "graph-filter"
with:
filters: |
graphchange:
- "proposed-update-graph.yaml"
build:
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true'
name: "Build Binary"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "authzed/actions/setup-go@main"
with:
go-version: "${{ env.GO_VERSION }}"
- uses: "authzed/actions/go-build@main"
image-build:
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true'
name: "Build Container Image"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "authzed/actions/setup-go@main"
with:
go-version: "${{ env.GO_VERSION }}"
- uses: "authzed/actions/docker-build@main"
with:
push: false
file: "Dockerfile.openshift"
tags: "spicedb-operator:ci"
buildx: false
qemu: false
unit:
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true'
name: "Unit Tests"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
with:
submodules: true
- uses: "authzed/actions/setup-go@main"
with:
go-version: "${{ env.GO_VERSION }}"
- uses: "docker/setup-qemu-action@v3"
- uses: "docker/setup-buildx-action@v3"
- name: "Run Unit Tests"
uses: "magefile/mage-action@v3"
with:
version: "latest"
args: "test:unit"
e2e:
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true' || needs.paths-filter.outputs.graphchange == 'true'
name: "E2E Tests"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
if: |
needs.paths-filter.outputs.graphchange == 'true'
with:
submodules: true
token: "${{ secrets.AUTHZED_BOT_PAT }}"
repository: "${{ github.event.pull_request.head.repo.full_name }}"
ref: "${{ github.event.pull_request.head.ref }}"
- uses: "actions/checkout@v4"
if: |
needs.paths-filter.outputs.graphchange == 'false'
with:
submodules: true
- uses: "authzed/actions/setup-go@main"
with:
go-version: "${{ env.GO_VERSION }}"
- uses: "docker/setup-qemu-action@v3"
- uses: "docker/setup-buildx-action@v3"
- name: "Run E2E Tests"
uses: "magefile/mage-action@v3"
with:
version: "latest"
args: "test:e2e"
- name: "Check if validated update graph has changed"
if: |
needs.paths-filter.outputs.graphchange == 'true'
uses: "tj-actions/verify-changed-files@v20"
id: "verify-changed-graph"
with:
files: |
validated-update-graph.yaml
- name: "Commit validated update graph"
uses: "EndBug/add-and-commit@v9"
if: |
steps.verify-changed-graph.outputs.files_changed == 'true'
with:
committer_name: "GitHub Actions"
committer_email: "41898282+github-actions[bot]@users.noreply.github.com"
default_author: "github_actor"
message: "update validated graph after successful tests"
pathspec_error_handling: "exitImmediately"
- uses: "actions/upload-artifact@v4"
if: "always()"
# this upload step is really flaky, don't fail the job if it fails
continue-on-error: true
with:
name: "cluster-state"
path: "e2e/cluster-state"