From 513754135026b9bd70c8efc7b03bc801e11caf79 Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Wed, 19 Aug 2026 10:06:36 +0530 Subject: [PATCH] CLOSE: #0 Remove upstream GitHub workflows --- .github/workflows/ci-cache-clean-pr.yml | 40 ---- .github/workflows/ci-checkfilesetlock.yml | 99 --------- .github/workflows/ci-on-pull_request.yml | 38 ---- .github/workflows/ci-on-push.yml | 38 ---- .github/workflows/ci-on-release.yml | 24 --- .github/workflows/ci-phpstan_baseline.yml | 82 -------- .github/workflows/ci-pr-autoassign-v18.yml | 164 --------------- .github/workflows/ci-stale-issues-safe.yml | 28 --- .github/workflows/moderation.yml | 79 -------- .github/workflows/phan.yml | 100 --------- .github/workflows/phpstan.yml | 142 ------------- .github/workflows/pre-commit.yml | 179 ---------------- .github/workflows/windows-ci.yml | 224 --------------------- 13 files changed, 1237 deletions(-) delete mode 100644 .github/workflows/ci-cache-clean-pr.yml delete mode 100644 .github/workflows/ci-checkfilesetlock.yml delete mode 100644 .github/workflows/ci-on-pull_request.yml delete mode 100644 .github/workflows/ci-on-push.yml delete mode 100644 .github/workflows/ci-on-release.yml delete mode 100644 .github/workflows/ci-phpstan_baseline.yml delete mode 100644 .github/workflows/ci-pr-autoassign-v18.yml delete mode 100644 .github/workflows/ci-stale-issues-safe.yml delete mode 100644 .github/workflows/moderation.yml delete mode 100644 .github/workflows/phan.yml delete mode 100644 .github/workflows/phpstan.yml delete mode 100644 .github/workflows/pre-commit.yml delete mode 100644 .github/workflows/windows-ci.yml diff --git a/.github/workflows/ci-cache-clean-pr.yml b/.github/workflows/ci-cache-clean-pr.yml deleted file mode 100644 index 77d180711e9..00000000000 --- a/.github/workflows/ci-cache-clean-pr.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -# This clean the caches of a branch when we close the pull request. -# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy -name: Cleanup caches of a closed branch - -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@v7 - - 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 }} diff --git a/.github/workflows/ci-checkfilesetlock.yml b/.github/workflows/ci-checkfilesetlock.yml deleted file mode 100644 index 49b2cdbd385..00000000000 --- a/.github/workflows/ci-checkfilesetlock.yml +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This is a basic workflow to check the lock on major version (to lock some files on certified versions) -name: Check fileset lock - -on: - push: - branches: - - "24.0" - - develop - pull_request_target: - branches: - - "24.0" - - develop - -concurrency: - group: check-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - checkmajorversion: - name: Check lock on fileset unalterable_files with generate_filelist_xml.php - runs-on: ubuntu-latest - - permissions: - contents: read - pull-requests: write - - # Referent Qualite/ Conformite (will be autoassigned as reviewer) - env: - REVIEWER: "eldy" - - - # Do not run schedule on forks - if: | - github.repository == 'Dolibarr/dolibarr' - || github.event.schedule == false - steps: - # 1) Generate a GitHub App token (via actions/create-github-app-token) - - name: Generate GitHub App token - id: generate-token - uses: actions/create-github-app-token@v3 - with: - app-id: ${{ vars.PR18_APP_ID }} - private-key: ${{ secrets.PR18_SECRET_KEY }} - - - # 2) Checkout repository (useful if repo content is needed later) - - name: Checkout repository - uses: actions/checkout@v7 - - # Debug information (useful for diagnostics) - - name: Debug info - run: | - echo "Event: $GITHUB_EVENT_NAME" - echo "Ref: $GITHUB_REF" - echo "Run id: $GITHUB_RUN_ID" - echo "Reviewer configured: $REVIEWER" - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - coverage: none # disable xdebug, pcov - - - name: Run generate_filelist_xml.php - id: checklock - continue-on-error: true - run: | - # shellcheck disable=2086 - dev/build/generate_filelist_xml.php checklock=auto unalterable_files - - - # Assign reviewers one-by-one with fine-grained error handling - # - try each reviewer, track successes and failures - # - fail the step only if none could be added - # - succeed if at least one was added (but log failures) - - name: Assign reviewers on PR (per-reviewer, tolerant errors) - if: ${{ github.event_name == 'pull_request_target' && steps.checklock.outcome == 'failure' }} - env: - GH_TOKEN: ${{ steps.generate-token.outputs.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - REPO: ${{ github.repository }} - REVIEWER: ${{ env.REVIEWER }} - run: | - echo "Lock check failed, assigning reviewer ${REVIEWER}" - - curl -s \ - -X POST \ - -H "Authorization: Bearer ${GH_TOKEN}" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/${REPO}/pulls/${PR_NUMBER}/requested_reviewers" \ - -d "{\"reviewers\": [\"${REVIEWER}\"]}" - - - name: Fail workflow if lock check failed - if: steps.checklock.outcome == 'failure' - run: | - echo "The list of unalterable files has been modified." - echo "Review from the compliance maintainer is required." - exit 1 diff --git a/.github/workflows/ci-on-pull_request.yml b/.github/workflows/ci-on-pull_request.yml deleted file mode 100644 index 1c6b568ef1f..00000000000 --- a/.github/workflows/ci-on-pull_request.yml +++ /dev/null @@ -1,38 +0,0 @@ -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: - # if: false # Uncommenting this line disables 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 }} diff --git a/.github/workflows/ci-on-push.yml b/.github/workflows/ci-on-push.yml deleted file mode 100644 index 17659b89ae8..00000000000 --- a/.github/workflows/ci-on-push.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: "CI-PUSH" - -on: [push] - -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: - if: github.ref == 'refs/heads/develop' # Condition for branch "develop" - 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 }} diff --git a/.github/workflows/ci-on-release.yml b/.github/workflows/ci-on-release.yml deleted file mode 100644 index 32eac6da117..00000000000 --- a/.github/workflows/ci-on-release.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: "CI-RELEASE" - -on: - release: - types: [published] - -jobs: - trigger-docker: - runs-on: ubuntu-latest - - steps: - - name: Generate a token - id: generate-token - uses: actions/create-github-app-token@v3 - with: - app-id: ${{ vars.RELEASE_DOCKER_ID }} - private-key: ${{ secrets.RELEASE_DOCKER_SECRET }} - - - uses: peter-evans/repository-dispatch@v4 - with: - token: ${{ steps.generate-token.outputs.token }} - repository: Dolibarr/dolibarr-docker - event-type: new-release - client-payload: '{"version": "${{ github.event.release.tag_name }}"}' diff --git a/.github/workflows/ci-phpstan_baseline.yml b/.github/workflows/ci-phpstan_baseline.yml deleted file mode 100644 index 3e3f7485cf5..00000000000 --- a/.github/workflows/ci-phpstan_baseline.yml +++ /dev/null @@ -1,82 +0,0 @@ ---- -# This run the script to update the phpstan baseline file dev/build/phpstan/phpstan-baseline.neon -name: 'PHPStan baseline' - -on: - # Every day we want to refresh the baseline - schedule: - - cron: '0 12 * * *' - - # 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: - -permissions: {} # none - -env: - PHP_VERSION: '8.2' - GH_TOKEN: ${{ github.token }} - 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 - permissions: - contents: write - pull-requests: write - steps: - - name: Checkout - uses: actions/checkout@v7 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ env.PHP_VERSION }} - coverage: none # disable xdebug, pcov - tools: phpstan:2.1.12 - 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@v6 - 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: ${{ env.GH_TOKEN }} - phpstan_path: phpstan - configuration_path: phpstan.neon.dist - phpstan_additional_arguments: --memory-limit 7G -a dev/build/phpstan/bootstrap_action.php - baseline_path: dev/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: diff --git a/.github/workflows/ci-pr-autoassign-v18.yml b/.github/workflows/ci-pr-autoassign-v18.yml deleted file mode 100644 index 595811df2ea..00000000000 --- a/.github/workflows/ci-pr-autoassign-v18.yml +++ /dev/null @@ -1,164 +0,0 @@ -# Action to prepare the GitHub Action -# Prerequisites (create in the organization / repo): -# - Create a Github app with name "The DoliBear bot for ..." and no special options -# - Generate a client secret for this Github app -# - Set Read access to actions, administration, code, custom organization roles, custom repository roles, members, and metadata -# - Set Read and write access to discussions, issues, merge queues, pull requests, and repository projects -# - Set permission of the Github app for the repository of sources -# - Create the secret: PR18_SECRET_KEY (private key generated for the GitHub App) with permission for the repository of sources and value of Github app secret -# - Variable: PR18_APP_ID (GitHub App ID) with value of the GitHub App ID -# -# Behavior: -# - On pull_request_target (opened, synchronize, reopened) against branch 18.0: -# - Generate a GitHub App token -# - Add the label "Issue for v18 maintenance Team" to the PR (error-tolerant) -# - Assign the reviewers listed below, excluding the PR author -# -> attempt per reviewer (if a reviewer fails, log and continue) -# -> the step fails only if no reviewer could be added -# - On push to 18.0: workflow runs but PR-specific actions are skipped -# -name: Set reviewer and label for v18 - -on: - pull_request_target: - types: [opened, synchronize, reopened] - branches: - - "18.0" - push: - branches: - - "18.0" - -permissions: - pull-requests: write - issues: write - -jobs: - assign-and-label-v18: - runs-on: ubuntu-latest - - # Mergeers / reviewers list: edit here as needed (comma-separated) - env: - REVIEWERS: "lvessiller-opendsi,rycks" - # Label name to apply - V18_LABEL: "Issue for v18 maintenance Team" - - steps: - # 1) Generate a GitHub App token (via actions/create-github-app-token) - - name: Generate GitHub App token - id: generate-token - uses: actions/create-github-app-token@v3 - with: - app-id: ${{ vars.PR18_APP_ID }} - private-key: ${{ secrets.PR18_SECRET_KEY }} - - # 2) Checkout repository (useful if repo content is needed later) - - name: Checkout repository - uses: actions/checkout@v7 - - # Debug information (useful for diagnostics) - - name: Debug info - run: | - echo "Event: $GITHUB_EVENT_NAME" - echo "Ref: $GITHUB_REF" - echo "Run id: $GITHUB_RUN_ID" - echo "Reviewers configured: $REVIEWERS" - - # 3) Add the label to the PR (PR events only) - # -> tolerant to errors: log on failure but do not fail the job - - name: Add label to PR (pull_request events only) - if: ${{ github.event_name == 'pull_request_target' }} - env: - GH_TOKEN: ${{ steps.generate-token.outputs.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - V18_LABEL: ${{ env.V18_LABEL }} - REPO: ${{ github.repository }} - run: | - set -euo pipefail - echo "Adding label '$V18_LABEL' to PR #${PR_NUMBER}" - response=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ - -H "Authorization: Bearer ${GH_TOKEN}" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/${REPO}/issues/${PR_NUMBER}/labels" \ - -d "{\"labels\": [\"${V18_LABEL}\"]}") - - if [ "$response" -eq 200 ]; then - echo "Label added successfully." - else - echo "Warning: failed to add label '$V18_LABEL' to PR #${PR_NUMBER} (HTTP $response). Continuing." - fi - - # 4) Compute final reviewers list excluding the PR author - - name: Compute reviewers (exclude PR author) - if: ${{ github.event_name == 'pull_request_target' }} - id: set-reviewers - run: | - set -euo pipefail - IFS=',' read -ra ALL_REVIEWERS <<< "${REVIEWERS}" - AUTHOR="${{ github.event.pull_request.user.login }}" - FINAL=() - for r in "${ALL_REVIEWERS[@]}"; do - r_trimmed="$(echo "$r" | xargs)" - if [ -z "$r_trimmed" ]; then - continue - fi - if [ "$r_trimmed" != "$AUTHOR" ]; then - FINAL+=("$r_trimmed") - fi - done - if [ ${#FINAL[@]} -eq 0 ]; then - echo "reviewers=" >> $GITHUB_OUTPUT - else - reviewers_csv="$(IFS=, ; echo "${FINAL[*]}")" - echo "reviewers=${reviewers_csv}" >> $GITHUB_OUTPUT - fi - echo "author=$AUTHOR" >> $GITHUB_OUTPUT - echo "Computed reviewers: ${reviewers_csv:-}" - - # 5) Assign reviewers one-by-one with fine-grained error handling - # - try each reviewer, track successes and failures - # - fail the step only if none could be added - # - succeed if at least one was added (but log failures) - - name: Assign reviewers on PR (per-reviewer, tolerant errors) - if: ${{ github.event_name == 'pull_request_target' && steps.set-reviewers.outputs.reviewers != '' }} - env: - GH_TOKEN: ${{ steps.generate-token.outputs.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - REVIEWERS_CSV: ${{ steps.set-reviewers.outputs.reviewers }} - REPO: ${{ github.repository }} - run: | - set -uo pipefail - IFS=',' read -ra TO_ADD <<< "${REVIEWERS_CSV}" - SUCCESS=0 - FAILED=() - for r in "${TO_ADD[@]}"; do - r_trimmed="$(echo "$r" | xargs)" - if [ -z "$r_trimmed" ]; then - continue - fi - echo "Attempting to add reviewer: $r_trimmed" - response=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ - -H "Authorization: Bearer ${GH_TOKEN}" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/${REPO}/pulls/${PR_NUMBER}/requested_reviewers" \ - -d "{\"reviewers\": [\"${r_trimmed}\"]}") - - if [ "$response" -eq 201 ] || [ "$response" -eq 200 ]; then - echo "Added reviewer: $r_trimmed" - SUCCESS=$((SUCCESS+1)) - else - echo "Warning: failed to add reviewer: $r_trimmed (HTTP $response)" - FAILED+=("$r_trimmed") - fi - done - if [ $SUCCESS -eq 0 ]; then - echo "Error: none of the configured reviewers could be added: ${FAILED[*]:-}" - exit 1 - else - echo "Reviewers added: ${SUCCESS}. Failed to add: ${FAILED[*]:-none}" - fi - - # 6) Push event notice (no PR-specific actions performed) - - name: Push event notice - if: ${{ github.event_name == 'push' }} - run: | - echo "Triggered by push on branch 18.0. No PR-specific actions performed." diff --git a/.github/workflows/ci-stale-issues-safe.yml b/.github/workflows/ci-stale-issues-safe.yml deleted file mode 100644 index 266227fc057..00000000000 --- a/.github/workflows/ci-stale-issues-safe.yml +++ /dev/null @@ -1,28 +0,0 @@ -# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions -name: "Close stale issues (bugs and feature requests)" - -on: - schedule: - - cron: "0 21 * * *" - issue_comment: - types: [created] - workflow_dispatch: - -permissions: {} # none - -jobs: - stale: - permissions: - issues: write - runs-on: ubuntu-latest - steps: - - uses: Dolibarr/stale@staleunstale - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 10 days (you should still be able to re-open it if required).' - stale-label: 'Issue Stale (automatic label)' - exempt-labels: 'Priority High / Blocking,Priority Top Strategic,Priority Medium,hacktoberfest,hacktoberfest-accepted,good first issue,Bug Security (CVE),Analysis of PR in progress' - days-before-stale: 365 - days-before-close: 10 - operations-per-run: 100 - dry-run: false diff --git a/.github/workflows/moderation.yml b/.github/workflows/moderation.yml deleted file mode 100644 index 69f2c31d2f1..00000000000 --- a/.github/workflows/moderation.yml +++ /dev/null @@ -1,79 +0,0 @@ -# Github action to experiment automatic moderation -name: Moderation Bot - -on: - issue_comment: - types: [created, edited] - pull_request_review_comment: - types: [created, edited] - -permissions: - issues: write - pull-requests: write - -jobs: - moderate: - runs-on: ubuntu-latest - steps: - - name: Install franc - run: npm install franc - - - name: Moderate comments - uses: actions/github-script@v9 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const forbiddenPatterns = [ - 'music.youtube.com', - 'youtu.be', - 'youtube.com/watch' - ] - - const profanityList = JSON.parse(process.env.PROFANITY_LIST || '[]') - const offTopicKeywords = JSON.parse(process.env.OFFTOPIC_LIST || '[]') - - const comment = context.payload.comment.body || '' - const commentAuthor = context.payload.comment.user.login - const repoOwner = context.repo.owner - const isOwner = commentAuthor === repoOwner - - const isForbidden = forbiddenPatterns.some(p => comment.toLowerCase().includes(p)) - const isProfane = profanityList.some(word => new RegExp(`\\b${word}\\b`, 'i').test(comment)) - const isOffTopic = offTopicKeywords.some(kw => comment.toLowerCase().includes(kw.toLowerCase())) - - async function isEnglishFunc(text) { - try { - const { franc } = await import('franc'); - const lang = franc(text); - return lang.startsWith('eng') || lang.startsWith('sco'); - } catch (e) { - console.log('Language detection failed:', e) - return true; - } - } - let isEnglish = await isEnglishFunc(comment) - - if ((isForbidden || isProfane || isOffTopic || !isEnglish) && !isOwner) { - try { - const issueNumber = context.payload.issue?.number || context.payload.pull_request?.number - const reason = !isEnglish ? 'non-English comment' : - isForbidden ? 'forbidden link' : - isProfane ? 'profanity' : 'off-topic content' - - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueNumber, - body: `Comment auto removed: ${reason} violates repository guidelines.` - }) - - await github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id - }) - } catch (error) { - console.error('Moderation error:', error) - throw error - } - } diff --git a/.github/workflows/phan.yml b/.github/workflows/phan.yml deleted file mode 100644 index 9acdbfa17b7..00000000000 --- a/.github/workflows/phan.yml +++ /dev/null @@ -1,100 +0,0 @@ ---- -# This is a basic workflow to check code with PHPSTAN tool -name: Phan - -on: - # 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.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - gh_event: ${{ inputs.gh_event || github.event_name }} - PHAN_CONFIG: dev/tools/phan/config.php - PHAN_BASELINE: dev/tools/phan/baseline.txt - PHAN_MIN_PHP: 7.2 - PHAN_QUICK: ${{ github.event.schedule && '' || '--quick' }} - GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action - -jobs: - phan: - name: Run phan - runs-on: ubuntu-latest - # Do not run schedule on forks - if: | - github.repository == 'Dolibarr/dolibarr' - || github.event.schedule == false - steps: - - uses: actions/checkout@v7 - - # Another method to get the list of changed files - # It sets the variable steps.changed-php.outputs.all_changed_files for other steps - - name: Get all changed php files (if PR) - id: changed-php - if: env.gh_event == 'pull_request' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./.github/scripts/get_changed_php.sh - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.4 - coverage: none # disable xdebug, pcov - extensions: ast - tools: cs2pr:1.8.6,phan:5.5.2 - - - - name: Run Phan analysis - # Proceed when: - # - the action is not cancelled - # AND - # - the branch is an integration branch (no merge), or, - # - the merge from branch contains 'phan_full', or, - # - there are changes in PHP files. - # Note: --output-mode=github does not provide file:line, so using checkstyle and cs2pr - if: ${{ ! cancelled() && (github.ref_name == 'develop' || github.ref_name == 'refs/heads/develop' || endsWith(github.ref_name, '.0') || contains(github.head_ref, 'phan_full') || steps.changed-php.outputs.phan_changed == 'true') }} - env: - ALL_CHANGED_FILES: ${{ steps.changed-php.outputs.all_changed_files }} - PHAN_CHANGED_FILES: ${{ steps.changed-php.outputs.phan_changed_files }} - # shellcheck disable=2086 - FILE_CHANGED_LIST: /tmp/phan-changed.lst - run: | - # shellcheck disable=2086 - if [ "${{ github.ref_name }}" == "develop" ] || [[ "${{ github.ref_name }}" == *.0 ]]|| [[ "${{ github.head_ref }}" == *"phan_full"* ]] ; then - echo phan $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml - phan $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml - else - echo -n "" > "$FILE_CHANGED_LIST" - for f in $PHAN_CHANGED_FILES; do echo "$f" >> "$FILE_CHANGED_LIST"; done - # Must exclude same files as in phan configuration - grep -v -E '^htdocs/(custom/|.*/canvas/.*/tpl/.*.tpl.php|admin/tools/ui/|includes/(nusoap/|restler/|stripe/)|conf/conf.php)$' "$FILE_CHANGED_LIST"> "$FILE_CHANGED_LIST".tmp || true - mv "$FILE_CHANGED_LIST".tmp "$FILE_CHANGED_LIST" - if [ ! -s "$FILE_CHANGED_LIST" ] ; then - echo "All changed files are excluded for phan" - else - echo phan --file-list "$FILE_CHANGED_LIST" $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml - phan --file-list "$FILE_CHANGED_LIST" $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml - fi - fi - - - name: Add results to PR as Github notices - if: ${{ always() }} - run: | - cs2pr --prepend-filename --prepend-source --notices-as-warnings _phan.xml - - - name: Provide phan log as artifact - uses: actions/upload-artifact@v7 - if: ${{ always() }} - with: - name: phan-srcrt - path: ${{ github.workspace }}/_phan.xml - retention-days: 2 diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml deleted file mode 100644 index b597b678c68..00000000000 --- a/.github/workflows/phpstan.yml +++ /dev/null @@ -1,142 +0,0 @@ ---- -# This is a basic workflow to check code with PHPSTAN tool -name: PHPStan - -# Controls when the workflow will run -on: - # 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: phpstan-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - 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 }} - GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action - DUMMY_FILE: htdocs/theme/md/progress.inc.php -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job - php-stan: - # The type of runner that the job will run on - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php-version: - # PHPStan requires PHP >= 7.2. - #- "7.2" - - '8.2' - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v7 - # Get PHP and addons - - name: Setup PHP - id: setup-php - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - coverage: none # disable xdebug, pcov - tools: phpstan:2.1.12, cs2pr:1.8.6 - extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap, - mysql, pgsql, sqlite3, ldap, xml, mcrypt - - # Restore old cache - - name: Restore phpstan cache - id: cache - uses: actions/cache/restore@v6 - with: - path: ./.github/tmp - key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ - github.run_id }} - restore-keys: | - phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}- - phpstan-cache-${{ matrix.php-version }}-${{ github.head_ref }}- - phpstan-cache-${{ matrix.php-version }}-${{ github.base_ref }}- - phpstan-cache-${{ matrix.php-version }}- - - - name: Show debug info - run: ls -al ./.github/tmp || echo "Cache directory not found (first run)" - - # Another method to get the list of changed files - # It sets the variable steps.changed-php.outputs.all_changed_files for other steps - - name: Get all changed php files (if PR) - id: changed-php - if: env.gh_event == 'pull_request' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./.github/scripts/get_changed_php.sh - - #- name: Get changed PHP files - # id: files - # run: | - # git fetch origin ${{ github.base_ref }} - # FILES=$(git diff --name-only "origin/${{ github.base_ref }}...HEAD" | grep '\.php$' || true) - # { - # echo "files< "$GITHUB_OUTPUT" - - # Run PHPStan - - name: Run PHPStan - id: phpstan - # Proceed when: - # - the action is not cancelled - # AND - # - the branch is an integration branch (no merge), or, - # - the merge from branch contains 'phpstan_full', or, - # - there are changes in PHP files. - if: ${{ ! cancelled() && (github.ref_name == 'develop' || github.ref_name == 'refs/heads/develop' || endsWith(github.ref_name, '.0') || contains(github.head_ref, 'phpstan_full') || steps.changed-php.outputs.any_changed == 'true') }} - env: - ALL_CHANGED_FILES: ${{ steps.changed-php.outputs.all_changed_files }} - # shellcheck disable=2086 - run: | - # shellcheck disable=2086 - if [ "${{ github.ref_name }}" == "develop" ] || [[ "${{ github.ref_name }}" == *.0 ]]|| [[ "${{ github.head_ref }}" == *"phpstan_full"* ]] ; then - # Run phpstan on all files in integration branch - phpstan analyse --no-progress --error-format=checkstyle --memory-limit 7G -a dev/build/phpstan/bootstrap_action.php | tee _stan.xml | cs2pr --graceful-warnings - else - PHP_FILES=$(echo "$ALL_CHANGED_FILES" | tr ' ' '\n' | grep -E '\.php$' || true) - echo "PHP_FILES=$PHP_FILES" - if [ -z "$PHP_FILES" ]; then - echo "No PHP files to analyse. Skipping PHPStan." - exit 0 - fi - - echo phpstan analyse --no-progress --error-format=checkstyle --memory-limit 7G -a dev/build/phpstan/bootstrap_action.php ${ALL_CHANGED_FILES} - phpstan analyse --no-progress --error-format=checkstyle --memory-limit 7G -a dev/build/phpstan/bootstrap_action.php "${{ env.DUMMY_FILE }}" ${ALL_CHANGED_FILES} | tee _stan.xml | cs2pr --graceful-warnings - fi - # continue-on-error: true - - # Save cache - - name: Save phpstan cache - uses: actions/cache/save@v6 - if: ${{ success() || ( ! cancelled() && steps.cache.outputs.cache-hit != 'true' ) }} - 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@v7 - if: ${{ always() }} - with: - 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 dev/build/phpstan/bootstrap_action.php --generate-baseline dev/build/phpstan/phpstan-baseline.neon diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml deleted file mode 100644 index c4ff9b90009..00000000000 --- a/.github/workflows/pre-commit.yml +++ /dev/null @@ -1,179 +0,0 @@ ---- -name: pre-commit - -on: - # 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: pre-commit-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - gh_event: ${{ inputs.gh_event || github.event_name }} - -jobs: - pre-commit: - runs-on: ubuntu-latest - env: - RAW_LOG: pre-commit.log - CS_XML: pre-commit.xml - steps: - #- name: Install required tools - # run: sudo apt-get update && sudo apt-get install cppcheck - # if: false - - # Checkout git sources to analyze - - uses: actions/checkout@v7 - - # Try to get the list of modified files into steps.changed-php.outputs.all_changed_files - #- name: Get changed files - # id: changed-files - # uses: actions/github-script@v7 - # with: - # script: | - # const base = context.payload.pull_request?.base?.sha; - # const head = context.payload.pull_request?.head?.sha; - # const response = await github.rest.repos.compareCommits({ - # owner: context.repo.owner, - # repo: context.repo.repo, - # base, - # head - # }); - # - # const changedFiles = response.data.files.map(file => file.filename); - # core.setOutput("all_changed_files", changedFiles.join(" ")); - - # Another method to get the list of changed files - # It sets the variable steps.changed-php.outputs.all_changed_files for other steps - - name: Get all changed php files (if PR) - id: changed-php - if: env.gh_event == 'pull_request' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./.github/scripts/get_changed_php.sh - - - name: Print changed files - run: echo "Changed files are ${{ steps.changed-php.outputs.all_changed_files }}" - - # Action setup-python needs a requirements.txt or pyproject.toml - # This ensures one of them exists. - - name: Create requirements.txt if no requirements.txt or pyproject.toml - run: |- - [ -r requirements.txt ] || [ -r pyproject.toml ] || touch requirements.txt - # Install python and pre-commit tool - - uses: actions/setup-python@v6 - with: - cache: pip - python-version: "3.11" - - run: python -m pip install pre-commit - - # Restore previous cache of precommit - - uses: actions/cache/restore@v6 - with: - path: ~/.cache/pre-commit/ - key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - - # Run all the precommit tools (defined in pre-commit-config.yaml). - - name: Extract PHP version - id: extract-php-version - run: | - # shellcheck disable=SC2016 - PHP_VERSION=$(sed -n 's/.*\$arrayphpmaxversionwarning\s*=\s*array\s*(\s*\([0-9]\+\)\s*,\s*\([0-9]\+\).*/\1.\2/p' htdocs/install/check.php) - echo "PHP_VERSION=$PHP_VERSION" >> "$GITHUB_ENV" - - - name: Setup PHPCS - uses: shivammathur/setup-php@v2 - # Install proper php version, and also install phpcs which may be needed - if: | - ! cancelled() && - ( - steps.changed-php.outputs.any_changed == 'true' - || - ( - env.gh_event == 'push' - && ( - github.event.ref == 'refs/heads/develop' - || endsWith(github.event.ref, '.0') - ) - ) - ) - with: - php-version: ${{ env.PHP_VERSION }} # Version from check.php - coverage: none # disable xdebug, pcov - tools: phpcs - - # Install perltidy and perlcritic - #- name: Install perltidy and perlcritic - # run: sudo apt-get update && sudo apt-get install -y perltidy libperl-critic-perl - - # Run all the precommit tools (defined into pre-commit-config.yaml). - # We can force exclusion of some of them here. - - name: Run pre-commit hooks - env: - # SKIP is used by pre-commit to not execute certain hooks - SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer,shellcheck - run: | - set -o pipefail - pre-commit gc - 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) - # id: changed-php - # uses: tj-actions/changed-files@v45 - # if: env.gh_event == 'pull_request' - # with: - # files: | - # **.php - - - name: Run some pre-commit hooks on selected changed files only - if: "! cancelled() && steps.changed-php.outputs.any_changed == 'true'" - env: - ALL_CHANGED_FILES: ${{ steps.changed-php.outputs.all_changed_files }} - run: | - set -o pipefail - # 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: | - env.gh_event == 'push' - && ( - github.event.ref == 'refs/heads/develop' - || endsWith(github.event.ref, '.0') - ) - 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}" - ls -l ~/.cache/pre-commit/ - - - name: Convert Raw Log to Annotations - uses: mdeweerd/logToCheckStyle@v2026.8.2 - if: ${{ failure() }} - with: - in: ${{ env.RAW_LOG }} - - # Save the precommit cache - - uses: actions/cache/save@v6 - if: ${{ ! cancelled() }} - with: - path: ~/.cache/pre-commit/ - key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - # Upload result log files of precommit into the Artifact shared store - - name: Provide log as artifact - uses: actions/upload-artifact@v7 - if: ${{ ! cancelled() }} - with: - name: precommit-logs - path: | - ${{ env.RAW_LOG }} - ${{ env.CS_XML }} diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml deleted file mode 100644 index edad4973a3b..00000000000 --- a/.github/workflows/windows-ci.yml +++ /dev/null @@ -1,224 +0,0 @@ ---- -name: Win CI - -# yamllint disable-line rule:truthy -on: - # 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: win-ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref - }} - cancel-in-progress: true -env: - gh_event: ${{ inputs.gh_event || github.event_name }} - 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: ${{ ( inputs.gh_event == 'pull_request' || 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 - GS_VERSION: "10.07.0" # Ghostscript version - -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 - runs-on: ${{ matrix.os }} - steps: - - name: Checkout code - uses: actions/checkout@v7 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php_version }} - # ini-values: post_max_size=256M, max_execution_time=180 - extensions: > - calendar, gd, imagick, imap, intl, json, ldap, mbstring, - mcrypt, mysql, mysqli, opcache, pgsql, sqlite3, xml, zip - tools: > - composer, - phpunit:9.5 - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # phpts: ts # ts for thread-safe, default nts - # steps: - - - name: Restore cache Ghostscript (also stores cache at end of workflow) - uses: actions/cache@v6 - with: - path: | - C:\Program Files\gs - key: ${{ runner.os }}-imagick-ghostscript-${{ env.GS_VERSION }} - - - name: Install Ghostscript if not found - run: | - $gsBinDir = "C:\Program Files\gs\gs${{ env.GS_VERSION }}\bin" - echo "$gsBinDir" >> $env:GITHUB_PATH - $gsPath = "$gsBinDir\gswin64c.exe" - if (-not (Test-Path $gsPath)) { - choco install ghostscript -y --no-progress --version=${{ env.GS_VERSION }} - } - if (-not (Test-Path "$gsBinDir\gs.exe")) { - New-Item -ItemType SymbolicLink -Path "$gsBinDir\gs.exe" -Target $gsPath -Force - } - DIR "$gsBinDir" - - # Restore cache - - name: Restore cache - id: cache - uses: actions/cache/restore@v6 - env: - HASH: ${{ hashFiles('htdocs/install/**', 'htdocs/filefunc.inc.php', 'htdocs/version.inc.php') }} - KEY_ROOT: ${{ matrix.os }}-${{ env.ckey }}-${{ matrix.php_version }} - with: - # See https://github.com/actions/cache/issues/1275#issuecomment-1925217178 - enableCrossOsArchive: true - path: | - ./db_init.sql - ./db_init.sql.md5 - ./.cache/mariadb - key: ${{ env.KEY_ROOT }}-${{ env.HASH }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }} - restore-keys: | - ${{ env.KEY_ROOT }}-${{ env.HASH }}-${{ env.CACHE_KEY_PART }}- - ${{ env.KEY_ROOT }}-${{ env.HASH }}-${{ github.head_ref }}- - ${{ env.KEY_ROOT }}-${{ env.HASH }}-${{ github.base_ref }}- - ${{ env.KEY_ROOT }}-${{ env.HASH }}- - # ${{ env.KEY_ROOT }}- - - - name: Setup MariaDB - uses: frederic34/setup-mariadb@v1 - with: - # mariadb-version: ${{ matrix.mariadb-version }} - database: travis # Specify your database name - - - name: Create local php.ini with open_basedir restrictions - shell: cmd - # Objective: separate step, and before database initialisation to verify open_basedir restrictions - run: |- - echo "BASEDIR=%CD%" >> %GITHUB_ENV% - ECHO "==== Show INI file usage before our configuration ===" - php --ini - ECHO "==== Set PHP_INI_SCAN_DIR to include the INI File we create ===" - mkdir %PHP_INI_SCAN_DIR% - SET INIFILE="%PHP_INI_SCAN_DIR%\dolibarr.ini" - SET HTDOCS_DIR=%CD%\htdocs - SET DATA_DIR=%CD%\documents - SET TEST_DIR=%CD%\test - SET INITDEMO_DIR=%CD%\dev\initdemo - SET SESSION_DIR=%TEMP%\php_sessions - mkdir %SESSION_DIR% - ECHO "==== Create INI file to set open_basedir ===" - echo [php] > %INIFILE% - echo open_basedir^="%HTDOCS_DIR%;%DATA_DIR%;%TEST_DIR%;%INITDEMO_DIR%;%PHPROOT%;%SESSION_DIR%" >> %INIFILE% - echo session.save_path^="%SESSION_DIR%" >> %INIFILE% - REM Unset PHP_INI_SCAN_DIR to disable open_basedir restrictions (to limit debug effort) - REM SET PHP_INI_SCAN_DIR= - ECHO "==== Show contents of INI file to set open_basedir ===" - type %INIFILE% - ECHO "==== Verify it is used by PHP ===" - php --ini - REM TEST OPEN_BASEDIR restriction is not limiting wrongly - REM THE DATA_DIR MUST BE CREATED HERE - open_base does not allow it's creation - mkdir "%DATA_DIR%" - mkdir "%DATA_DIR%\mytest" - php -r "$d=implode(DIRECTORY_SEPARATOR,[__DIR__,'documents','mytest']);echo 'IS_DIR '.$d.' '.((int) is_dir($d)).PHP_EOL;" - php -r "$d=__DIR__.'\documents/mytest';echo 'TEST PATH IS SHOWN: '.$d.PHP_EOL;" - php -r "$d=__DIR__.'\documents/mytest';echo 'IS_DIR '.$d.' '.((int) is_dir($d)).PHP_EOL;" - ECHO "The above should show 2 successful tests" - - - name: Run Bash script that Initialises the database - # Note this is bash (MSYS) on Windows - shell: bash - run: | - # shellcheck disable=SC2129 - ECHO "#[group]Directory contents to verify cache files, ..." - ls -l - ECHO "#[endgroup]" - ECHO "==== Verify openbase_dir restriction" - php --ini - # Run bash script to initialise database - ECHO "==== Start 'setup_conf.sh' to setup database" - ${SHELL} -xv dev/setup/phpunit/setup_conf.sh - ## Updating test configuration to not stop on first failure (to see all errors) - need sed - sed -i -e 's/stopOnFailure="[^"]*"/stopOnFailure="false"/' test/phpunit/phpunittest.xml - ECHO "#[group]Directory contents after database setup to verify cache files, ..." - ls -l - ECHO "#[endgroup]" - # Export some tool paths to reuse the from CMD shell. - { - echo "TAIL=$(cygpath -w "$(which tail)")" - echo "GREP=$(cygpath -w "$(which grep)")" - echo "TEE=$(cygpath -w "$(which tee)")" - echo "BASEDIR=$(realpath .)" - } >> "$GITHUB_ENV" - - - name: Run PHPUnit tests - # continue-on-error: true - shell: cmd - # setting up php.ini, starting the php server are currently in this step - run: |- - ECHO "==== Visually verify our dolibarr.INI file usage ===" - php --ini - ECHO "==== Add our web server information to the config file ===" - echo $dolibarr_main_url_root="http://${{ env.PHPSERVER_DOMAIN_PORT }}"; >> htdocs/conf/conf.php - ECHO "#[group]==== Dolibarr config file contents" - cat htdocs/conf/conf.php - ECHO "#[endgroup]" - ECHO "==== START PHP server" - start /B php -S %PHPSERVER_DOMAIN_PORT% -t htdocs >> %PHPSERVER_LOG% 2>&1 - ECHO "#[group]==== Output from curl on PHP server" - curl "http://${{ env.PHPSERVER_DOMAIN_PORT }}" - ECHO "#[endgroup]" - ECHO "==== START PHPUNIT TESTS" - 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" --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/logToCheckStyle@v2026.8.2 - if: ${{ failure() }} - with: - in: ${{ env.PHPUNIT_LOG }} - - - name: Provide dolibarr and phpunit logs as artifact - uses: actions/upload-artifact@v7 - if: ${{ ! cancelled() }} - with: - name: win-ci-logs - path: | - ${{ env.PHPUNIT_LOG }} - ${{ env.DOLIBARR_LOG }} - ${{ env.PHPSERVER_LOG }} - db_init.sql - db_init.sql.md5 - retention-days: 2 - - # Save cache - - name: Save cache - uses: actions/cache/save@v6 - 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.sql - ./db_init.sql.md5 - ./.cache/mariadb