-
Notifications
You must be signed in to change notification settings - Fork 5
156 lines (151 loc) · 4.86 KB
/
docker-dev.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
name: Docker Build Dev
on:
push:
branches: [ develop ]
jobs:
laravel-test-sqlite:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Installing PHP
uses: shivammathur/setup-php@master
with:
php-version: '8.2'
- name: Get Composer Cache Directory 2
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Cache PHP dependencies
uses: actions/cache@v3
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
- name: Setup env file
run: cp .env.ci .env
- name: Composer install
if: steps.vendor-cache.outputs.cache-hit != 'true'
run: composer install --no-ansi --no-interaction --no-scripts --no-suggest --prefer-dist
- name: Setup keys
run: php artisan key:generate
- name: Fix perms for dirs
run: chmod -R 777 storage bootstrap/cache
- name: Migrate database
env:
DB_CONNECTION: 'sqlite'
DB_DATABASE: 'db.sqlite'
run: touch database/db.sqlite; php artisan migrate
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: 'sqlite'
DB_DATABASE: 'db.sqlite'
run: vendor/phpunit/phpunit/phpunit
laravel-test-sql:
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:latest
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_PASSWORD }}
MYSQL_DATABASE: scw__api
MYSQL_USER: scw__api
MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }}
ports:
- 33306:3306
options: >-
--health-cmd="mariadb-admin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v3
- name: Installing PHP
uses: shivammathur/setup-php@master
with:
php-version: '8.2'
- name: Get Composer Cache Directory 2
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Cache PHP dependencies
uses: actions/cache@v3
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
- name: Setup env file
run: cp .env.ci .env
- name: Composer install
if: steps.vendor-cache.outputs.cache-hit != 'true'
run: composer install --no-ansi --no-interaction --no-scripts --no-suggest --prefer-dist
- name: Setup keys
run: php artisan key:generate
- name: Fix perms for dirs
run: chmod -R 777 storage bootstrap/cache
- name: Migrate database
env:
DB_CONNECTION: 'mysql'
DB_DATABASE: 'scw__api'
DB_PORT: 33306
#DB_HOST: 'mysql'
DB_USERNAME: 'scw__api'
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: touch database/db.sqlite; php artisan migrate
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: 'mysql'
DB_DATABASE: 'scw__api'
DB_PORT: 33306
#DB_HOST: 'mysql'
DB_USERNAME: 'scw__api'
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: vendor/phpunit/phpunit/phpunit
main:
runs-on: ubuntu-latest
needs:
- laravel-test-sqlite
- laravel-test-sql
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
tags: scwiki/api:dev
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache