Skip to content

Commit 6c5a1b3

Browse files
committed
Add lint and static analysis workflows
1 parent d0d1c83 commit 6c5a1b3

3 files changed

Lines changed: 182 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "Lint"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php-version:
7+
description: "The PHP version to use when running the job"
8+
default: "8.0"
9+
required: false
10+
type: "string"
11+
12+
jobs:
13+
14+
lint:
15+
name: "Lint yaml & Composer"
16+
17+
runs-on: "ubuntu-latest"
18+
19+
strategy:
20+
matrix:
21+
php-version:
22+
- "${{ inputs.php-version }}"
23+
24+
steps:
25+
- name: "Checkout"
26+
uses: "actions/checkout@v3"
27+
28+
- name: "Lint YAML files"
29+
uses: "ibiqlik/action-yamllint@v3.1"
30+
with:
31+
config_file: ".yamllint.yaml"
32+
file_or_dir: "."
33+
strict: true
34+
35+
- name: "Set up PHP"
36+
uses: "shivammathur/setup-php@2.18.0"
37+
with:
38+
coverage: "none"
39+
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo"
40+
php-version: "${{ matrix.php-version }}"
41+
42+
- name: "Validate composer.json and composer.lock"
43+
run: "composer validate --ansi --strict"
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: "Code coverage"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php-version:
7+
description: "The PHP version to use when running the job"
8+
default: "8.0"
9+
required: false
10+
type: "string"
11+
php-extensions:
12+
description: "The php extensions to install, allowing composer to pass"
13+
default: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo"
14+
required: false
15+
type: "string"
16+
composer-root-version:
17+
description: "The version of the package being tested, in case of circular dependencies."
18+
required: false
19+
type: "string"
20+
composer-options:
21+
description: "Additional flags for the composer install command."
22+
default: "--prefer-dist"
23+
required: false
24+
type: "string"
25+
composer-dependencies:
26+
description: "Composer dependency level to install"
27+
default: "locked"
28+
required: false
29+
type: "string"
30+
31+
jobs:
32+
static-code-analysis:
33+
name: "Static Code Analysis"
34+
35+
runs-on: "ubuntu-latest"
36+
37+
strategy:
38+
matrix:
39+
php-version:
40+
- "${{ inputs.php-version }}"
41+
42+
steps:
43+
- name: "Checkout"
44+
uses: "actions/checkout@v3"
45+
46+
- name: "Install PHP"
47+
uses: "shivammathur/setup-php@v2"
48+
with:
49+
coverage: "none"
50+
php-version: "${{ matrix.php-version }}"
51+
extensions: "${{ inputs.php-extensions }}"
52+
53+
- name: "Set COMPOSER_ROOT_VERSION"
54+
run: |
55+
echo "COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}" >> $GITHUB_ENV
56+
if: "${{ inputs.composer-root-version }}"
57+
58+
- name: "Install dependencies with Composer"
59+
uses: "ramsey/composer-install@v1"
60+
with:
61+
dependency-versions: "${{ inputs.composer-dependencies }}"
62+
composer-options: "${{ inputs.composer-options }}"
63+
64+
- name: "Create cache directory for phpstan/phpstan"
65+
run: "mkdir -p .build/phpstan"
66+
67+
- name: "Run phpstan/phpstan"
68+
run: "vendor/bin/phpstan --configuration=phpstan.neon --memory-limit=-1"
69+
70+
- name: "Create cache directory for vimeo/psalm"
71+
run: "mkdir -p .build/psalm"
72+
73+
- name: "Run vimeo/psalm"
74+
run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4"

.yamllint.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
extends: "default"
2+
3+
ignore: |
4+
.build/
5+
.notes/
6+
vendor/
7+
rules:
8+
braces:
9+
max-spaces-inside-empty: 0
10+
max-spaces-inside: 1
11+
min-spaces-inside-empty: 0
12+
min-spaces-inside: 1
13+
brackets:
14+
max-spaces-inside-empty: 0
15+
max-spaces-inside: 0
16+
min-spaces-inside-empty: 0
17+
min-spaces-inside: 0
18+
colons:
19+
max-spaces-after: 1
20+
max-spaces-before: 0
21+
commas:
22+
max-spaces-after: 1
23+
max-spaces-before: 0
24+
min-spaces-after: 1
25+
comments:
26+
ignore-shebangs: true
27+
min-spaces-from-content: 1
28+
require-starting-space: true
29+
comments-indentation: "enable"
30+
document-end:
31+
present: false
32+
document-start:
33+
present: false
34+
indentation:
35+
check-multi-line-strings: false
36+
indent-sequences: true
37+
spaces: 2
38+
empty-lines:
39+
max-end: 0
40+
max-start: 0
41+
max: 1
42+
empty-values:
43+
forbid-in-block-mappings: true
44+
forbid-in-flow-mappings: true
45+
hyphens:
46+
max-spaces-after: 2
47+
key-duplicates: "enable"
48+
key-ordering: "disable"
49+
line-length: "disable"
50+
new-line-at-end-of-file: "enable"
51+
new-lines:
52+
type: "unix"
53+
octal-values:
54+
forbid-implicit-octal: true
55+
quoted-strings:
56+
quote-type: "double"
57+
trailing-spaces: "enable"
58+
truthy:
59+
allowed-values:
60+
- "false"
61+
- "true"
62+
63+
yaml-files:
64+
- "*.yaml"
65+
- "*.yml"

0 commit comments

Comments
 (0)