-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (144 loc) · 5.28 KB
/
laravel.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
name: Laravel
on:
push:
pull_request:
schedule:
- cron: "0 8 * * 6" # 8AM Saturdays
workflow_dispatch:
jobs:
laravel-tests:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
php: ["8.0"]
experimental: [false]
services:
mariadb:
image: mariadb:10.3
env:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes
MARIADB_DATABASE: laravel
MARIADB_USER: ci
MARIADB_PASSWORD: ci
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: ${{ matrix.php }}
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Read .nvmrc
run: echo NVMRC=`cat .nvmrc` >> $GITHUB_ENV
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.ci', '.env');"
- name: Create Database
run: touch database/database.tests.sqlite
- name: Install Dependencies
run: composer install --no-ansi --no-interaction --no-progress
- name: Generate key
run: php artisan key:generate --no-interaction
- name: Install Dependencies
run: composer deploy-dev
- name: Execute tests via PHPUnit (SQLite)
run: vendor/bin/phpunit --configuration phpunit.xml
- name: Execute tests via PHPUnit (MariaDB) and publish coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
XDEBUG_MODE: coverage
with:
coverageCommand: vendor/bin/phpunit --configuration phpunit.mysql.xml --coverage-clover build/logs/clover.xml
- name: Display logs after a failure
if: ${{ failure() }}
run: cat storage/logs/laravel.log
docker:
runs-on: ubuntu-latest
needs: laravel-tests
env:
IMAGE_NAME: nfarrington/vatsim-url-shortener
steps:
- name: Configure IMAGE_VERSION
run: |
shopt -s extglob
IMAGE_VERSION=${GITHUB_REF}
IMAGE_VERSION=${IMAGE_VERSION##refs/?(heads/|tags/)}
IMAGE_VERSION=${IMAGE_VERSION//\//-}
[[ $IMAGE_VERSION == v[[:digit:]]* ]] && IMAGE_VERSION=${IMAGE_VERSION#v}
echo "IMAGE_VERSION=$IMAGE_VERSION" >> $GITHUB_ENV
- name: Configure IMAGE_TAG
run: echo "IMAGE_TAG=$IMAGE_NAME:$IMAGE_VERSION" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push nginx
id: docker_build_nginx
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.IMAGE_TAG }}-nginx
build-args: |
APP_COMMIT=${{ github.sha }}
APP_VERSION=${{ env.IMAGE_VERSION }}
target: nginx
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Nginx image digest
run: echo ${{ steps.docker_build_nginx.outputs.digest }}
- name: Build and push php-fpm
id: docker_build_php_fpm
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.IMAGE_TAG }}-php-fpm
build-args: |
APP_COMMIT=${{ github.sha }}
APP_VERSION=${{ env.IMAGE_VERSION }}
target: php-fpm
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: php-fpm image digest
run: echo ${{ steps.docker_build_php_fpm.outputs.digest }}
# Temp fix (from https://github.com/docker/build-push-action/blob/1bc1040caef9e604eb543693ba89b5bf4fc80935/docs/advanced/cache.md)
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache