Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
atm-maxime committed Mar 18, 2024
2 parents 75a2e11 + 57181e6 commit eae46af
Show file tree
Hide file tree
Showing 1,690 changed files with 37,840 additions and 28,333 deletions.
29 changes: 3 additions & 26 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,9 @@ body:
- type: input
id: environment-version
attributes:
label: Environment Version
label: Dolibarr Version
description: Affected Dolibarr version(s)

- type: input
id: environment-os
attributes:
label: Environment OS
description: Server OS type and version

- type: input
id: environment-webserver
attributes:
label: Environment Web server
description: Webserver type and version
placeholder: 19.0, develop, ...

- type: input
id: environment-php
Expand All @@ -46,22 +35,10 @@ body:
label: Environment Database
description: Database type and version

- type: input
id: environment-urls
attributes:
label: Environment URL(s)
description: Affected URL(s)

- type: textarea
id: expected-behaviour
attributes:
label: Expected and actual behavior
description: Verbose description

- type: textarea
id: reproduce
attributes:
label: Steps to reproduce the behavior
label: Steps to reproduce the behavior and expected behavior
description: Verbose description

- type: textarea
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/cache-clean-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Cleanup caches of a closed branch
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
on:
pull_request:
types: [closed]
workflow_dispatch:
jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
# `actions:write` permission is required to delete caches
# See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
actions: write
contents: read
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
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 )
## 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
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 10 additions & 4 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ concurrency:
cancel-in-progress: true

env:
CACHE_KEY_PART: >
${{ ( github.event_name == 'pull_request' ) && github.base_ref
}}${{ ( github.event_name == 'pull_request' ) && '-' }}${{ github.head_ref }}
CACHE_KEY_PART: ${{ github.event_name == 'pull_request' && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }}
GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down Expand Up @@ -58,7 +56,8 @@ jobs:
# Run PHPStan
- name: Run PHPStan
id: phpstan
run: phpstan -vvv analyse --error-format=checkstyle --memory-limit 4G -a build/phpstan/bootstrap_action.php -c phpstan.neon | cs2pr --graceful-warnings
run: |
phpstan -vvv analyse --error-format=checkstyle --memory-limit 7G -a build/phpstan/bootstrap_action.php | tee _stan.xml | cs2pr --graceful-warnings
# continue-on-error: true

# Save cache
Expand All @@ -68,3 +67,10 @@ jobs:
with:
path: ./.github/tmp
key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }}
- name: Provide phpstan log as artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: phpstan-srcrt
path: ${{ github.workspace }}/_stan.xml
retention-days: 2
45 changes: 24 additions & 21 deletions .github/workflows/windows-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
---
name: Win CI
# yamllint disable-line rule:truthy
on:
push:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref
}}
cancel-in-progress: true

env:
PHPUNIT_LOG: phpunit_tests.log
DOLIBARR_LOG: documents/dolibarr.log
PHPSERVER_LOG: phpserver.log
PHPSERVER_DOMAIN_PORT: 127.0.0.1:8000 # could be 127.0.0.1:8000 if config modified
CACHE_KEY_PART: ${{ ( github.event_name == 'pull_request' ) && github.base_ref }}${{ ( github.event_name == 'pull_request' ) && '-' }}${{ github.head_ref }}
PHP_INI_SCAN_DIR: "C:\\myphpini"
PHPSERVER_DOMAIN_PORT: 127.0.0.1:8000 # could be 127.0.0.1:8000 if config modified
CACHE_KEY_PART: ${{ github.event_name == 'pull_request' && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }}
PHP_INI_SCAN_DIR: C:\myphpini
CKEY: win-ci-2

GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action
jobs:
win-test:
strategy:
matrix:
os: [windows-latest]
# php_version: [7.4, 8.0] # Add more versions if needed
php_version: [7.4] # Add more versions if needed
php_version: [7.4] # Add more versions if needed
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup MariaDB
uses: ankane/setup-mariadb@v1
with:
# mariadb-version: ${{ matrix.mariadb-version }}
database: travis # Specify your database name

database: travis # Specify your database name
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -57,16 +55,18 @@ jobs:
id: cache
uses: actions/cache/restore@v4
with:
# See https://github.com/actions/cache/issues/1275#issuecomment-1925217178
enableCrossOsArchive: true
path: |
db_init.sql
db_init.sql.md5
key: ${{ matrix.os }}-${{ env.ckey }}-${{ matrix.php_version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }}
key: ${{ matrix.os }}-${{ env.ckey }}-${{ matrix.php_version }}-${{ env.CACHE_KEY_PART
}}-${{ github.run_id }}
restore-keys: |
${{ matrix.os }}-${{ env.ckey }}-${{ matrix.php_version }}-${{ env.CACHE_KEY_PART }}-
${{ matrix.os }}-${{ env.ckey }}-${{ matrix.php_version }}-${{ github.head_ref }}-
${{ matrix.os }}-${{ env.ckey }}-${{ matrix.php_version }}-${{ github.base_ref }}-
${{ matrix.os }}-${{ env.ckey }}-${{ matrix.php_version }}-
- name: Create local php.ini
shell: cmd
if: false
Expand All @@ -91,7 +91,6 @@ jobs:
SET PHP_INI_SCAN_DIR=
ECHO "==== Verify it is used by PHP ==="
php --ini
- name: Run Bash script
# Note this is bash (MSYS) on Windows
shell: bash
Expand All @@ -104,9 +103,10 @@ jobs:
sed -i -e 's/stopOnFailure="[^"]*"/stopOnFailure="false"/' test/phpunit/phpunittest.xml
# Check if database cache is present after the script (visually, to remove once ok)
ls -l
echo "TAIL=$(cygpath -w "$(which tail)")" >> "$GITHUB_ENV"
echo "GREP=$(cygpath -w "$(which grep)")" >> "$GITHUB_ENV"
echo "TEE=$(cygpath -w "$(which tee)")" >> "$GITHUB_ENV"
echo "BASEDIR=$(realpath .)" >> "$GITHUB_ENV"
- name: Start web server
id: server
if: false
Expand All @@ -115,9 +115,8 @@ jobs:
Start-Process -FilePath "php.exe" -WindowStyle Hidden -ArgumentList "-S ${{ env.PHPSERVER_DOMAIN_PORT }} -t htdocs > ${{ env.PHPSERVER_LOG }}" -PassThru
curl "http://${{ env.PHPSERVER_DOMAIN_PORT }}"
shell: powershell

- name: Run PHPUnit tests
continue-on-error: true
# continue-on-error: true
shell: cmd
# setting up php.ini, starting the php server are currently in this step
run: |-
Expand Down Expand Up @@ -146,15 +145,17 @@ jobs:
cat htdocs/conf/conf.php
curl "http://${{ env.PHPSERVER_DOMAIN_PORT }}"
REM 'DOSKEY' USED to recover error code (no pipefile equivalent in windows?)
( php "%PHPROOT%\phpunit" -d memory_limit=-1 -c %CD%\test\phpunit\phpunittest.xml "test\phpunit\AllTests.php" & call doskey /exename=err err=%%^^errorlevel%% ) | "${{ env.TEE }}" "${{ env.PHPUNIT_LOG }}"
( php "%PHPROOT%\phpunit" -d memory_limit=-1 -c %CD%\test\phpunit\phpunittest.xml "test\phpunit\AllTests.php" --exclude-group WindowsWaitingForFix & call doskey /exename=err err=%%^^errorlevel%% ) | "${{ env.TEE }}" "${{ env.PHPUNIT_LOG }}"
echo ""
echo "Ensure that PHPUNIT completed (no early exit from code)"
"${{ env.TAIL }}" -5 "${{ env.PHPUNIT_LOG }}" | "${{ env.GREP }}" -qE "(OK .*[0-9]+ tests.*[0-9]+ assertions|Tests: [0-9]+)" || EXIT /B 1
echo "PHPUNIT seems to have completed with a test result, reuse the exit code"
for /f "tokens=2 delims==" %%A in ('doskey /m:err') do EXIT /B %%A
- name: Convert Raw Log to Annotations
uses: mdeweerd/[email protected]
if: ${{ failure() }}
with:
in: ${{ env.PHPUNIT_LOG }}

- name: Provide dolibarr and phpunit logs as artifact
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
Expand All @@ -169,9 +170,11 @@ jobs:
retention-days: 2

# Save cache
- name: "Save cache"
- name: Save cache
uses: actions/cache/save@v4
if: ${{ ! cancelled() }}
with:
# See https://github.com/actions/cache/issues/1275#issuecomment-1925217178
enableCrossOsArchive: true
key: ${{ steps.cache.outputs.cache-primary-key }}
path: db_init.*
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,26 @@ doc/install.lock
/composer.json
/composer.lock

# Local script, executed during pre-commit
/local.sh

# Local phpstan configuration
/phpstan.neon
/phpstan-baseline.neon

# Logs
/*.log

# Vim swap files
*.sw?

# Generated by PHPUNIT.BAT
/INI_PHPUNIT

# ignore cache builds
/build/phpstan/phpstan
/build/phpstan/bootstrap_custom.php
phpstan_custom.neon
/.php-cs-fixer.cache
/.php_cs.cache
/.cache
11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ repos:
rev: v6.2.1
hooks:
- id: beautysh
exclude: (?x)^(dev/setup/git/hooks/pre-commit)$
exclude: |
(?x)^(dev/setup/git/hooks/pre-commit
)$
args: [--tab]

# Run local script
Expand All @@ -77,6 +79,13 @@ repos:
# ```
- repo: local
hooks:
- name: Find missing/unused/duplicate language keys
id: check-translations
files: (?x)^(htdocs/langs/en_US/.*\.lang)
language: script
entry: ./dev/translation/sanity_check_trans_missing_unused.sh
pass_filenames: false
args: [list]
- id: local-precommit-script
name: Run local script before commit if it exists
language: system
Expand Down
Loading

0 comments on commit eae46af

Please sign in to comment.