-
Notifications
You must be signed in to change notification settings - Fork 49
132 lines (111 loc) · 3.11 KB
/
ci.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
name: CI
on:
push:
branches: [master]
pull_request:
jobs:
check-commits:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v2
with:
# Fetch all history
fetch-depth: 0
- name: Check commit messages
run: |
scripts/check-commits.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Shellcheck
run: |
shellcheck install/*.sh scripts/*.sh
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12]
steps:
- uses: actions/checkout@v2
- name: Set up Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: |
yarn install --frozen-lockfile
- name: Lint
run: |
yarn lint
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12]
postgres: [12]
redis: [6]
services:
postgres:
image: postgres:${{ matrix.postgres }}
env:
POSTGRES_PASSWORD: password
ports:
- 5432:5432
redis:
image: redis:${{ matrix.redis }}
ports:
- 6379:6379
env:
RCTF_DATABASE_URL: postgres://postgres:password@localhost/rctf
RCTF_REDIS_URL: redis://@localhost:6379/0
RCTF_TOKEN_KEY: 32_byte_long_base64_encoded_value_for_token
steps:
- uses: actions/checkout@v2
- name: Set up Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: |
yarn install --frozen-lockfile
- name: Create DB
run: |
psql postgres://postgres:password@localhost -c 'CREATE DATABASE rctf;'
- name: Load configuration
run: |
cp test/conf-test.yaml conf.d
- name: Run migrations
run: |
yarn migrate
- name: Add data to DB
run: |
psql "$RCTF_DATABASE_URL" -c $'INSERT INTO challenges (id, data) VALUES (\'id\', \'{"flag": "flag{good_flag}", "name": "name", "files": [], "author": "author", "points": {"max": 500, "min": 100}, "category": "category", "description": "description", "tiebreakEligible": true}\')'
- name: Build
run: |
yarn build
- name: Run tests
run: |
yarn test:report
- name: Upload coverage reports
uses: codecov/codecov-action@v1
docker-build:
runs-on: ubuntu-latest
# TODO: handle tagging releases correctly
if: github.ref == 'refs/heads/master'
needs:
- shellcheck
- lint
- test
steps:
- uses: actions/checkout@v2
- name: Build & push
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASS }}
repository: redpwn/rctf
# TODO: handle tagging releases correctly
tags: master,${{ github.sha }}
# TODO: add cache_froms once we have full releases