-
Notifications
You must be signed in to change notification settings - Fork 15
167 lines (144 loc) · 5.87 KB
/
build.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
157
158
159
160
161
162
163
164
165
166
167
name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
# Prevent forks from running this to be nice
if: github.repository_owner == 'SwedbankPay'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Execute GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
- name: Version label for unstable builds
id: unstable
if: startsWith(github.ref, 'refs/tags/') != true
run: |
LABEL="-dev"
echo "Pre-release: ${LABEL}"
echo "##[set-output name=label;]${LABEL}"
- name: Composer version
id: composer-version
run: |
COMPOSER_VERSION="${{ steps.gitversion.outputs.majorMinorPatch }}${{ steps.unstable.outputs.label }}"
echo "Composer version: ${COMPOSER_VERSION}"
echo "::set-output name=version::${COMPOSER_VERSION}"
- name: Install tools
uses: shivammathur/setup-php@master
with:
php-version: '7.4'
extension: intl, mbstring, json, bcmath
coverage: xdebug
tools: composer, php-cs-fixer, phpunit:8.5.14, phpcpd, phpmd
- name: Version stamp composer.json
run: |
jq ".version=\"${{ steps.composer-version.outputs.version }}\"" composer.json > composer.version.json # Add "version" property to composer.version.json
mv composer.json composer.clean.json
mv composer.version.json composer.json # Rename composer.version.json to composer.json
- name: Create ZIP archive
id: archive
env:
SEMVER: ${{ steps.gitversion.outputs.fullSemVer }}
run: |
ARCHIVE=${GITHUB_REPOSITORY#SwedbankPay/}-${SEMVER}.zip
echo "Archive: ${ARCHIVE}"
echo "::set-output name=name::${ARCHIVE}"
zip --recurse-paths --exclude="*.zip" --exclude="vendor/*" --exclude="composer.clean.json" ${ARCHIVE} *
unzip -l ${ARCHIVE}
- name: Upload artifact
uses: actions/[email protected]
with:
name: ${{ steps.archive.outputs.name }}
path: ${{ steps.archive.outputs.name }}
- name: Validate composer.json and composer.lock
run: composer validate
- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/[email protected]
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: PHPCS check
run: ./vendor/bin/phpcs --standard=PSR2 --report=code --ignore=vendor/* --runtime-set ignore_warnings_on_exit true src/
- name: PHP Mess Detector
run: ./vendor/bin/phpmd src/ text cleancode,codesize,controversial,design,naming,unusedcode
- name: Install Chrome browser
run: |
sudo apt-get update
sudo apt-cache policy google-chrome
- name: Install chromedriver
uses: nanasess/setup-chromedriver@master
#with:
#chromedriver-version: '98.0.4758.80'
- name: Acceptance tests with codeception
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
PAYEE_ID: ${{ secrets.PAYEE_ID }}
ACCESS_TOKEN_MOBILEPAY: ${{ secrets.ACCESS_TOKEN_MOBILEPAY }}
PAYEE_ID_MOBILEPAY: ${{ secrets.PAYEE_ID_MOBILEPAY }}
VERSION: ${{ steps.composer-version.outputs.version }}
run: |
if [ "$ACCESS_TOKEN" != "" ]; then
cd ./vendor/bin/
wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.59/selenium-server-standalone-3.141.59.jar
cd ../..
export DISPLAY=:99
chromedriver --url-base=/wd/hub > /dev/null &
sudo Xvfb :0 -ac -screen 0 1024x768x24 > /dev/null 2>&1 &
xvfb-run java -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver -jar ./vendor/bin/selenium-server-standalone-3.141.59.jar &
php -S localhost:8000 -t ./tests/stand > /dev/null &
sleep 30
php ./vendor/bin/codecept build
php ./vendor/bin/codecept run acceptance
fi
- name: Unit tests
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
PAYEE_ID: ${{ secrets.PAYEE_ID }}
ACCESS_TOKEN_MOBILEPAY: ${{ secrets.ACCESS_TOKEN_MOBILEPAY }}
PAYEE_ID_MOBILEPAY: ${{ secrets.PAYEE_ID_MOBILEPAY }}
VERSION: ${{ steps.composer-version.outputs.version }}
run: |
if [ "$ACCESS_TOKEN" != "" ]; then
./vendor/bin/phpunit --configuration=./tests/phpunit.xml --bootstrap=./tests/bootstrap.php --coverage-clover=coverage.xml
fi
- name: Upload code coverage report to Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash)
- name: Create GitHub release
id: release
uses: actions/create-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ${{ steps.archive.outputs.name }}
asset_name: ${{ steps.archive.outputs.name }}
asset_content_type: application/zip