From 0f04117b3f3147eddd8ac11f0b03ff9f16eba3d1 Mon Sep 17 00:00:00 2001 From: David Siaw Date: Fri, 20 May 2022 17:21:10 +0900 Subject: [PATCH 1/3] better branch name error --- app/models/review_app.rb | 6 +++++- spec/models/review_app_spec.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/models/review_app.rb b/app/models/review_app.rb index a1519f22..3148428f 100644 --- a/app/models/review_app.rb +++ b/app/models/review_app.rb @@ -4,7 +4,11 @@ class ReviewApp < ApplicationRecord attr_accessor :image_name, :image_tag, :services, :before_deploy, :environment validates :subject, :image_name, :image_tag, :retention, :services, presence: true - validates :subject, format: {with: /\A[a-z0-9][a-z0-9(-|_)]*[a-z0-9]\z/} + validates :subject, format: { + with: /\A[a-z0-9][a-z0-9(-|_)]*[a-z0-9]\z/, + message: 'must only contain lowercase characters, numbers and hyphens, and can only start and end with a letter or a number' + } + validates :retention, numericality: {greater_than: 0, less_than: 24 * 3600 * 30} before_validation :build_heritage diff --git a/spec/models/review_app_spec.rb b/spec/models/review_app_spec.rb index 622dbbcf..60cf0e0a 100644 --- a/spec/models/review_app_spec.rb +++ b/spec/models/review_app_spec.rb @@ -96,5 +96,31 @@ expect(review_app.heritage.services[0].listeners[0].health_check_path).to eq "/healthcheck" end end + + context "when a service has capital letters" do + let(:review_app) { + group.review_apps.new( + subject: "SUBJECT", + image_name: "image", + image_tag: "tag", + retention: 12 * 3600, + before_deploy: "true", + environment: [], + services: [{ + name: "review", + command: "true", + service_type: "web", + listeners: [{ + health_check_path: "/healthcheck", + health_check_interval: 300 + }] + }]) + } + + it "preserves configurations" do + expect(review_app).to_not be_valid + expect(review_app.errors[:subject]).to eq(["branch name must only contain lowercase characters, numbers and hyphens, and can only start and end with a letter or a number"]) + end + end end end From 79bc19f03eed455f7c1e4c0e0dc90353363c4be1 Mon Sep 17 00:00:00 2001 From: David Siaw Date: Fri, 20 May 2022 17:37:44 +0900 Subject: [PATCH 2/3] workaround github ci issue --- .github/workflows/build-reverse-proxy.yml | 2 ++ .github/workflows/build-run-pack.yml | 2 ++ .github/workflows/build-wazuh-kibana-proxy.yml | 2 ++ .github/workflows/build-wazuh.yml | 2 ++ .github/workflows/build.yml | 2 ++ .github/workflows/test.yml | 2 ++ 6 files changed, 12 insertions(+) diff --git a/.github/workflows/build-reverse-proxy.yml b/.github/workflows/build-reverse-proxy.yml index be505d87..ecb03171 100644 --- a/.github/workflows/build-reverse-proxy.yml +++ b/.github/workflows/build-reverse-proxy.yml @@ -25,6 +25,8 @@ jobs: AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} runs-on: ubuntu-18.04 steps: + - name: workaround + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: prepare run: |- apk add --no-cache python3 py3-pip diff --git a/.github/workflows/build-run-pack.yml b/.github/workflows/build-run-pack.yml index d8853faa..f89f889e 100644 --- a/.github/workflows/build-run-pack.yml +++ b/.github/workflows/build-run-pack.yml @@ -11,6 +11,8 @@ jobs: AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} runs-on: ubuntu-18.04 steps: + - name: workaround + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: prepare run: |- apk add --no-cache python3 py3-pip diff --git a/.github/workflows/build-wazuh-kibana-proxy.yml b/.github/workflows/build-wazuh-kibana-proxy.yml index fd05387d..ebc11341 100644 --- a/.github/workflows/build-wazuh-kibana-proxy.yml +++ b/.github/workflows/build-wazuh-kibana-proxy.yml @@ -11,6 +11,8 @@ jobs: AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} runs-on: ubuntu-18.04 steps: + - name: workaround + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: prepare run: |- apk add --no-cache python3 py3-pip diff --git a/.github/workflows/build-wazuh.yml b/.github/workflows/build-wazuh.yml index c8243227..0ba6bc60 100644 --- a/.github/workflows/build-wazuh.yml +++ b/.github/workflows/build-wazuh.yml @@ -11,6 +11,8 @@ jobs: AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} runs-on: ubuntu-18.04 steps: + - name: workaround + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: prepare run: |- apk add --no-cache python3 py3-pip diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7657c130..8e13fdfd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,8 @@ jobs: DOCKER_BUILDKIT: '1' runs-on: ubuntu-18.04 steps: + - name: workaround + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: prepare run: |- apk add --no-cache python3 py3-pip diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e32dc34..342d304a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,8 @@ jobs: ENCRYPTION_KEY: abcdefghijklmn runs-on: ubuntu-18.04 steps: + - name: workaround + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - uses: actions/checkout@v2 - name: before_install run: bundle install From c3148093b5086f8523a7a64782848631d76ed13f Mon Sep 17 00:00:00 2001 From: David Siaw Date: Fri, 20 May 2022 17:40:58 +0900 Subject: [PATCH 3/3] fix test --- app/models/review_app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/review_app.rb b/app/models/review_app.rb index 3148428f..f3bfdca4 100644 --- a/app/models/review_app.rb +++ b/app/models/review_app.rb @@ -6,7 +6,7 @@ class ReviewApp < ApplicationRecord validates :subject, :image_name, :image_tag, :retention, :services, presence: true validates :subject, format: { with: /\A[a-z0-9][a-z0-9(-|_)]*[a-z0-9]\z/, - message: 'must only contain lowercase characters, numbers and hyphens, and can only start and end with a letter or a number' + message: 'branch name must only contain lowercase characters, numbers and hyphens, and can only start and end with a letter or a number' } validates :retention, numericality: {greater_than: 0, less_than: 24 * 3600 * 30}