-
Notifications
You must be signed in to change notification settings - Fork 2
108 lines (99 loc) · 4.12 KB
/
pull-request-checks.yml
File metadata and controls
108 lines (99 loc) · 4.12 KB
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
name: Pull Request Checks
on:
pull_request:
branches:
- main
- 1.x
jobs:
composer:
name: Build AZQS with composer
runs-on: ubuntu-latest
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- uses: actions/checkout@v4
- name: Find the pull request source branch name
run: |
echo "AZ_SOURCE_REF=${GITHUB_HEAD_REF}" >> ${GITHUB_ENV}
echo "AZ_TARGET_REF=${GITHUB_BASE_REF}" >> ${GITHUB_ENV}
- name: Set default branches for scaffolding and profile repos if ref is 1.*
if: startsWith(github.base_ref, '1.') || startsWith(github.ref_name, '1.')
id: test-1-x
run: |
echo "DEFAULT_SCAFFOLD_BRANCH=2.x" >> ${GITHUB_ENV}
echo "DEFAULT_PROFILE_BRANCH=2.x" >> ${GITHUB_ENV}
- name: Fallback to main branch
if: steps.test-1-x.outcome == 'skipped'
run: |
echo "DEFAULT_SCAFFOLD_BRANCH=main" >> ${GITHUB_ENV}
echo "DEFAULT_PROFILE_BRANCH=main" >> ${GITHUB_ENV}
- name: Set variables
run: |
if [ $(git ls-remote --heads https://github.com/az-digital/az_quickstart.git $AZ_SOURCE_REF | wc -l) = 1 ]; then
echo "QUICKSTART_BRANCH_NAME=${AZ_SOURCE_REF}" >> ${GITHUB_ENV}
elif [ $(git ls-remote --heads https://github.com/az-digital/az_quickstart.git $AZ_TARGET_REF | wc -l) = 1 ]; then
echo "QUICKSTART_BRANCH_NAME=${AZ_TARGET_REF}" >> ${GITHUB_ENV}
else
echo "QUICKSTART_BRANCH_NAME=${DEFAULT_PROFILE_BRANCH}" >> ${GITHUB_ENV}
fi
if [ $(git ls-remote --heads https://github.com/az-digital/az-quickstart-scaffolding.git $AZ_SOURCE_REF | wc -l) = 1 ]; then
echo "SCAFFOLDING_BRANCH_NAME=${AZ_SOURCE_REF}" >> ${GITHUB_ENV}
elif [ $(git ls-remote --heads https://github.com/az-digital/az-quickstart-scaffolding.git $AZ_TARGET_REF | wc -l) = 1 ]; then
echo "SCAFFOLDING_BRANCH_NAME=${AZ_TARGET_REF}" >> ${GITHUB_ENV}
else
echo "SCAFFOLDING_BRANCH_NAME=${DEFAULT_SCAFFOLD_BRANCH}" >> ${GITHUB_ENV}
fi
- name: Checkout scaffolding repo
uses: actions/checkout@v4
with:
repository: az-digital/az-quickstart-scaffolding
ref: ${{ env.SCAFFOLDING_BRANCH_NAME }}
path: az-quickstart-scaffolding
- name: Build Arizona Quickstart
run: |
cd $GITHUB_WORKSPACE/az-quickstart-scaffolding
composer config repositories.az_quickstart vcs https://github.com/az-digital/az_quickstart.git
composer config use-github-api false
./quickstart_branch.sh --branch ${QUICKSTART_BRANCH_NAME}
if [[ ${AZ_SOURCE_REF} =~ ^[0-9]\.[0-9x] ]]; then
DEV_PACKAGE_VERSION="${AZ_SOURCE_REF}-dev"
else
DEV_PACKAGE_VERSION="dev-${AZ_SOURCE_REF}"
fi
composer require --no-update --dev az-digital/az-quickstart-dev:${DEV_PACKAGE_VERSION}
composer install -o
- name: Save build artifact
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/az-quickstart-scaffolding
key: azqs-build-${{ github.sha }}
phpcs:
name: PHP_CodeSniffer
needs: composer
runs-on: ubuntu-latest
steps:
- name: Restore build artifact cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/az-quickstart-scaffolding
key: azqs-build-${{ github.sha }}
- name: Run PHPCS
run: |
cd $GITHUB_WORKSPACE/az-quickstart-scaffolding
composer phpcs
phpstan:
name: PHPStan
needs: composer
runs-on: ubuntu-latest
steps:
- name: Restore build artifact cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/az-quickstart-scaffolding
key: azqs-build-${{ github.sha }}
- name: Run PHPStan
run: |
cd $GITHUB_WORKSPACE/az-quickstart-scaffolding
./vendor/bin/phpstan analyse --configuration web/profiles/custom/az_quickstart/phpstan.neon web/profiles/custom/az_quickstart