Skip to content

Switch to GLPI core tools - #9

Open
froozeify wants to merge 8 commits into
glpi-project:v1from
froozeify:switch-to-core-tools
Open

froozeify wants to merge 8 commits into
glpi-project:v1from
froozeify:switch-to-core-tools

Conversation

@froozeify

@froozeify froozeify commented Jan 27, 2026 •

Copy link
Copy Markdown
Member

I have tested with mreporting plugin (fork)

CI : https://github.com/froozeify/GLPI_plugin_mreporting/actions/runs/21402755512
Generated PR : froozeify/GLPI_plugin_mreporting#1


August re-run

CI : https://github.com/froozeify/GLPI_plugin_mreporting/actions/runs/30888156017
Generated PR : froozeify/GLPI_plugin_mreporting#3

@froozeify
froozeify marked this pull request as ready for review August 4, 2026 07:46
@froozeify
froozeify requested review from Rom1-B and trasher August 4, 2026 07:46

@Rom1-B Rom1-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on php bin/console tools:locales:extract/tools:locales:compile, which only exist in the still-unmerged glpi-project/glpi#22465, and on a container image described in the PR body as "based on the branch so we can test" (not a stable released image). Since consumers reference this repo as @v1, which is a branch, not an immutable tag, merging this now would break every existing consumer's CI on their very next run, before core support ships. Should this land on a new branch/major version (e.g. v2) instead, and only be pointed at from @v1 once glpi-project/glpi#22465 is merged and the image is a stable release?

Comment thread .github/workflows/transifex-sync.yml Outdated
@froozeify
froozeify requested review from Rom1-B and removed request for trasher August 4, 2026 08:39

@Rom1-B Rom1-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, answer:

This depends on php bin/console tools:locales:extract/tools:locales:compile, which only exist in the still-unmerged glpi-project/glpi#22465, and on a container image described in the PR body as "based on the branch so we can test" (not a stable released image). Since consumers reference this repo as @v1, which is a branch, not an immutable tag, merging this now would break every existing consumer's CI on their very next run, before core support ships. Should this land on a new branch/major version (e.g. v2) instead, and only be pointed at from @v1 once glpi-project/glpi#22465 is merged and the image is a stable release?

@froozeify

Copy link
Copy Markdown
Member Author

glpi-project/glpi#22465 has been merged in February.

The job use ghcr.io/glpi-project/githubactions-glpi-apache:latest as a based image so it have access to the glpi tools, no need for a v2

@froozeify
froozeify requested a review from Rom1-B August 12, 2026 11:34

@Rom1-B Rom1-B left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The container setup, plugin-key extraction, checkout, and symlink steps (transifex-push-sources.yml lines 13-44, transifex-sync.yml lines 15-46) are duplicated verbatim across both workflow files. Worth extracting into a shared composite action to avoid the two copies drifting apart on the next change?

diff --git a/.github/actions/setup-glpi-plugin/action.yml b/.github/actions/setup-glpi-plugin/action.yml
new file mode 100644
index 0000000..38141c2
--- /dev/null
+++ b/.github/actions/setup-glpi-plugin/action.yml
@@ -0,0 +1,42 @@
+name: "Setup GLPI plugin"
+description: "Checks out the plugin and links it into the GLPI container image, exposing its plugin key"
+
+outputs:
+  plugin-key:
+    description: "Plugin key extracted from setup.php"
+    value: "${{ steps.get-plugin-key.outputs.plugin-key }}"
+
+runs:
+  using: "composite"
+  steps:
+    - name: "Checkout setup.php"
+      uses: "actions/checkout@v7"
+      with:
+        sparse-checkout: setup.php
+        path: tmp_setup
+
+    - name: "Get Plugin Key"
+      id: "get-plugin-key"
+      shell: "bash"
+      run: |
+        PLUGIN_KEY=$(sed --quiet 's/.*function plugin_version_\([a-z0-9_]\+\).*/\1/p' tmp_setup/setup.php | head --lines=1)
+        if [ -z "$PLUGIN_KEY" ]; then
+          echo "Could not extract plugin key from setup.php"
+          exit 1
+        fi
+        echo "PLUGIN_KEY=$PLUGIN_KEY" >> $GITHUB_ENV
+        echo "plugin-key=$PLUGIN_KEY" >> $GITHUB_OUTPUT
+
+    - name: "Checkout Plugin"
+      uses: "actions/checkout@v7"
+
+    - name: "Link Plugin to GLPI"
+      shell: "bash"
+      run: |
+        sudo ln -s $GITHUB_WORKSPACE /var/www/glpi/plugins/$PLUGIN_KEY
+        # Fix permissions for logs and other writable dirs
+        # Open the whole tree for writing so any tool (present or future) can write wherever it needs to.
+        sudo mkdir -p /var/www/glpi/tests/files/_log
+        sudo chmod -R a+rwX /var/www/glpi/
+        # Ensure git trusts the directory
+        git config --global --add safe.directory '*'
diff --git a/.github/workflows/transifex-push-sources.yml b/.github/workflows/transifex-push-sources.yml
index 76d9d46..6462357 100644
--- a/.github/workflows/transifex-push-sources.yml
+++ b/.github/workflows/transifex-push-sources.yml
@@ -15,38 +15,14 @@ jobs:
       options: --user 1001 # using built-in image user, otherwise GitHub Actions can't write file to the container
     steps:
 
