-
Notifications
You must be signed in to change notification settings - Fork 2
185 lines (145 loc) · 4.33 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
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
name: CI
on:
- push
- workflow_dispatch
jobs:
scrapers:
runs-on: ubuntu-latest
defaults:
run:
working-directory: scrapers
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/checkout@v2
- name: Cache python packages
uses: actions/cache@v2
env:
cache-name: cache-python-packages
with:
path: ${{ env.HOME }}/.cache/pypoetry
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-
- name: Install poetry
run: pip install poetry
- name: Install dependencies
run: poetry install
- name: Lint with flake8
run: make lint
- name: Check types with mypy
run: make types
- name: Test with pytest
run: make tests
- name: Convert coverage report to XML
run: make coverage
- name: Upload coverage report to codecov.io
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./scrapers/coverage.xml
flags: scrapers
app:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
services:
mariadb:
image: mariadb:10.5.5
ports:
- '3306:3306'
env:
MYSQL_DATABASE: tests
MYSQL_USER: laravel
MYSQL_PASSWORD: laravel
MYSQL_ROOT_PASSWORD: laravel
options: >-
--health-cmd="mariadb-admin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
env:
APP_ENV: testing
# Use this key for testing purposes only
APP_KEY: base64:aZ+X6o+vmxSZD8RtLYTpQ5NlQ7SXOgmz5CYjG9faFdU=
DB_USERNAME: laravel
DB_PASSWORD: laravel
DB_HOST: '127.0.0.1'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: pcov
- uses: actions/checkout@v2
- name: Cache php packages
uses: actions/cache@v2
env:
cache-name: cache-php-packages
with:
path: ./vendor
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-
- name: Install PHP dependencies
run: composer install --no-interaction
- name: Install Node.js dependencies
run: npm ci
- name: Build frontend assets
run: npm run prod
- name: Check code style with PHP CS Fixer
run: composer cs
- name: Test with pest
run: composer test-with-coverage
- name: Upload coverage report to codecov.io
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./app/coverage.xml
flags: app
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm ci
- name: Check formatting with Prettier
run: npm run prettier
deploy:
needs: [app, scrapers, frontend]
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
concurrency: deployment
defaults:
run:
working-directory: ansible
steps:
- uses: actions/checkout@v2
- run: |
mkdir ~/.ssh
echo "${{ secrets.EPVPROD_PUBLIC}}" >> ~/.ssh/known_hosts
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Cache Ansible installation
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-ansible
- name: Install Ansible
run: pip3 install ansible
- name: Install Ansible collection
run: ansible-galaxy collection install community.general
- name: Create Ansible Vault password file
run: echo "${{ secrets.ANSIBLE_VAULT_PASSWORD }}" > ansible-vault.pass
- name: Run Ansible playbook
run: ansible-playbook site.yml -i ./hosts --vault-password-file ansible-vault.pass
- name: Delete secret files
run: rm ansible-vault.pass && rm ~/.ssh/id_rsa