diff --git a/compose.local-test.yml b/compose.local-test.yml new file mode 100644 index 0000000000..ecb9f42722 --- /dev/null +++ b/compose.local-test.yml @@ -0,0 +1,49 @@ +# このconfigは、 dockerでMisskey本体を起動せず、 redisとpostgresql などだけを起動します + +services: + redis: + restart: always + image: redis:7-alpine + ports: + - "6379:6379" + volumes: + - ./redis:/data + healthcheck: + test: "redis-cli ping" + interval: 5s + retries: 20 + + postgres: + restart: always + image: postgres:15-alpine + ports: + - "5432:5432" + env_file: + - .config/docker.env + volumes: + - ./db:/var/lib/postgresql/data + healthcheck: + test: "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB" + interval: 5s + retries: 20 + + web: + restart: always + image: node:iron + ports: + - 3000:3000 + volumes: + - ./:/host + command: sleep infinity + +# meilisearch: +# restart: always +# image: getmeili/meilisearch:v1.3.4 +# environment: +# - MEILI_NO_ANALYTICS=true +# - MEILI_ENV=production +# env_file: +# - .config/meilisearch.env +# volumes: +# - ./meili_data:/meili_data + diff --git a/setup-tests.sh b/setup-tests.sh new file mode 100755 index 0000000000..21e0c4162f --- /dev/null +++ b/setup-tests.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +echo "This script will destroy the following local directories:" +echo " ./built" +echo " ./db" +echo " ./redis" +echo +echo "Do you want to continue? [Y/n]" +read -p "> " confirmation + +case $confirmation in + [Yy]* ) + echo "Continuing..." + ;; + [Nn] ) + echo "Exiting..." + exit 0 + ;; +esac + +cp compose.local-test.yml compose.yml + +echo Verifying containers are down... +docker compose down +docker compose rm + +echo Removing any preexisting builds and databases. +echo This may take a few moments... +rm -rf ./built ./db ./redis + +echo Creating environment +docker compose up -d +docker compose exec web apt-get update +docker compose exec web apt-get install -y bash + +echo Building and running tests... +docker compose exec web /host/tests.sh + +echo Cleaning up... +docker compose down +docker compose rm +rm -f compose.yml diff --git a/tests.sh b/tests.sh new file mode 100755 index 0000000000..ce62a9f250 --- /dev/null +++ b/tests.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Do not run this on your local machine. Instead, execute setup-tests.sh and it +# will automatically create, test, and tear down the testing environment. + +set -e + +cd /host/ +echo Removing any preexisting builds and databases. +echo This may take a few moments... +rm -rf ./built ./db ./redis +apt-get update && apt-get install -y git wget curl build-essential python3 ffmpeg +cp .config/ci.yml .config/default.yml +cp .config/ci.yml .config/test.yml +corepack enable +corepack prepare pnpm@latest --activate +git submodule update --init +pnpm install --frozen-lockfile +pnpm run build +pnpm run migrate +pnpm run --filter='!megalodon' test +pnpm run --filter=backend --filter=misskey-js lint +pnpm run --filter=frontend --filter=frontend-embed eslint