Skip to content

Commit

Permalink
convert docker-compose to docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
guidopetri committed Oct 8, 2023
1 parent 0f175b7 commit aad2d22
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ jobs:
- name: Build Docker Images
run: |
set -x
docker-compose build --build-arg install_groups="main,all_ds,dev" --build-arg skip_frontend_build=true
docker-compose up -d
docker compose build --build-arg install_groups="main,all_ds,dev" --build-arg skip_frontend_build=true
docker compose up -d
sleep 10
- name: Create Test Database
run: docker-compose -p redash run --rm postgres psql -h postgres -U postgres -c "create database tests;"
run: docker compose -p redash run --rm postgres psql -h postgres -U postgres -c "create database tests;"
- name: List Enabled Query Runners
run: docker-compose -p redash run --rm redash manage ds list_types
run: docker compose -p redash run --rm redash manage ds list_types
- name: Run Tests
run: docker-compose -p redash run --name tests redash tests --junitxml=junit.xml --cov-report=xml --cov=redash --cov-config=.coveragerc tests/
run: docker compose -p redash run --name tests redash tests --junitxml=junit.xml --cov-report=xml --cov=redash --cov-config=.coveragerc tests/
- name: Copy Test Results
run: |
mkdir -p /tmp/test-results/unit-tests
Expand Down Expand Up @@ -137,12 +137,12 @@ jobs:
set -x
yarn cypress build
yarn cypress start -- --skip-db-seed
docker-compose run cypress yarn cypress db-seed
docker compose run cypress yarn cypress db-seed
- name: Execute Cypress Tests
run: yarn cypress run-ci
- name: "Failure: output container logs to console"
if: failure()
run: docker-compose logs
run: docker compose logs
- name: Copy Code Coverage Results
run: docker cp cypress:/usr/src/app/coverage ./coverage || true
- name: Store Coverage Results
Expand Down Expand Up @@ -234,4 +234,4 @@ jobs:

- name: "Failure: output container logs to console"
if: failure()
run: docker-compose logs
run: docker compose logs
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
.PHONY: compose_build up test_db create_database clean down tests lint backend-unit-tests frontend-unit-tests test build watch start redis-cli bash

compose_build: .env
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose build

up:
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose up -d --build
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose up -d --build

test_db:
@for i in `seq 1 5`; do \
if (docker-compose exec postgres sh -c 'psql -U postgres -c "select 1;"' 2>&1 > /dev/null) then break; \
if (docker compose exec postgres sh -c 'psql -U postgres -c "select 1;"' 2>&1 > /dev/null) then break; \
else echo "postgres initializing..."; sleep 5; fi \
done
docker-compose exec postgres sh -c 'psql -U postgres -c "drop database if exists tests;" && psql -U postgres -c "create database tests;"'
docker compose exec postgres sh -c 'psql -U postgres -c "drop database if exists tests;" && psql -U postgres -c "create database tests;"'

create_database: .env
docker-compose run server create_db
docker compose run server create_db

clean:
docker-compose down && docker-compose rm
docker compose down && docker compose rm

down:
docker-compose down
docker compose down

.env:
printf "REDASH_COOKIE_SECRET=`pwgen -1s 32`\nREDASH_SECRET_KEY=`pwgen -1s 32`\n" >> .env
Expand All @@ -31,14 +31,14 @@ format:
pre-commit run --all-files

tests:
docker-compose run server tests
docker compose run server tests

lint:
ruff check .
black --check . --diff

backend-unit-tests: up test_db
docker-compose run --rm --name tests server tests
docker compose run --rm --name tests server tests

frontend-unit-tests:
CYPRESS_INSTALL_BINARY=0 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 yarn --frozen-lockfile
Expand All @@ -56,7 +56,7 @@ start:
yarn start

redis-cli:
docker-compose run --rm redis redis-cli -h redis
docker compose run --rm redis redis-cli -h redis

bash:
docker-compose run --rm server bash
docker compose run --rm server bash
10 changes: 5 additions & 5 deletions client/cypress/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ function seedDatabase(seedValues) {

function buildServer() {
console.log("Building the server...");
execSync("docker-compose -p cypress build", { stdio: "inherit" });
execSync("docker compose -p cypress build", { stdio: "inherit" });
}

function startServer() {
console.log("Starting the server...");
execSync("docker-compose -p cypress up -d", { stdio: "inherit" });
execSync("docker-compose -p cypress run server create_db", { stdio: "inherit" });
execSync("docker compose -p cypress up -d", { stdio: "inherit" });
execSync("docker compose -p cypress run server create_db", { stdio: "inherit" });
}

function stopServer() {
console.log("Stopping the server...");
execSync("docker-compose -p cypress down", { stdio: "inherit" });
execSync("docker compose -p cypress down", { stdio: "inherit" });
}

function runCypressCI() {
Expand All @@ -81,7 +81,7 @@ function runCypressCI() {
}

execSync(
"COMMIT_INFO_MESSAGE=$(git show -s --format=%s) docker-compose run --name cypress cypress ./node_modules/.bin/percy exec -t 300 -- ./node_modules/.bin/cypress run $CYPRESS_OPTIONS",
"COMMIT_INFO_MESSAGE=$(git show -s --format=%s) docker compose run --name cypress cypress ./node_modules/.bin/percy exec -t 300 -- ./node_modules/.bin/cypress run $CYPRESS_OPTIONS",
{ stdio: "inherit" }
);
}
Expand Down

0 comments on commit aad2d22

Please sign in to comment.