-
-
Notifications
You must be signed in to change notification settings - Fork 56
204 lines (194 loc) · 6.52 KB
/
main.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: CI/CD
on:
pull_request:
paths-ignore:
- ".vscode/**"
- "docs/**"
- "env/**"
- "**/*.md"
- ".gitpod.yml"
push:
branches:
- master
paths-ignore:
- ".vscode/**"
- "docs/**"
- "env/**"
- "**/*.md"
- ".gitpod.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true
cache: "yarn"
cache-dependency-path: "./yarn.lock"
- uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-
- run: corepack enable
- run: yarn install --immutable
- run: yarn run lint-ci
env:
NODE_ENV: production
- name: cargo-install
uses: baptiste0928/cargo-install@v3
with:
crate: typeshare-cli
version: "1.7.0"
- name: Ensure generated code is up to date
run: ./scripts/codegen.sh && git diff --exit-code
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: typos-action
uses: crate-ci/[email protected]
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
fail-fast: true
continue-on-error: true
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true
cache: "yarn"
cache-dependency-path: "./yarn.lock"
- uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-
- run: corepack enable
- run: yarn install --immutable
- run: yarn workspace ott-server run sequelize db:migrate
env:
NODE_ENV: test
- run: yarn run build
- run: yarn run test
env:
REDIS_HOST: localhost
REDIS_PORT: 6379
- name: Collect coverage reports
id: collect-coverage
run: |
echo "files=$(find . -name coverage-final.json | sed 's/\.\///g' | tr '\n' ',')" >> "$GITHUB_OUTPUT"
- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
files: ${{ steps.collect-coverage.outputs.files }}
token: ${{ secrets.CODECOV_TOKEN }}
grafana-compatibilitycheck:
runs-on: ubuntu-latest
strategy:
matrix:
package: [ott-vis-panel, ott-vis-datasource]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
cache-dependency-path: "./yarn.lock"
- run: corepack enable
- name: Install dependencies
run: yarn install --immutable
- name: Build plugin
run: yarn workspace ${{ matrix.package }} build
- name: Compatibility check
run: npx @grafana/levitate@latest is-compatible --path packages/${{ matrix.package }}/src/module.ts --target @grafana/data,@grafana/ui,@grafana/runtime
deploy-docker:
runs-on: ubuntu-latest
name: Deploy docker image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test, lint]
steps:
- uses: actions/checkout@v4
- name: Log in to Dockerhub
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "dyc3" --password-stdin
touch env/production.env
- name: Build image
run: |
docker-compose -f docker/docker-compose.yml up -d --build
docker commit opentogethertube opentogethertube
docker-compose -f docker/docker-compose.yml down
docker tag opentogethertube dyc3/opentogethertube:latest
- name: Push to Dockerhub
run: docker push dyc3/opentogethertube:latest
deploy-fly-staging-monolith:
runs-on: ubuntu-latest
name: Deploy Monolith on fly.io (staging)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test, lint]
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --config deploy/fly.staging.monolith.toml --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
deploy-fly-staging-balancer:
runs-on: ubuntu-latest
name: Deploy Balancer on fly.io (staging)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test, lint, deploy-fly-staging-monolith]
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --config deploy/fly.staging.balancer.toml --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
deploy-fly-prod-monolith:
runs-on: ubuntu-latest
name: Deploy Monolith on fly.io (prod)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test, lint]
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --config deploy/fly.prod.monolith.toml --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
deploy-fly-prod-balancer:
runs-on: ubuntu-latest
name: Deploy Balancer on fly.io (prod)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test, lint, deploy-fly-prod-monolith]
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --config deploy/fly.prod.balancer.toml --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}