From 7a7b390f04eb1bf4dc7c4abbce69c6781ac8fb70 Mon Sep 17 00:00:00 2001
From: Bart Jaskulski <bjaskulski@protonmail.com>
Date: Tue, 7 Mar 2023 18:02:11 +0100
Subject: [PATCH] feat: skip tranlations for repository plugins

Maybe it would be better to split workflow for paid and free plugins
(and definitely for libraries), but for now it should be enough to skip
prepare translations job and mark it optional in other stages.

Translations for free plugins are handled by WordPress repository, thus
there's no need to keep this job. Essentially, most plugins targeting
WordPress repository doesn't have its own translation files either.

Signed-off-by: Bart Jaskulski <bjaskulski@protonmail.com>
---
 gitlab-ci-free.yml                      | 3 +++
 includes/deploy.yml                     | 3 ++-
 includes/prepare.yml                    | 9 +++++----
 includes/tests/codeception-parallel.yml | 3 ++-
 includes/tests/codeception.yml          | 3 ++-
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gitlab-ci-free.yml b/gitlab-ci-free.yml
index 8241c63..3052cbc 100644
--- a/gitlab-ci-free.yml
+++ b/gitlab-ci-free.yml
@@ -1,3 +1,6 @@
+variables:
+  WP_REPOSITORY: true
+
 include:
   - project: 'wpdesk/gitlab-ci'
     ref: 'master'
diff --git a/includes/deploy.yml b/includes/deploy.yml
index 56d4021..c8d195e 100644
--- a/includes/deploy.yml
+++ b/includes/deploy.yml
@@ -46,7 +46,8 @@ hooks docs refresh:
     - deploy
   needs:
     - prepare prefixed vendor
-    - prepare translations
+    - job: prepare translations
+      optional: true
     - job: prepare npm assets
       optional: true
   artifacts:
diff --git a/includes/prepare.yml b/includes/prepare.yml
index cb68b0f..58ac780 100644
--- a/includes/prepare.yml
+++ b/includes/prepare.yml
@@ -58,10 +58,11 @@ prepare translations:
   stage: prepare-translations-and-tests
   dependencies:
     - prepare prefixed vendor
-  except:
-    variables:
-      - $IS_LIBRARY
-      - $IS_NPM_LIBRARY
+  rules:
+    - if: $WP_REPOSITORY
+      when: never
+    - if: $IS_LIBRARY || $IS_NPM_LIBRARY
+      when: never
   interruptible: true
   script:
     - composer generate-pot
diff --git a/includes/tests/codeception-parallel.yml b/includes/tests/codeception-parallel.yml
index 5f45038..06cade2 100644
--- a/includes/tests/codeception-parallel.yml
+++ b/includes/tests/codeception-parallel.yml
@@ -7,7 +7,8 @@
     entrypoint: [""]
   needs:
     - prepare prefixed vendor
-    - prepare translations
+    - job: prepare translations
+      optional: true
     - job: prepare tests
       optional: true
     - job: prepare npm assets
diff --git a/includes/tests/codeception.yml b/includes/tests/codeception.yml
index d6480d4..d5a790d 100644
--- a/includes/tests/codeception.yml
+++ b/includes/tests/codeception.yml
@@ -30,7 +30,8 @@
   stage: tests
   needs:
     - prepare prefixed vendor
-    - prepare translations
+    - job: prepare translations
+      optional: true
     - job: prepare tests
       optional: true
     - job: prepare npm assets
-- 
GitLab