-
Notifications
You must be signed in to change notification settings - Fork 37
191 lines (170 loc) · 5.69 KB
/
cicd.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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: CICD
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
env:
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_HOST: "localhost"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PORT: "5432"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME: "username"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD: "password"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_DATABASE: "resonate_test"
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: ${{ env.TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME }}
POSTGRES_PASSWORD: ${{ env.TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_DATABASE }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Install and run golangci-lint
uses: golangci/golangci-lint-action@v3 # nosemgrep
with:
version: v1.54
args: --verbose --timeout=3m
- name: Run go test and generate coverage report
run: |
go test -v -coverprofile=coverage.out -coverpkg=./... ./...
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3 # nosemgrep
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Build resonate
run: go build -o resonate
- name: Cache resonate binary
uses: actions/cache/save@v4
with:
path: resonate
key: resonate-${{ github.sha }}
test:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Restore resonate binary
uses: actions/cache/restore@v4
with:
path: resonate
key: resonate-${{ github.sha }}
fail-on-cache-miss: true
- name: Run resonate server
run: |
chmod +x resonate
./resonate serve --aio-store-sqlite-path :memory: &
- name: Checkout test harness
uses: actions/checkout@v4
with:
repository: resonatehq/durable-promise-test-harness
- name: Build test harness
run: |
go build -o harness
- name: Run linearizability check
run: |
chmod +x harness
./harness verify -r 1000 -c 10
- uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: test-harness-results
path: test/results/
scan:
name: semgrep
needs: [build]
runs-on: ubuntu-20.04
env:
SEMGREP_RULES: "auto semgrep.yml"
container:
image: returntocorp/semgrep
if: (github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v4
- run: semgrep ci
deploy-linux-binary:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [build, test, scan]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21
- name: Install cross-compiler for linux/arm64
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build for both amd64 and arm64
run: |
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o ./bin/linux-x86_64/ ./...
CC=aarch64-linux-gnu-gcc GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -o ./bin/linux-aarch64/ ./...
chmod +x ./bin/linux-x86_64/resonate
chmod +x ./bin/linux-aarch64/resonate
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}"
- id: upload-linux-x86_64
uses: google-github-actions/upload-cloud-storage@v2
with:
path: ./bin/linux-x86_64/resonate
destination: resonate-release/linux-x86_64
- id: upload-linux-aarch64
uses: google-github-actions/upload-cloud-storage@v2
with:
path: ./bin/linux-aarch64/resonate
destination: resonate-release/linux-aarch64
deploy-darwin-binary:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [build, test, scan]
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21
- name: Build for both amd64 and arm64
run: |
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -o ./bin/darwin-x86_64/ ./...
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -o ./bin/darwin-aarch64/ ./...
chmod +x ./bin/darwin-x86_64/resonate
chmod +x ./bin/darwin-aarch64/resonate
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}"
- id: upload-darwin-x86_64
uses: google-github-actions/upload-cloud-storage@v2
with:
path: ./bin/darwin-x86_64/resonate
destination: resonate-release/darwin-x86_64
- id: upload-darwin-aarch64
uses: google-github-actions/upload-cloud-storage@v2
with:
path: ./bin/darwin-aarch64/resonate
destination: resonate-release/darwin-aarch64