From 9da9b25b4069177c831c87a7b4a558cfbaa8ccde Mon Sep 17 00:00:00 2001
From: Sebastian Mohr <sebastian@mohrenclan.de>
Date: Wed, 15 Jan 2025 14:07:54 +0100
Subject: [PATCH] Removed build stage in favor for publish stage as test should
 run without build.

---
 .gitlab/packages.yml | 42 ++++++++++++++++++------------------------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/.gitlab/packages.yml b/.gitlab/packages.yml
index e8fbea80..7e2ccb7b 100644
--- a/.gitlab/packages.yml
+++ b/.gitlab/packages.yml
@@ -12,27 +12,26 @@ cache: &pnpm_cache
 ## Snips package
 ######################################
 
-build:packages:snips:
+test:packages:snips:
     image: node:22-alpine
-    stage: build
+    stage: test
     cache:
         <<: *pnpm_cache
     before_script:
         # Install corepack and pnpm
-        - apk add --no-cache curl build-base
-        - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
-        - source $HOME/.cargo/env
         - corepack enable
         - corepack prepare pnpm@latest-9 --activate
         - pnpm config set store-dir .pnpm-store
         - pnpm install --frozen-lockfile
     script:
-        # Build the package
-        - echo "Building @snip/snips"
-        - pnpm --filter snips... build
-        # TODO: publish to local registry
+        # Run the tests
+        - echo "Running tests for @snip/snips"
+        - pnpm --filter snips test
     tags:
         - docker
+    dependencies:
+        # Build artifacts from previous stages
+        - build:packages:snips
     rules:
         - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
           changes:
@@ -40,35 +39,30 @@ build:packages:snips:
         - when: on_failure
         - when: manual
 
-test:packages:snips:
+publish:packages:snips:
     image: node:22-alpine
     stage: publish
     cache:
         <<: *pnpm_cache
     before_script:
         # Install corepack and pnpm
+        - apk add --no-cache curl build-base
+        - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
+        - source $HOME/.cargo/env
         - corepack enable
         - corepack prepare pnpm@latest-9 --activate
         - pnpm config set store-dir .pnpm-store
         - pnpm install --frozen-lockfile
-    script:
-        # Run the tests
-        - echo "Running tests for @snip/snips"
-        - pnpm --filter snips test
-    tags:
-        - docker
-    dependencies:
-        # Build artifacts from previous stages
-        - build:packages:snips
-    needs: ["build:packages:snips"]
-
-publish:packages:snips:
-    before_script:
         - pnpm config set @scope:registry https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/
         - pnpm config set -- //${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken ${CI_JOB_TOKEN}
-    needs: ["build:packages:snips", "test:packages:snips"]
     script:
+        # Build the package
+        - echo "Building @snip/snips"
+        - pnpm --filter snips... build
         - pnpm --filter snips publish
+    tags:
+        - docker
+    needs: ["test:packages:snips"]
 
 build:packages:config:
     image: node:22-alpine
-- 
GitLab