This repository was archived by the owner on Mar 1, 2023. It is now read-only.
generated from narrowspark/php-library-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
116 lines (92 loc) · 3.74 KB
/
continuous-integration-linux.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
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "Continuous Integration on Linux"
on:
push:
paths:
- "**.php"
- "composer.json"
pull_request:
paths:
- "**.php"
- "composer.json"
jobs:
LinuxIntegration:
name: "PHP ${{ matrix.php-versions }} Test on ubuntu-latest OS with ${{ matrix.dependencies }} dependencies"
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ["7.3", "7.4"]
dependencies: ["highest", "lowest"]
env:
key: "continuous-integration-linux-v1" # change key (version) to clear cache
extensions: "mbstring"
ini-values: "date.timezone=Europe/Berlin, opcache.enable_cli=1, serialize_precision=14"
tools: "composer, composer-prefetcher"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: "Setup cache environment"
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: "Cache extensions"
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
ini-values: ${{ env.ini-values }}
tools: ${{ env.tools }}
coverage: none
- name: "Configure Container"
env:
NARROWSPARK_EMAIL: ${{ secrets.NARROWSPARK_EMAIL }}
NARROWSPARK_USERNAME: ${{ secrets.NARROWSPARK_USERNAME }}
run: |
echo "::set-env name=PHPUNIT::./vendor/bin/phpunit --verbose"
echo "::set-env name=COMPOSER_UP::composer update --no-progress --no-interaction --prefer-source --ansi"
echo "::set-env name=SOURCE_NAME::${GITHUB_REF#refs/*/}"
echo "::set-env name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}"
echo "::set-env name=SOURCE_TAG::${GITHUB_REF#refs/tags/}"
EMAIL=${NARROWSPARK_EMAIL:-"[email protected]"}
NAME=${NARROWSPARK_USERNAME:-"prisis"}
git config --global user.email "${EMAIL}"
git config --global user.name "${NAME}"
- name: "Setup Problem Matchers for PHP"
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: "Check PHP Version"
run: php -v
- name: "List all php extensions with versions"
run: php -r 'foreach (get_loaded_extensions() as $extension) echo $extension . " " . phpversion($extension) . PHP_EOL;'
- name: "Setup Problem Matchers for PHPUnit"
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: "Check Composer Version"
run: composer -V
- name: "Validate composer.json and composer.lock"
run: composer validate --strict
- name: "Get Composer Cache Directory"
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: "Cache dependencies"
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: "Install highest dependencies"
if: matrix.dependencies == 'highest'
run: $COMPOSER_UP
- name: "Install lowest dependencies"
if: matrix.dependencies == 'lowest'
run: $COMPOSER_UP --prefer-lowest --prefer-stable
- name: "Run Test's"
run: $PHPUNIT