-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1068103
Showing
77 changed files
with
8,637 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/.php-cs-fixer.cache | ||
/.prettier.cache | ||
|
||
/vendor/ | ||
/coverage/ | ||
/phpmetrics/ | ||
/tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
version: 2 | ||
updates: | ||
- package-ecosystem: 'github-actions' | ||
directory: '/' | ||
schedule: | ||
interval: 'daily' | ||
|
||
- package-ecosystem: 'composer' | ||
directory: '/' | ||
schedule: | ||
interval: 'daily' | ||
|
||
- package-ecosystem: 'docker' | ||
directory: '/' | ||
schedule: | ||
interval: 'daily' | ||
|
||
- package-ecosystem: 'npm' | ||
directory: '/tests/prettier' | ||
schedule: | ||
interval: 'daily' | ||
|
||
- package-ecosystem: 'docker' | ||
directory: '/tests/prettier' | ||
schedule: | ||
interval: 'daily' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
on: | ||
workflow_call: | ||
inputs: | ||
command: | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
phpspec: | ||
runs-on: ubuntu-latest | ||
env: | ||
COMPOSE_FILE: tests/compose.yaml | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: make phpspec | ||
- name: XPath | ||
id: xpath | ||
run: | | ||
sudo apt-get install -y libxml-xpath-perl | ||
PERCENT=$(cat coverage/phpspec/index.xml | xpath -q -e '/phpunit/project/directory[@name="/"]/totals/lines/@percent' | cut -f 2 -d "=" | tr -d \") | ||
echo "phpspec=${PERCENT}" > $GITHUB_OUTPUT | ||
- uses: KnpLabs/[email protected] | ||
with: | ||
report: coverage | ||
command: ${{ inputs.command }} | ||
values: ${{ toJson(steps.xpath.outputs) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
on: workflow_call | ||
|
||
jobs: | ||
metric: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/github-script@v7 | ||
id: script | ||
with: | ||
script: | | ||
const query = ` | ||
query($cursor: String, $owner: String!, $repo: String!) { | ||
repository(owner: $owner, name: $repo) { | ||
vulnerabilityAlerts(states: OPEN, first: 100, after: $cursor) { | ||
pageInfo { | ||
endCursor | ||
} | ||
nodes { | ||
securityVulnerability { | ||
severity | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
let cursor = null; | ||
const countBySeverity = {CRITICAL: 0, HIGH: 0, MODERATE: 0, LOW: 0}; | ||
do { | ||
const result = await github.graphql( | ||
query, | ||
{ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
cursor: cursor, | ||
} | ||
); | ||
for(const alert of result.repository.vulnerabilityAlerts.nodes) { | ||
if (!countBySeverity[alert.securityVulnerability.severity]) { | ||
countBySeverity[alert.securityVulnerability.severity] = 0; | ||
} | ||
countBySeverity[alert.securityVulnerability.severity]++; | ||
} | ||
cursor = result.repository.vulnerabilityAlerts.pageInfo.endCursor; | ||
} while(null !== cursor) | ||
return countBySeverity; | ||
- uses: actions/checkout@v4 | ||
- uses: KnpLabs/[email protected] | ||
with: | ||
report: github-security | ||
command: compile | ||
values: ${{ steps.script.outputs.result }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
on: | ||
workflow_call: | ||
inputs: | ||
command: | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
phpmetrics: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
report: ${{ steps.phpmetrics.outputs.result }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: latest | ||
tools: phpmetrics/phpmetrics | ||
- name: Compile | ||
run: | | ||
mkdir phpmetrics -p | ||
phpmetrics src --report-html=phpmetrics --report-json=phpmetrics/report.json | ||
echo "report=$(cat phpmetrics/report.json | jq . --compact-output)" > $GITHUB_OUTPUT | ||
- name: Dump | ||
id: phpmetrics | ||
uses: actions/github-script@v7 | ||
with: | ||
script: return require('./phpmetrics/report.json'); | ||
|
||
report: | ||
name: ${{ matrix.report }} | ||
runs-on: ubuntu-latest | ||
needs: phpmetrics | ||
strategy: | ||
matrix: | ||
include: | ||
- report: outdated-dependencies | ||
query: '{"composer.json": .composer.packages|map(select(.status=="outdated"))|length}' | ||
- report: class-bugs | ||
query: '. | to_entries | map({key: .key, value: .value.bugs}) | map(select(.value != null)) | from_entries' | ||
steps: | ||
- name: jq | ||
id: jq | ||
env: | ||
QUERY: ${{ matrix.query }} | ||
REPORT: ${{ needs.phpmetrics.outputs.report }} | ||
run: | | ||
echo $REPORT > /tmp/report.json | ||
echo report=$(cat /tmp/report.json | jq "$QUERY" --compact-output --raw-output) > $GITHUB_OUTPUT | ||
- uses: actions/checkout@v4 | ||
- uses: KnpLabs/[email protected] | ||
with: | ||
report: ${{ matrix.report }} | ||
command: ${{ inputs.command }} | ||
values: ${{ steps.jq.outputs.report }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
on: pull_request | ||
|
||
permissions: | ||
statuses: write | ||
|
||
jobs: | ||
autoformat: | ||
runs-on: ubuntu-latest | ||
env: | ||
COMPOSE_FILE: tests/compose.yaml | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: make autoformat | ||
run: make autoformat > /dev/null | ||
- name: git status | ||
run: | | ||
if [ -z $(git status --porcelain) ]; | ||
then | ||
echo "Looks good" | ||
else | ||
echo "Some files need to be corrected, so run 'make autoformat' to apply a correction" | ||
echo git status | ||
exit 1 | ||
fi | ||
phpmetrics: | ||
uses: ./.github/workflows/example-phpmetrics.yaml | ||
with: | ||
command: check | ||
coverage: | ||
uses: ./.github/workflows/example-coverage.yaml | ||
with: | ||
command: check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
github-security: | ||
uses: ./.github/workflows/example-github-security.yaml | ||
phpmetrics: | ||
uses: ./.github/workflows/example-phpmetrics.yaml | ||
with: | ||
command: compile | ||
coverage: | ||
uses: ./.github/workflows/example-coverage.yaml | ||
with: | ||
command: compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
on: | ||
schedule: | ||
- cron: '0 6 * * 1-5' # Mon to Fri at 8:00 (Paris GMT+2) | ||
|
||
jobs: | ||
github-security: | ||
uses: ./.github/workflows/example-github-security.yaml | ||
phpmetrics: | ||
uses: ./.github/workflows/example-phpmetrics.yaml | ||
with: | ||
command: compile | ||
coverage: | ||
uses: ./.github/workflows/example-coverage.yaml | ||
with: | ||
command: compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.php-cs-fixer.cache | ||
/.prettier.cache | ||
|
||
/phpmetrics/ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
reports: | ||
github-security: | ||
extra: | ||
Total: total | ||
colors: | ||
LOW: '#808080' | ||
MODERATE: '#FFFF00' | ||
HIGH: '#FFC100' | ||
CRITICAL: '#FF0000' | ||
storage: | ||
github-discussion: | ||
url: https://github.com/KnpLabs/K-pi/discussions/4 | ||
coverage: | ||
storage: | ||
github-discussion: | ||
url: https://github.com/KnpLabs/K-pi/discussions/1 | ||
check-reporter: | ||
github-status: | ||
states: higher-is-better | ||
unit: '%' | ||
outdated-dependencies: | ||
storage: | ||
github-discussion: | ||
url: https://github.com/KnpLabs/K-pi/discussions/2 | ||
check-reporter: | ||
github-status: | ||
states: lower-is-better | ||
unit: | ||
singular: ' dependency' | ||
plural: ' dependencies' | ||
class-bugs: | ||
storage: | ||
github-discussion: | ||
url: https://github.com/KnpLabs/K-pi/discussions/3 | ||
check-reporter: | ||
github-status: | ||
states: | ||
on-lower: success | ||
on-higher: success | ||
unit: | ||
singular: ' bug' | ||
plural: ' bugs' |
Oops, something went wrong.