Skip to content

Commit

Permalink
Merge branch 'develop' into pre-opportunity
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy authored Nov 13, 2024
2 parents 39be31d + 7e283c2 commit 5928eaf
Show file tree
Hide file tree
Showing 2,181 changed files with 82,374 additions and 19,503 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ trim_trailing_whitespace = false
indent_style = tab
trim_trailing_whitespace = true
indent_size = 4
[*.yml]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
10 changes: 5 additions & 5 deletions .github/workflows/cache-clean-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ jobs:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge
REPO="${{ github.repository }}"
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
cacheKeysForPR=$(gh actions-cache list -R "$REPO" -B "$BRANCH" | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
gh actions-cache delete "$cacheKey" -R "$REPO" -B "$BRANCH" --confirm
done
echo "Done"
env:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/ci-on-pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CI-PULL-REQUEST"

on: [pull_request]
jobs:
pre-commit:
uses: ./.github/workflows/pre-commit.yml
secrets: inherit
with:
gh_event: ${{ github.event_name }}
phan:
uses: ./.github/workflows/phan.yml
secrets: inherit
needs: [pre-commit]
with:
gh_event: ${{ github.event_name }}
phpstan:
uses: ./.github/workflows/phpstan.yml
secrets: inherit
needs: [pre-commit]
with:
gh_event: ${{ github.event_name }}
#windows-ci:
# needs: [pre-commit, phan, phpstan]
# secrets: inherit
# uses: ./.github/workflows/windows-ci.yml
# with:
# gh_event: ${{ github.event_name }}
gh-travis: # Runs travis script on github runner (not on travis)
if: false
# needs: [pre-commit, phan]
# needs: [windows-ci]
secrets: inherit
needs: [pre-commit, phan, phpstan]
uses: ./.github/workflows/gh-travis.yml
with:
gh_event: ${{ github.event_name }}

# Note (not tested, from https://github.com/orgs/community/discussions/38361)
# To cancel jobs if one fails, the following action may help
# - if: "failure()"
# uses: "andymckay/cancel-action@0.3"
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml → .github/workflows/ci-on-push.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "CI"
name: "CI-PUSH"

on: [push, pull_request]
on: [push]
jobs:
pre-commit:
uses: ./.github/workflows/pre-commit.yml
Expand All @@ -20,7 +20,7 @@ jobs:
with:
gh_event: ${{ github.event_name }}
windows-ci:
needs: [pre-commit, phpstan, phan]
needs: [pre-commit, phan, phpstan]
secrets: inherit
uses: ./.github/workflows/windows-ci.yml
with:
Expand All @@ -30,12 +30,12 @@ jobs:
# needs: [pre-commit, phan]
# needs: [windows-ci]
secrets: inherit
needs: [pre-commit, phan, phpstan]
uses: ./.github/workflows/gh-travis.yml
with:
gh_event: ${{ github.event_name }}


# Note (not tested, from https://github.com/orgs/community/discussions/38361)
# To cancel jobs if one failes, the following action may help
# To cancel jobs if one fails, the following action may help
# - if: "failure()"
# uses: "andymckay/cancel-action@0.3"
5 changes: 2 additions & 3 deletions .github/workflows/exakat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ name: "Exakat analysis"
on:
# execute once a month, the 1st
schedule:
- cron: "0 20 1 * *"
- cron: "0 20 1 * *"
workflow_dispatch:
branches:
- develop

permissions:
contents: read
Expand All @@ -19,6 +17,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: develop
- name: Exakat
uses: docker://exakat/exakat-ga
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh-travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
name: Travis
# Controls when the workflow will run
on:
# push:
# pull_request:
# workflow called by the parent workflow ci.yml
workflow_call:
inputs:
gh_event:
required: true
type: string
# can run job manually
workflow_dispatch:

concurrency:
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/phan.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
---
on:
# pull_request:
# push:
# schedule:
# # execute once a day, the 1st
# - cron: 10 9 * * *
# workflow called by the parent workflow ci.yml
workflow_call:
inputs:
gh_event:
required: true
type: string
# can run job manually
workflow_dispatch:

concurrency:
group: phan-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
gh_event: ${{ inputs.gh_event || github.event_name }}
PHAN_CONFIG: >
${{ 'dev/tools/phan/config.php' }}
PHAN_CONFIG: dev/tools/phan/config.php
PHAN_BASELINE: dev/tools/phan/baseline.txt
PHAN_MIN_PHP: 7.0
PHAN_QUICK: ${{ github.event.schedule && '' || '--quick' }}
Expand All @@ -43,7 +39,8 @@ jobs:
tools: cs2pr,phan
- name: Run Phan analysis
run: |
phan $PHAN_QUICK -k $PHAN_CONFIG -B $PHAN_BASELINE --analyze-twice --minimum-target-php-version $PHAN_MIN_PHP --output-mode=checkstyle -o _phan.xml
# shellcheck disable=2086
phan $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml
- name: Add results to PR
if: ${{ always() }}
run: |
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
name: PHPStan
# Controls when the workflow will run
on:
# push:
# pull_request:
# workflow called by the parent workflow ci.yml
workflow_call:
inputs:
gh_event:
required: true
type: string
# can run job manually
workflow_dispatch:

concurrency:
group: stan-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref
}}
group: stan-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
gh_event: ${{ inputs.gh_event || github.event_name }}
Expand All @@ -37,14 +36,14 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

