-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (83 loc) · 3.79 KB
/
php_staticAnalysis.yml
File metadata and controls
92 lines (83 loc) · 3.79 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
name: PHP Static Analysis
on:
workflow_call:
secrets:
laravelEnvDecryptionKey:
required: false
inputs:
branch:
type: string
description: 'The branch to analize'
required: false
default: 'main'
path:
type: string
description: 'Path to analyze'
required: false
default: 'app/'
phpVersion:
type: string
description: 'PHP Version'
required: false
default: '8.3'
useLaravelEnvDecryptionKey:
type: boolean
description: 'Should the Laravel environment decryption key be used?'
required: false
default: false
directory:
type: string
description: 'Directory path relative to GITHUB_WORKSPACE'
required: false
default: ${{ github.workspace }}
jobs:
StaticAnalysis:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.phpVersion }}
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Determine Working Directory
id: workingDirectory
shell: bash
run: |
if [ "${{ github.workspace }}" == "${{ inputs.directory }}" ]; then
echo "Using workspace root directory"
echo "directory=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT
else
echo "Using subdirectory within workspace"
echo "directory=$GITHUB_WORKSPACE/${{ inputs.directory }}" >> $GITHUB_OUTPUT
fi
echo "Working directory: $GITHUB_WORKSPACE/${{ inputs.directory }}"
- name: Get Composer Cache Directory
id: composerCache
shell: bash
run: |
cd ${{steps.workingDirectory.outputs.directory}}
echo "cacheDirectory=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer Dependencies
uses: actions/cache@v4
with:
path: |
${{ steps.composerCache.outputs.cacheDirectory }}
${{steps.workingDirectory.outputs.directory}}/vendor
key: ${{ runner.os }}-composer-${{ hashFiles(format('{0}/composer.lock', steps.workingDirectory.outputs.directory)) }}
restore-keys: |
${{ runner.os }}-composer-${{ hashFiles(format('{0}/composer.lock', steps.workingDirectory.outputs.directory)) }}
- name: Install Dependencies
run: |
cd ${{steps.workingDirectory.outputs.directory}}
composer install --no-ansi --no-interaction --no-progress --prefer-dist --ignore-platform-reqs
- name: Decrypt Test Environment Variables
if: ${{ inputs.useLaravelEnvDecryptionKey }}
run: |
cd ${{steps.workingDirectory.outputs.directory}}
php artisan env:decrypt --env=testing --key=${{secrets.laravelEnvDecryptionKey}}
mv ${{steps.workingDirectory.outputs.directory}}/.env.testing ${{steps.workingDirectory.outputs.directory}}/.env
- name: Run PHPStan
run: |
cd ${{steps.workingDirectory.outputs.directory}}
${{steps.workingDirectory.outputs.directory}}/vendor/bin/phpstan analyse ${{ inputs.path }}