-
Notifications
You must be signed in to change notification settings - Fork 18
190 lines (186 loc) · 5.57 KB
/
registry.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Trunk registry workflow
defaults:
run:
shell: bash
working-directory: ./registry/
on:
pull_request:
branches:
- main
paths:
- '.github/workflows/registry.yml'
- 'registry/**'
# Always run on main or release branches
push:
branches:
- main
paths:
- '.github/workflows/registry.yml'
- 'registry/**'
jobs:
lint:
name: Run linters
runs-on:
- self-hosted
- dind
- large-8x8
env:
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/postgres"
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Install minimal stable with clippy and rustfmt
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
- name: install sqlx-cli
run: cargo install [email protected]
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "lint"
- name: Cargo format
run: cargo fmt --all --check
- name: Run migrations
run: cargo sqlx migrate run
- name: Migrations check
# ensure migration cache is up-to-date
run: cargo sqlx prepare --check
- name: Clippy
run: cargo clippy -- -Dwarnings
test:
name: Run tests
runs-on:
- self-hosted
- dind
- large-8x8
env:
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/postgres"
CLERK_SECRET_KEY: ""
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "trunk-registry-functional-test"
workspaces: |
registry
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
- name: install sqlx-cli
run: cargo install sqlx-cli
- name: Run migrations
run: cargo sqlx migrate run
- name: Run functional tests
run: cargo test -- --nocapture
build-push-image:
name: Build and push image
runs-on:
- self-hosted
- dind
- xlarge-16x16
outputs:
short_sha: ${{ steps.versions.outputs.SHORT_SHA }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set version strings
id: versions
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build image
run: |
set -xe
docker build -t trunk-registry .
docker tag trunk-registry trunk-registry:latest
docker tag trunk-registry trunk-registry:${{ steps.versions.outputs.SHORT_SHA }}
- name: Login to Quay
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v2
with:
registry: quay.io/coredb
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Push to Quay
if: ${{ github.ref == 'refs/heads/main' }}
shell: bash
run: |
set -xe
IFS=' ' read -ra TAG_ARRAY <<< "latest ${{ steps.versions.outputs.SHORT_SHA }}"
for tag in "${TAG_ARRAY[@]}"; do
docker tag trunk-registry:$tag quay.io/coredb/trunk-registry:$tag
docker push quay.io/coredb/trunk-registry:$tag
done
argocd-update:
name: ArgoCD update automation
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-20.04
strategy:
# fail-fast means to cancel all jobs if one fails
fail-fast: false
matrix:
include:
- repository: tembo-io/app-deploy-dev
subdirectory: dev
branch: main
- repository: tembo-io/app-deploy
subdirectory: staging
branch: staging-updates
- repository: tembo-io/app-deploy
subdirectory: prod
branch: prod-updates
needs:
- build-push-image
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Check out the repo
uses: ./.github/actions/argocd-update
with:
repository: ${{ matrix.repository }}
ssh_key: ${{ secrets.SERVICE_USER_GITHUB_SSH_KEY }}
branch: ${{ matrix.branch }}
version: ${{ needs.build-push-image.outputs.short_sha }}
subdirectory: ${{ matrix.subdirectory }}