# Get PHP and addons
- name: Setup PHP
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: phpstan, cs2pr
coverage: none # disable xdebug, pcov
tools: phpstan:2.0, cs2pr
extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap,
mysql, pgsql, sqlite3, ldap, xml, mcrypt

Expand Down Expand Up @@ -86,3 +85,9 @@ jobs:
name: phpstan-srcrt
path: ${{ github.workspace }}/_stan.xml
retention-days: 2
# Run PHPStan generate baseline
# - name: Run PHPStan generate baseline
# id: phpstan-baseline
# if: ${{ success() }}
# run: |
# phpstan -vv analyse --memory-limit 7G -a build/phpstan/bootstrap_action.php --generate-baseline build/phpstan/phpstan-baseline.neon
74 changes: 74 additions & 0 deletions .github/workflows/phpstan_baseline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: 'PHPStan baseline'

on:
# Every Thursday we want to refresh the baseline
schedule:
- cron: '0 6 * * 4'

# We want to be able to manually refresh the baseline too
workflow_dispatch:

workflow_call:
inputs:
gh_event:
required: true
type: string
# Run PHPStan analyse on pull requests
pull_request:

env:
PHP_VERSION: '8.2'
gh_event: ${{ inputs.gh_event || github.event_name }}
CACHE_KEY_PART: ${{ ( inputs.gh_event == 'pull_request' || github.event_name == 'pull_request' ) && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }}
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
coverage: none # disable xdebug, pcov
tools: phpstan:2.0, cs2pr
extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap,
mysql, pgsql, sqlite3, ldap, xml, mcrypt
env:
fail-fast: true
# Restore old cache
- name: Restore phpstan cache
id: cache
uses: actions/cache/restore@v4
with:
path: ./.github/tmp
key: phpstan-cache-${{ env.PHP_VERSION }}-${{ env.CACHE_KEY_PART }}-${{
github.run_id }}
restore-keys: |
phpstan-cache-${{ env.PHP_VERSION }}-${{ env.CACHE_KEY_PART }}-
phpstan-cache-${{ env.PHP_VERSION }}-${{ github.head_ref }}-
phpstan-cache-${{ env.PHP_VERSION }}-${{ github.base_ref }}-
phpstan-cache-${{ env.PHP_VERSION }}-
- uses: ruudk/phpstan-baseline-refresh-create-pr-action@main
with:
github_token: ${{ secrets.PAT_GITHUB_TOKEN }}
phpstan_path: phpstan
configuration_path: phpstan.neon.dist
phpstan_additional_arguments: --memory-limit 7G -a build/phpstan/bootstrap_action.php
baseline_path: build/phpstan/phpstan-baseline.neon
commit_name: Dolibot
commit_email: dolibarr-bot@users.noreply.github.com
commit_message: PHPStan > Update baseline
target_branch: develop
pr_create: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && 1 || 0 }}
# pr_create: 1
pr_title: PHPStan > Update baseline
pr_reviewer: eldy
pr_body: |
This PR is automatically created to cleanup our baseline.
Since the last refresh of the baseline we have fixed {0} ignored errors.
Keep it up all! :muscle:
There are only {1} ignored errors left :sweat_smile:
13 changes: 7 additions & 6 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: pre-commit
on:
# pull_request:
# push:
# workflow called by the parent workflow ci.yml
workflow_call:
inputs:
gh_event:
required: true
type: string
# can run job manually
workflow_dispatch:

concurrency:
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
run: |
set -o pipefail
pre-commit gc
pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG}
pre-commit run --show-diff-on-failure --color=always --all-files | tee "${RAW_LOG}"
# The next uses git, which is slow for a bit repo.
# - name: Get all changed php files (if PR)
Expand Down Expand Up @@ -105,7 +105,8 @@ jobs:
ALL_CHANGED_FILES: ${{ steps.changed-php.outputs.all_changed_files }}
run: |
set -o pipefail
pre-commit run php-cs --files ${ALL_CHANGED_FILES} | tee -a ${RAW_LOG}
# shellcheck disable=2086
pre-commit run php-cs --files ${ALL_CHANGED_FILES} | tee -a "${RAW_LOG}"
- name: Run some pre-commit hooks on all files on push to "main" branches
if: |
Expand All @@ -117,8 +118,8 @@ jobs:
run: |
set -o pipefail
ln -sf ~/.cache .cache # Absolute path in .pre-commit-config.yaml
pre-commit run --hook-stage manual -a php-cs-with-cache | tee -a ${RAW_LOG}
pre-commit run --hook-stage manual -a sqlfluff-lint | tee -a ${RAW_LOG}
pre-commit run --hook-stage manual -a php-cs-with-cache | tee -a "${RAW_LOG}"
pre-commit run --hook-stage manual -a sqlfluff-lint | tee -a "${RAW_LOG}"
ls -l ~/.cache/pre-commit/
- name: Convert Raw Log to Annotations
Expand Down
Loading

0 comments on commit 5928eaf

Please sign in to comment.