-
Notifications
You must be signed in to change notification settings - Fork 14
176 lines (161 loc) · 5.34 KB
/
test-build.yml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Test Build
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
run-unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
- name: Run Unit Tests
id: unit
run: |
make prepare
make test
make fmtcheck
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
- name: Build
id: build
run: |
make prepare
make build-cross-platform
run-integration-tests:
runs-on: ubuntu-latest
steps:
# To wait for the existing nightly-build run to complete to avoid running same integration tests at the same time
- name: Turnstyle
uses: softprops/turnstyle@v1
with:
same-branch-only: false
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
- name: Run Integration Tests
id: integration
run: |
make prepare
make clean-test
make integration-test
env:
LW_ACCOUNT: ${{ secrets.LW_ACCOUNT }}.lacework.net
LW_API_KEY: ${{ secrets.LW_API_KEY }}
LW_API_SECRET: ${{ secrets.LW_API_SECRET }}
LW_SUBACCOUNT: ${{ secrets.LW_SUBACCOUNT }}
OCI_CREDENTIALS: ${{ secrets.OCI_CREDENTIALS }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
DOCKER_CREDENTIALS: ${{ secrets.DOCKER_CREDENTIALS }}
GHCR_CREDENTIALS: ${{ secrets.GHCR_CREDENTIALS }}
CLOUDWATCH_EVENT_BUS_ARN: ${{ secrets.CLOUDWATCH_EVENT_BUS_ARN }}
AWS_ECR_IAM: ${{ secrets.AWS_ECR_IAM }}
AWS_CREDS: ${{ secrets.AWS_CREDS }}
AWS_S3: ${{ secrets.AWS_S3 }}
S3_BUCKET_ARN: ${{ secrets.S3_BUCKET_ARN }}
LW_PUB_SUB_SUBSCRIPTION: ${{ secrets.LW_PUB_SUB_SUBSCRIPTION }}
slack-notify:
name: Slack Notify if Failed Tests
needs: [run-unit-tests, build, run-integration-tests]
runs-on: ubuntu-latest
if: always()
steps:
- name: Notify Slack on Failure
if: ${{ contains(needs.*.result, 'failure') }}
uses: slackapi/[email protected]
with:
payload: |
{
"attachments": [
{
"color": "#E92020",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "@oncall-growth-eng! There has been a failure that needs your attention. :rotating_light:\n*GitHub Workflow Failure <${{ github.server_url }}/${{ github.repository }}>*\n\n*Workflow Run*\n <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
}
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.TF_SLACK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
trigger-release:
if: github.ref == 'refs/heads/main'
needs: [run-unit-tests, build, run-integration-tests]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN }}
- name: Trigger release
shell: bash
run: |
echo "$GPG_SECRET_KEY" | base64 --decode | gpg --import --no-tty --batch --yes
scripts/release.sh trigger
env:
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GITHUB_TOKEN: ${{ secrets.TOKEN }}
slack-notify-trigger-release:
name: Slack Notify if Failed Tests
needs: trigger-release
runs-on: ubuntu-latest
if: always()
steps:
- name: Notify Slack on Failure
if: ${{ contains(needs.*.result, 'failure') }}
uses: slackapi/[email protected]
with:
payload: |
{
"attachments": [
{
"color": "#E92020",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "@oncall-growth-eng! There has been a failure that needs your attention. :rotating_light:\n*GitHub Workflow Failure <${{ github.server_url }}/${{ github.repository }}>*\n\n*Workflow Run*\n <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
}
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.TF_SLACK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK