Skip to content

Commit

Permalink
Merge pull request #723 from degica/better-error
Browse files Browse the repository at this point in the history
Better branch name error
  • Loading branch information
pmq20 authored May 23, 2022
2 parents 13b02b7 + c314809 commit 5f84a7d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/build-reverse-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-run-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-wazuh-kibana-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-wazuh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion app/models/review_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: '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}

before_validation :build_heritage
Expand Down
26 changes: 26 additions & 0 deletions spec/models/review_app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5f84a7d

Please sign in to comment.