-
Notifications
You must be signed in to change notification settings - Fork 142
203 lines (180 loc) · 5.94 KB
/
test.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
name: Kitsu Test Suite
on:
push:
pull_request:
# Branches from forks have the form 'user:branch-name' so we only run
# this job on pull_request events for branches that look like fork
# branches. Without this we would end up running this job twice for non
# forked PRs, once for the push and then once for opening the PR.
branches:
- '**:**'
env:
STREAM_API_KEY: q3k9n9kqk3fb
STREAM_API_SECRET: vkw87x3p323z6ma75n8dvnse98jrr9gkauf2zfjnzbgjpmm54ssnbync4yhhzugc
CC_TEST_REPORTER_ID: 5e2172ea5a30b07e172058a3b33dfe08c6354699808e8f3010acc32b1ef41395
BUNDLE_GITHUB__HTTPS: true
LOG_LEVEL: warn
AWS_DEFAULT_REGION: us-east-1
IMAGEMAGICK_VERSION: 7.1.1-29
SENTRY_ORG: kitsu
SENTRY_PROJECT: server
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
jobs:
check_secrets:
runs-on: ubuntu-latest
outputs:
SECRETS_AVAILABLE: ${{ steps.check.outputs.SECRETS_AVAILABLE }}
steps:
- id: check
run: |
echo "SECRETS_AVAILABLE=${{ env.SECRETS_AVAILABLE == 'yes' }}" >> $GITHUB_OUTPUT
env:
SECRETS_AVAILABLE: ${{ secrets.AVAILABLE }}
test:
name: RSpec Test Suite
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
ruby:
- ruby-3.2
experimental: [false]
include:
- ruby: ruby-3.3
experimental: true
services:
minio:
image: fclairamb/minio-github-actions
options: --health-cmd "curl -s -o /dev/null -I http://127.0.0.1:9000/minio/index.html" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 9000:9000
env:
MINIO_ACCESS_KEY: miniotest
MINIO_SECRET_KEY: miniotest
postgres:
image: postgres:10-alpine
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: kitsu_test
ports:
- 5432:5432
redis:
image: redis:alpine
ports:
- 6379:6379
elasticsearch:
image: elasticsearch:2-alpine
ports:
- 9200:9200
typesense:
image: typesense/typesense:0.25.0
ports:
- 8108:8108
env:
TYPESENSE_DATA_DIR: /tmp
TYPESENSE_API_KEY: xyz
env:
AWS_ENDPOINT: http://localhost:9000
AWS_BUCKET: kitsu-ugc-test
AWS_ACCESS_KEY_ID: miniotest
AWS_SECRET_ACCESS_KEY: miniotest
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/kitsu_test
REDIS_URL: redis://localhost:6379/1
ELASTICSEARCH_URL: localhost:9200
TYPESENSUAL_API_KEY: xyz
TYPESENSUAL_NODES: http://localhost:8108/
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Dependencies
run: |
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get -yqq install libpq-dev libfuse2
- name: Install libvips
run: |
sudo apt-get -yqq install libvips libvips-dev libraqm-dev ffmpeg
- name: Set up Ruby (${{ matrix.ruby }})
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Set up Test Environment
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
run: |
aws --endpoint-url $AWS_ENDPOINT s3 mb s3://$AWS_BUCKET
bundle exec rake db:create db:schema:load
- name: Run RSpec Suite
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
run: |
bundle exec rspec
- name: Dump Schema
run: |
bundle exec rake graphql:dump_schema
- uses: actions/upload-artifact@v3
with:
name: graphql-schema-${{ matrix.ruby }}
path: schema.graphql
- name: Publish code coverage
uses: paambaati/[email protected]
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
continue-on-error: true
build:
needs: [check_secrets]
name: Build Docker Image
runs-on: ubuntu-latest
if: github.event_name == 'push' && needs.check_secrets.outputs.SECRETS_AVAILABLE == 'true'
steps:
- name: Install Sentry CLI
run: curl -sL https://sentry.io/get-cli/ | bash
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Checkout Repository
uses: actions/checkout@v3
- name: Connect to Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: Senkosan
password: ${{ secrets.SENKO_SAN_KEY }}
- name: Set version
run: |
echo "version=${GITHUB_SHA::8}" >> $GITHUB_ENV
echo "${GITHUB_SHA::8}" > .version
- name: Report Release to Sentry
run: sentry-cli releases new ${{ env.version }}
- name: Add Commits to Sentry Release
run: sentry-cli releases set-commits --auto ${{ env.version }}
- name: Build Docker Image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ghcr.io/hummingbird-me/kitsu-server:${{ env.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Finalize Sentry Release
if: success()
run: sentry-cli releases finalize ${{ env.version }}
deploy:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: [test, build]
if: success() && github.ref == 'refs/heads/the-future'
steps:
- name: Trigger Deployment
uses: octokit/[email protected]
with:
route: POST /repos/:repo/deployments
repo: ${{ github.repository }}
ref: ${{ github.sha }}
environment: staging
auto_merge: false
description: "Deploy ${{ github.sha }} to Staging"
mediaType: '{"previews": ["flash"]}'
required_contexts: "[]"
env:
GITHUB_TOKEN: ${{ secrets.SENKO_SAN_KEY }}