Make integration test app to deploy configurable

This commit is contained in:
Donal McBreen
2024-03-21 12:09:59 +00:00
parent 474b76cf47
commit ba40d026d0
4 changed files with 17 additions and 8 deletions

View File

@@ -50,6 +50,13 @@ services:
volumes:
- shared:/shared
vm3:
privileged: true
build:
context: docker/vm
volumes:
- shared:/shared
load_balancer:
build:
context: docker/load_balancer

View File

@@ -1,6 +1,6 @@
FROM ruby:3.2
WORKDIR /app
WORKDIR /
ENV VERBOSE=true
@@ -17,7 +17,7 @@ RUN echo \
RUN apt-get update --fix-missing && apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
COPY *.sh .
COPY app/ .
COPY app/ app/
RUN rm -rf /root/.ssh
RUN ln -s /shared/ssh /root/.ssh
@@ -25,7 +25,7 @@ RUN mkdir -p /etc/docker/certs.d/registry:4443 && ln -s /shared/certs/domain.crt
RUN git config --global user.email "deployer@example.com"
RUN git config --global user.name "Deployer"
RUN git init && echo ".env" >> .gitignore && git add . && git commit -am "Initial version"
RUN cd app && git init && echo ".env" >> .gitignore && git add . && git commit -am "Initial version"
HEALTHCHECK --interval=1s CMD pgrep sleep

View File

@@ -1,3 +1,3 @@
#!/bin/bash
git commit -am 'Update rev' --amend
cd $1 && git commit -am 'Update rev' --amend

View File

@@ -7,6 +7,7 @@ class IntegrationTest < ActiveSupport::TestCase
docker_compose "up --build -d"
wait_for_healthy
setup_deployer
@app = "app"
end
teardown do
@@ -34,8 +35,9 @@ class IntegrationTest < ActiveSupport::TestCase
result
end
def deployer_exec(*commands, **options)
docker_compose("exec deployer #{commands.join(" ")}", **options)
def deployer_exec(*commands, workdir: nil, **options)
workdir ||= "/#{@app}"
docker_compose("exec --workdir #{workdir} deployer #{commands.join(" ")}", **options)
end
def kamal(*commands, **options)
@@ -72,7 +74,7 @@ class IntegrationTest < ActiveSupport::TestCase
end
def update_app_rev
deployer_exec "./update_app_rev.sh"
deployer_exec "./update_app_rev.sh #{@app}", workdir: "/"
latest_app_version
end
@@ -115,7 +117,7 @@ class IntegrationTest < ActiveSupport::TestCase
end
def setup_deployer
deployer_exec("./setup.sh") unless $DEPLOYER_SETUP
deployer_exec("./setup.sh", workdir: "/") unless $DEPLOYER_SETUP
$DEPLOYER_SETUP = true
end