From 5674fcc0b0c009739fd89692c4dcdfb0eef8f49f Mon Sep 17 00:00:00 2001 From: Jennifer Li <jli@gitlab.com> Date: Mon, 3 Mar 2025 18:09:58 -0800 Subject: [PATCH] Run puma config test jobs with custom exit code --- .gitlab/ci/preflight.gitlab-ci.yml | 40 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/.gitlab/ci/preflight.gitlab-ci.yml b/.gitlab/ci/preflight.gitlab-ci.yml index de99c5c734b49..4d8ee13929f61 100644 --- a/.gitlab/ci/preflight.gitlab-ci.yml +++ b/.gitlab/ci/preflight.gitlab-ci.yml @@ -36,13 +36,18 @@ rails-production-server-boot-puma-example: extends: - .rails-production-server-boot script: - - cp config/puma.rb.example config/puma.rb - - sed --in-place "s:/home/git/gitlab:${PWD}:" config/puma.rb - - echo 'bind "tcp://127.0.0.1:3000"' >> config/puma.rb - - bundle exec puma --environment production --config config/puma.rb & - - sleep 50 # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/114124#note_1309506358 - - retry_times_sleep 10 5 "curl http://127.0.0.1:3000" - - kill $(jobs -p) + - | + function test_puma_config_example() { + cp config/puma.rb.example config/puma.rb + sed --in-place "s:/home/git/gitlab:${PWD}:" config/puma.rb + echo 'bind "tcp://127.0.0.1:3000"' >> config/puma.rb + bundle exec puma --environment production --config config/puma.rb & + sleep 50 # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/114124#note_1309506358 + retry_times_sleep 10 5 "curl http://127.0.0.1:3000" + kill $(jobs -p) + } + + run_with_custom_exit_code test_puma_config_example # Test the puma configuration present in # https://gitlab.com/gitlab-org/build/CNG/-/raw/master/gitlab-webservice/configuration/puma.rb @@ -50,14 +55,19 @@ rails-production-server-boot-puma-cng: extends: - .rails-production-server-boot script: - - define_trigger_branch_in_build_env - - echo "TRIGGER_BRANCH is defined as ${TRIGGER_BRANCH}" - - curl --silent "https://gitlab.com/gitlab-org/build/CNG/-/raw/${TRIGGER_BRANCH}/gitlab-webservice/configuration/puma.rb" > config/puma.rb - - sed --in-place "s:/srv/gitlab:${PWD}:" config/puma.rb - - bundle exec puma --environment production --config config/puma.rb & - - sleep 50 # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/114124#note_1309506358 - - retry_times_sleep 10 5 "curl http://127.0.0.1:8080" - - kill $(jobs -p) + - | + function test_puma_config_cng() { + define_trigger_branch_in_build_env + echo "TRIGGER_BRANCH is defined as ${TRIGGER_BRANCH}" + curl --silent "https://gitlab.com/gitlab-org/build/CNG/-/raw/${TRIGGER_BRANCH}/gitlab-webservice/configuration/puma.rb" > config/puma.rb + sed --in-place "s:/srv/gitlab:${PWD}:" config/puma.rb + bundle exec puma --environment production --config config/puma.rb & + sleep 50 # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/114124#note_1309506358 + retry_times_sleep 10 5 "curl http://127.0.0.1:8080" + kill $(jobs -p) + } + + run_with_custom_exit_code test_puma_config_cng ruby_syntax: extends: -- GitLab