-    - name: "Checkout setup.php"
-      uses: "actions/checkout@v7"
-      with:
-        sparse-checkout: setup.php
-        path: tmp_setup
-
-    - name: "Get Plugin Key"
-      run: |
-        PLUGIN_KEY=$(sed --quiet 's/.*function plugin_version_\([a-z0-9_]\+\).*/\1/p' tmp_setup/setup.php | head --lines=1)
-        if [ -z "$PLUGIN_KEY" ]; then
-          echo "Could not extract plugin key from setup.php"
-          exit 1
-        fi
-        echo "PLUGIN_KEY=$PLUGIN_KEY" >> $GITHUB_ENV
-
-    - name: "Checkout Plugin"
-      uses: "actions/checkout@v7"
-
-    - name: "Link Plugin to GLPI"
-      run: |
-        sudo ln -s $GITHUB_WORKSPACE /var/www/glpi/plugins/$PLUGIN_KEY
-        # Fix permissions for logs and other writable dirs
-        # Open the whole tree for writing so any tool (present or future) can write wherever it needs to.
-        sudo mkdir -p /var/www/glpi/tests/files/_log
-        sudo chmod -R a+rwX /var/www/glpi/
-        # Ensure git trusts the directory
-        git config --global --add safe.directory '*'
+    - name: "Setup GLPI plugin"
+      id: "setup-glpi-plugin"
+      uses: "glpi-project/plugin-translation-workflows/.github/actions/setup-glpi-plugin@v1"
 
     - name: "Extract locales"
       working-directory: /var/www/glpi/
       run: |
-        php bin/console tools:locales:extract --plugin=$PLUGIN_KEY
+        php bin/console tools:locales:extract --plugin=${{ steps.setup-glpi-plugin.outputs.plugin-key }}
 
     - name: "Push source file"
       uses: "transifex/cli-action@v2"
diff --git a/.github/workflows/transifex-sync.yml b/.github/workflows/transifex-sync.yml
index b6c2426..62ee8a8 100644
--- a/.github/workflows/transifex-sync.yml
+++ b/.github/workflows/transifex-sync.yml
@@ -17,38 +17,14 @@ jobs:
       options: --user 1001 # using built-in image user, otherwise GitHub Actions can't write file to the container
     steps:
 
-    - name: "Checkout setup.php"
-      uses: "actions/checkout@v7"
-      with:
-        sparse-checkout: setup.php
-        path: tmp_setup
-
-    - name: "Get Plugin Key"
-      run: |
-        PLUGIN_KEY=$(sed --quiet 's/.*function plugin_version_\([a-z0-9_]\+\).*/\1/p' tmp_setup/setup.php | head --lines=1)
-        if [ -z "$PLUGIN_KEY" ]; then
-          echo "Could not extract plugin key from setup.php"
-          exit 1
-        fi
-        echo "PLUGIN_KEY=$PLUGIN_KEY" >> $GITHUB_ENV
-
-    - name: "Checkout Plugin"
-      uses: "actions/checkout@v7"
-
-    - name: "Link Plugin to GLPI"
-      run: |
-        sudo ln -s $GITHUB_WORKSPACE /var/www/glpi/plugins/$PLUGIN_KEY
-        # Fix permissions for logs and other writable dirs
-        # Open the whole tree for writing so any tool (present or future) can write wherever it needs to.
-        sudo mkdir -p /var/www/glpi/tests/files/_log
-        sudo chmod -R a+rwX /var/www/glpi/
-        # Ensure git trusts the directory
-        git config --global --add safe.directory '*'
+    - name: "Setup GLPI plugin"
+      id: "setup-glpi-plugin"
+      uses: "glpi-project/plugin-translation-workflows/.github/actions/setup-glpi-plugin@v1"
 
     - name: "Extract locales"
       working-directory: /var/www/glpi/
       run: |
-        php bin/console tools:locales:extract --plugin=$PLUGIN_KEY
+        php bin/console tools:locales:extract --plugin=${{ steps.setup-glpi-plugin.outputs.plugin-key }}
 
     - name: "Push source file"
       uses: "transifex/cli-action@v2"
@@ -69,12 +45,7 @@ jobs:
     - name: "Compile MO files"
       working-directory: /var/www/glpi/
       run: |
-        php bin/console tools:locales:compile --plugin=$PLUGIN_KEY
-
-    - name: "Debug git status"
-      run: |
-        ls -la locales/
-        git status -u
+        php bin/console tools:locales:compile --plugin=${{ steps.setup-glpi-plugin.outputs.plugin-key }}
 
     - name: "Check status"
       id: "check-status"

@froozeify

froozeify commented Sep 30, 2026 •

Copy link
Copy Markdown
Member Author

Rebased and create the reusable action (the PR will only work once merged into v1 branch so)

Can test by creating a fork editing the @v1 to your branch and then making a plugin use it

@froozeify
froozeify requested a review from Rom1-B September 30, 2026 12:43
@froozeify

Copy link
Copy Markdown
Member Author

@Rom1-B
Rom1-B requested a review from stonebuzz October 2, 2026 07:49

@stonebuzz stonebuzz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants