-
Notifications
You must be signed in to change notification settings - Fork 3
153 lines (141 loc) · 3.96 KB
/
ci.yaml
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
on: [push, pull_request]
name: CI
jobs:
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: apcu
- name: PHP-CS-Fixer
uses: OskarStark/[email protected]
with:
args: --diff --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection
phpstan:
name: PHPStan Static Analysis
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: apcu
- name: Composer
run: composer install
- name: phpstan
run: |
./vendor/bin/phpstan analyse --level 6 src
phpunit:
runs-on: ubuntu-22.04
name: Unit tests
services:
db:
image: demostf/db
env:
POSTGRES_PASSWORD: test
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: apcu
- name: Composer
run: composer install
- name: PHPUnit Tests
env:
DB_PORT: 5432
DB_TYPE: pgsql
DB_HOST: localhost
DB_USERNAME: postgres
DB_PASSWORD: test
DB_DATABASE: postgres
run: |
php ./vendor/bin/phpunit test
api:
runs-on: ubuntu-22.04
name: Integration tests
services:
db:
image: demostf/db
env:
POSTGRES_PASSWORD: test
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
api:
image: demostf/api
env:
BASE_HOST: localhost
DEMO_ROOT: /tmp
DEMO_HOST: localhost
DB_TYPE: pgsql
DB_HOST: db
DB_PORT: 5432
DB_DATABASE: postgres
DB_USERNAME: postgres
DB_PASSWORD: test
APP_ROOT: https://localhost
EDIT_SECRET: edit
volumes:
- src:/app
nginx:
image: demostf/api-nginx-test
ports:
- 80:80
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: apcu
- name: Composer
run: composer install
- name: copy code
run: |
docker run -v src:/data --name helper busybox true
docker cp src helper:/data/
docker cp vendor helper:/data/
docker rm helper
- env:
DB_URL: postgres://postgres:test@db:5432/postgres
BASE_URL: http://nginx
EDIT_KEY: edit
uses: docker://demostf/api-test
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build
docker:
runs-on: ubuntu-latest
needs: [build, api, phpunit]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#docker
- name: Push image
if: github.ref == 'refs/heads/master'
run: |
skopeo copy --dest-creds="${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" "docker-archive:$(nix build .#docker --print-out-paths)" "docker://demostf/api"