forked from eclipxe13/CfdiUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.appveyor.yml
133 lines (124 loc) · 5.94 KB
/
.appveyor.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
version: "{branch}-{build}"
build: false
platform: x64
clone_folder: c:\projects\project
clone_depth: 1
cache:
- C:\ProgramData\chocolatey\bin -> .appveyor.yml
- C:\ProgramData\chocolatey\lib -> .appveyor.yml
- C:\tools\php -> .appveyor.yml
- C:\tools\composer -> .appveyor.yml
- '%LOCALAPPDATA%\Composer\files -> .appveyor.yml'
## Build matrix for lowest and highest possible targets
environment:
matrix:
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
init:
- SET PATH=c:\tools\php;C:\tools\composer;C:\OpenSSL-v111-Win64\bin;%PATH%
- SET COMPOSER_NO_INTERACTION=1
- SET ANSICON="121x90 (121x90)"
- SET saxonb-path=C:\ProgramData\chocolatey\bin\SaxonHE\bin\Transform.exe
- SET PHP_CS_FIXER_FUTURE_MODE=1
- SET PHP_CS_FIXER_IGNORE_ENV=1
## Check for openssl, install php using version environment, install
install:
# downgrade chocolatey to 0.10.13, otherwise versions query are not working
# see https://github.com/chocolatey/choco/issues/1843
- choco install chocolatey --yes --version 0.10.13 --allow-downgrade --no-progress --force
# check chocolatey sources and version
- choco source list
# check openssl exists and run from PATH
- openssl version
# php is not cached because this script change versions
- ps: |
Write-Host "PHP build version: $Env:php"
# Get current version of php (if any)
[string]$current_version = ""
if (Test-Path c:\tools\php\php.exe) {
[string]$current_version = php -r "printf('%s.%s.%s', PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION);"
Write-Host "PHP current version: $current_version"
} else {
Write-Host "PHP current version: (none)"
}
# Get latest available version for php environment variable
[string]$php_install_version = (( `
choco search php --exact --all-versions --limit-output `
| Select-String -Pattern "php|$Env:php" -SimpleMatch `
| Sort-Object { [version]($_ -Split '\|' | Select-Object -Last 1) } -Descending `
| Select-Object -First 1 `
) -Replace '[php|]', '')
Write-Host "PHP available version: $php_install_version"
if ($php_install_version -eq "") {
Write-Host "Unable to find a chocolatey php package version for PHP $env:php"
choco search php --exact --all-versions --limit-output | Select-String -Pattern "php|$Env:php" -SimpleMatch
Exit 1
}
# Test if require installation (not installed or upgrade available)
if (! ($current_version -eq $php_install_version)) {
# uninstall if previous version exists
if (! ($current_version -eq "")) {
choco uninstall php --yes --force --ignore-package-exit-codes --ignore-autouninstaller-failure --no-progress
}
# install php on C:\tools\php
appveyor-retry choco install --ignore-checksums --params='""/InstallDir:C:\tools\php""' `
php --version $php_install_version --yes --no-progress
}
# setup c:\tools\php\php.ini
if (Test-Path c:\tools\php\php.ini-production) {
Copy-Item -Path c:\tools\php\php.ini-production -Destination c:\tools\php\php.ini
[string]$php_ext_prefix=$(if ($Env:php -lt "7.2") {"php_"} else {""})
Add-Content c:\tools\php\php.ini "`
`n; PHP Custom config `
date.timezone=UTC `
extension_dir=ext `
memory_limit=1G `
extension=${php_ext_prefix}openssl `
extension=${php_ext_prefix}mbstring `
extension=${php_ext_prefix}fileinfo `
extension=${php_ext_prefix}curl `
extension=${php_ext_prefix}xsl `
extension=${php_ext_prefix}soap `
"
}
# show contents of extension directory
if ((Test-Path c:\tools\php\ext)) {
Get-ChildItem -Path c:\tools\php\ext
}
# show php information
- php -i
# composer
- ps: |
if (! (Test-Path c:\tools\composer\composer.phar)) {
New-Item -ItemType Directory -Force -Path c:\tools\composer
appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar -Filename C:\tools\composer\composer.phar
Set-Content -Path 'C:\tools\composer\composer.bat' -Value ('@php C:\tools\composer\composer.phar %*')
} else {
appveyor-retry composer self-update --stable --no-progress --no-interaction --ansi
}
composer --version
# saxonb
- ps: |
if (! (Test-Path ${Env:saxonb-path})) {
appveyor-retry choco install --ignore-checksums --yes saxonhe --no-progress
}
# install project dependences and list available tools
- cd c:\projects\project
- appveyor-retry composer install --prefer-dist --no-progress --no-interaction --ansi
- dir vendor\bin
# sat-xml resources as a dependency
- ps: |
appveyor-retry appveyor DownloadFile https://github.com/phpcfdi/resources-sat-xml/archive/master.zip -Filename c:\projects\project\build\sat-xml.zip
Expand-Archive -LiteralPath c:\projects\project\build\sat-xml.zip -DestinationPath c:\projects\project\build\ -Force
Move-Item -Path c:\projects\project\build\resources-sat-xml-master\resources -Destination c:\projects\project\build\resources
## Run the actual test
test_script:
- cd c:\projects\project
- vendor\bin\phpcs.bat -sp src tests
- vendor\bin\php-cs-fixer.bat fix --dry-run --verbose
- if "%php%"=="7.0" vendor\bin\phpunit.bat --verbose
- if not "%php%"=="7.0" vendor\bin\phpunit.bat --testdox --verbose
- if "%php%"=="7.3" vendor\bin\phpstan.bat analyse --no-progress --level max src/ tests/