From 500bce48833b50cef7d04649be3e691fbd713699 Mon Sep 17 00:00:00 2001 From: Bart Jaskulski <bjaskulski@protonmail.com> Date: Tue, 26 Nov 2024 13:00:14 +0100 Subject: [PATCH] feat: authorize composer globally Sometimes, tests may require own dependencies to be pulled from authorized packagist endpoint (gitlab.wpdesk.dev), and authorizing only project-wide is not enough in such cases, leading to missing auth, like observed in one of CI jobs[^1] [1]: https://gitlab.wpdesk.dev/wpdesk/heroes/flexible-coupons-shortcodes/-/jobs/1185412#L59 Signed-off-by: Bart Jaskulski <bjaskulski@protonmail.com> --- gitlab-ci-1.2.yml | 3 ++- includes/deploy.yml | 4 ++-- includes/mixins/.composer-auth.yml | 3 +++ includes/prepare.yml | 4 ++-- includes/tests/codeception-integration.yml | 2 +- includes/tests/codeception-parallel.yml | 2 +- includes/tests/codeception.yml | 2 +- includes/tests/lint.yml | 2 +- 8 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 includes/mixins/.composer-auth.yml diff --git a/gitlab-ci-1.2.yml b/gitlab-ci-1.2.yml index 234a43a..968b3ad 100644 --- a/gitlab-ci-1.2.yml +++ b/gitlab-ci-1.2.yml @@ -1,5 +1,5 @@ variables: - WPDESK_CI_VERSION: "2024.11.19" + WPDESK_CI_VERSION: "2024.11.26" MYSQL_ROOT_PASSWORD: "mysql" MYSQL_DATABASE: "wptest" MYSQL_USER: "mysql" @@ -39,4 +39,5 @@ include: - '/includes/tests/integration.yml' - '/includes/deploy.yml' - '/includes/mixins/.after-codeception.yml' + - '/includes/mixins/.composer-auth.yml' - '/includes/mixins/.skip-mr.yml' diff --git a/includes/deploy.yml b/includes/deploy.yml index 78b918d..14f5735 100644 --- a/includes/deploy.yml +++ b/includes/deploy.yml @@ -27,7 +27,7 @@ - release - release.zip before_script: - - composer config gitlab-token.gitlab.wpdesk.dev gitlab-ci-token ${CI_JOB_TOKEN} + - !reference [.composer-auth, script] script: - echo ${WPDESK_CI_VERSION} - php --version @@ -285,7 +285,7 @@ library: paths: - wp-desk before_script: - - composer config gitlab-token.gitlab.wpdesk.dev gitlab-ci-token ${CI_JOB_TOKEN} + - !reference [.composer-auth, script] script: - rm -rf ${CI_PROJECT_DIR}/wp-desk - mkdir -p /tmp/wp-desk diff --git a/includes/mixins/.composer-auth.yml b/includes/mixins/.composer-auth.yml new file mode 100644 index 0000000..ebf5318 --- /dev/null +++ b/includes/mixins/.composer-auth.yml @@ -0,0 +1,3 @@ +.composer-auth: + script: + - composer global config gitlab-token.gitlab.wpdesk.dev gitlab-ci-token ${CI_JOB_TOKEN} diff --git a/includes/prepare.yml b/includes/prepare.yml index 1f78e7d..294b160 100644 --- a/includes/prepare.yml +++ b/includes/prepare.yml @@ -16,7 +16,7 @@ prepare prefixed vendor: - $IS_NPM_LIBRARY interruptible: true before_script: - - composer config gitlab-token.gitlab.wpdesk.dev gitlab-ci-token ${CI_JOB_TOKEN} + - !reference [.composer-auth, script] - echo ${WPDESK_CI_VERSION} - php --version script: @@ -83,7 +83,7 @@ prepare tests: interruptible: true before_script: - cp /usr/local/bin/clone /tmp/clone.sh - - composer config gitlab-token.gitlab.wpdesk.dev gitlab-ci-token ${CI_JOB_TOKEN} + - !reference [.composer-auth, script] - echo ${WPDESK_CI_VERSION} - php --version script: diff --git a/includes/tests/codeception-integration.yml b/includes/tests/codeception-integration.yml index 486e53f..413212b 100644 --- a/includes/tests/codeception-integration.yml +++ b/includes/tests/codeception-integration.yml @@ -50,7 +50,7 @@ integration codeception tests: - mkdir -p ${APACHE_DOCUMENT_ROOT} - cd ${APACHE_DOCUMENT_ROOT} - cd ${CI_PROJECT_DIR} - - composer config gitlab-token.gitlab.wpdesk.dev gitlab-ci-token ${CI_JOB_TOKEN} + - !reference [.composer-auth, script] - composer prepare-wordpress-for-codeception - composer prepare-local-codeception-tests - chmod -R a+w ${APACHE_DOCUMENT_ROOT}/wp-content/uploads diff --git a/includes/tests/codeception-parallel.yml b/includes/tests/codeception-parallel.yml index b798fdf..14bcfe0 100644 --- a/includes/tests/codeception-parallel.yml +++ b/includes/tests/codeception-parallel.yml @@ -35,7 +35,7 @@ prepare codeception parallel: allow_failure: false interruptible: true before_script: - - composer config gitlab-token.gitlab.wpdesk.dev gitlab-ci-token ${CI_JOB_TOKEN} + - !reference [.composer-auth, script] - echo ${WPDESK_CI_VERSION} - php --version script: diff --git a/includes/tests/codeception.yml b/includes/tests/codeception.yml index fe83faf..4d1fee1 100644 --- a/includes/tests/codeception.yml +++ b/includes/tests/codeception.yml @@ -43,7 +43,7 @@ allow_failure: false interruptible: true before_script: - - composer config gitlab-token.gitlab.wpdesk.dev gitlab-ci-token ${CI_JOB_TOKEN} + - !reference [.composer-auth, script] - echo "xdebug.max_nesting_level=2560" >> /usr/local/etc/php/php.ini - mkdir -p /cache/wp-cli - mkdir -p /project diff --git a/includes/tests/lint.yml b/includes/tests/lint.yml index af0a8ba..a3a7b84 100644 --- a/includes/tests/lint.yml +++ b/includes/tests/lint.yml @@ -4,7 +4,7 @@ lint: - prepare prefixed vendor stage: tests before_script: - - composer config gitlab-token.gitlab.wpdesk.dev gitlab-ci-token ${CI_JOB_TOKEN} + - !reference [.composer-auth, script] - composer install --no-dev - rm auth.json - phive install -g https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/download/v1.4.0/parallel-lint.phar --force-accept-unsigned -- GitLab