Skip to content
Snippets Groups Projects
Commit be488afd authored by andrejs's avatar andrejs :flag_lv:
Browse files

Add ability to start full dev setup manually

Separate container node_modules and tmp folders

Add ability to bypass container orchestration

changelog: chore
parent d5cacf17
No related branches found
No related tags found
1 merge request!2671Add ability to start full dev setup manually
......@@ -10,7 +10,9 @@
"extensions": [
"castwide.solargraph",
"shopify.ruby-lsp",
"ms-azuretools.vscode-docker"
"ms-azuretools.vscode-docker",
"ms-playwright.playwright",
"kaiwood.endwise"
],
"settings": {
"terminal.integrated.profiles.linux": {
......
......@@ -38,7 +38,9 @@ services:
MOCK_HOST: smocker
GITLAB_URL: http://smocker:8080
DISABLE_SIDEKIQ_ALIVE: "true"
WITH_SERVICE: ${WITH_SERVICE:-false}
SETTINGS__GITLAB_URL: http://smocker:8080
SETTINGS__DEPENDABOT_URL: http://dependabot-gitlab.com
SETTINGS__GITLAB_ACCESS_TOKEN: ${SETTINGS__GITLAB_ACCESS_TOKEN:-dev}
SETTINGS__GITHUB_ACCESS_TOKEN: ${SETTINGS__GITHUB_ACCESS_TOKEN}
ports:
......@@ -46,11 +48,13 @@ services:
volumes:
- ..:/home/dependabot/app
- browsers:/home/dependabot/.cache/ms-playwright
- npm:/home/dependabot/.cache/npm
command: bundle exec solargraph socket
- npm:/home/dependabot/app/node_modules
- tmp:/home/dependabot/app/tmp
command: /home/dependabot/app/.devcontainer/entrypoint.sh
volumes:
redis-data:
mongodb-data:
browsers:
npm:
tmp:
#!/bin/bash
set -e
if [ "${WITH_SERVICE}" == "true" ]; then
. "$(dirname "$0")/setup.sh" "$PWD"
. "${APP_START_SCRIPT}" "tail"
else
bundle exec solargraph socket
fi
#!/bin/bash
set -e
workspace=$1
source "${workspace}/.gitlab/script/utils.sh"
......@@ -7,11 +9,19 @@ source "${workspace}/.gitlab/script/utils.sh"
bash ${workspace}/.gitlab/script/build-core-helpers.sh bundler
echo ""
log_with_header "Update npm packages"
npm install
log_success "success!"
echo ""
log_with_header "Install browsers"
npx playwright install
log_success "success!"
echo ""
log_with_header "Update npm packages"
npm ci --cache ${HOME}/.cache/npm
log_with_header "Setup database"
bundle exec rake db:create_indexes
log_success "success!"
echo ""
log_success "Setup completed! To start web server and sidekiq process, run 'start_app' command in the terminal."
......@@ -49,6 +49,22 @@ Following prerequisites are required to run tests locally:
- Running instance of mongodb (by default on `mongodb://localhost:27017`)
- Running instance of redis (by default on `redis://localhost:6379`)
### Docker Compose
It is possible to start fully functional test environment via `docker compose`. Environment exposes web page on port `3000`. This environment is most useful for running e2e tests.
To start environment, run following command:
```bash
bin/dev-env start
```
To stop environment, run following command:
```bash
bin/dev-env stop
```
### Devcontainer
This is prefered way for running system tests (`bundle exec rspec --tag system`) and E2E tests (`npm run e2e:test`).
......
......@@ -57,15 +57,19 @@ RUN set -eux; \
mkdir -p ${HOME}/log && \
echo "#!/bin/bash" > ${APP_START_SCRIPT} && \
echo "set -e" >> ${APP_START_SCRIPT} && \
echo "bundle exec sidekiq > ${HOME}/log/sidekiq.log 2>&1 &" >> ${APP_START_SCRIPT} && \
echo "bundle exec rails server > ${HOME}/log/puma.log 2>&1 &" >> ${APP_START_SCRIPT} && \
echo "sleep 5 && echo \"Started dependabot-giltab! Logging to '${HOME}/log' directory.\"" >> ${APP_START_SCRIPT} && \
echo "rm -rf ${CODE_DIR}/tmp/pids/server.pid" >> ${APP_START_SCRIPT} && \
echo "bundle exec sidekiq > ${CODE_DIR}/log/sidekiq.log 2>&1 &" >> ${APP_START_SCRIPT} && \
echo "bundle exec rails server > ${CODE_DIR}/log/puma.log 2>&1 &" >> ${APP_START_SCRIPT} && \
echo "sleep 5 && echo \"Started dependabot-giltab! Logging to '${CODE_DIR}/log' directory.\"" >> ${APP_START_SCRIPT} && \
echo "[ \"\${1}\" == \"tail\" ] && tail -f ${CODE_DIR}/log/puma.log || exit" >> ${APP_START_SCRIPT} && \
chmod +x ${APP_START_SCRIPT} && \
echo "alias start_app='bash ${APP_START_SCRIPT}'" >> ${HOME}/.bash_aliases
# Create folders for mounting
RUN mkdir -p ${HOME}/.cache/ms-playwright && \
mkdir -p ${HOME}/.cache/npm
mkdir -p ${HOME}/.cache/npm && \
mkdir -p ${CODE_DIR}/tmp && \
mkdir -p ${CODE_DIR}/node_modules
# Install gems
COPY --chown=dependabot:dependabot Gemfile Gemfile.lock ${CODE_DIR}/
......
......@@ -12,6 +12,9 @@ def initialize(project_name, package_ecosystem, directory)
end
def call
# Allow to bypass container runner in development mode
return run_via_sidekiq if !Rails.env.production? && UpdaterConfig.deploy_mode.nil?
container_runner_class.call(
package_ecosystem: package_ecosystem,
task_name: "update",
......@@ -22,6 +25,13 @@ def call
private
attr_reader :project_name, :package_ecosystem, :directory
# Trigger update run directly via sidekiq
#
# @return [void]
def run_via_sidekiq
Job::Triggers::DependencyUpdate.call(project_name, package_ecosystem, directory)
end
end
end
end
#!/bin/bash
# This script starts development environment used in .devcontainer setup.
set -e
action="$1"
compose_file=".devcontainer/docker-compose.yml"
export WITH_SERVICE="true"
if [ "$action" == "start" ]; then
docker compose -f "$compose_file" up --build --wait --force-recreate
elif [ "$action" == "stop" ]; then
docker compose -f "$compose_file" down
else
echo "Usage: $0 start|stop"
exit 1
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment