Conversation
Rom1-B
left a comment
There was a problem hiding this comment.
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?
Rom1-B
left a comment
There was a problem hiding this comment.
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?
|
The job use |
There was a problem hiding this comment.
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"Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
ca25384 to
aa42649
Compare
|
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 |
This PR is aimed to use the native core tools that will be release soon (Migrate glpi-project/tools to core glpi#22465)
For now I have created an image based on the branch so we can test.
This should tested once Migrate glpi-project/tools to core glpi#22465 is officially merged
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