From 19e26318fca909355bc36e1c80a9c3500a541063 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Fri, 9 Jun 2023 11:46:03 +0200 Subject: [PATCH] fix(ci): Integration tests now use new docker-compose file (#283) * fix(ci): Initial test with new docker-compose file * fix(ci): Don't use python orb * fix(ci): Use python 3 * fix(ci): Use python3 everywhere * fix(ci): whitespace PEBKAC * fix(ci): use included pyenv installation * fix(ci): Skip pyenv version if its the current one * fix(ci): Reapply matrix build for integration testing * fix(ci): Run exec $SHELL * fix(ci): Removed exec step * fix(ci): Remove test-old job --- .circleci/config.yml | 56 ++++++--------- docker-compose.yml | 162 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+), 33 deletions(-) create mode 100644 docker-compose.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 31fb022..ce1032f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,48 +6,38 @@ orbs: jobs: test: - docker: - - image: "cimg/python:<>" - - image: "cimg/node:16.15" - - image: "cimg/redis:6.2" - - image: "cimg/postgres:14.2" - environment: - POSTGRES_DB: speckle2_test - POSTGRES_PASSWORD: speckle - POSTGRES_USER: speckle - - image: "speckle/speckle-server" - command: ["bash", "-c", "/wait && node bin/www"] - environment: - POSTGRES_URL: "127.0.0.1" - POSTGRES_USER: "speckle" - POSTGRES_PASSWORD: "speckle" - POSTGRES_DB: "speckle2_test" - REDIS_URL: "redis://127.0.0.1" - SESSION_SECRET: "keyboard cat" - STRATEGY_LOCAL: "true" - CANONICAL_URL: "http://localhost:3000" - WAIT_HOSTS: 127.0.0.1:5432, 127.0.0.1:6379 - DISABLE_FILE_UPLOADS: "true" + machine: + image: ubuntu-2204:2023.02.1 + docker_layer_caching: true + resource_class: medium parameters: tag: - default: "3.8" + default: "3.11" type: string steps: - checkout - - run: python --version - run: - command: python -m pip install --upgrade pip - name: upgrade pip - - python/install-packages: - pkg-manager: poetry - - run: poetry run pytest --cov --cov-report xml:reports/coverage.xml --junitxml=reports/test-results.xml - + name: Install python + command: | + pyenv install -s << parameters.tag >> + pyenv global << parameters.tag >> + - run: + name: Startup the Speckle Server + command: docker compose -f docker-compose.yml up -d + - run: + name: Install Poetry + command: | + pip install poetry + - run: + name: Install packages + command: poetry install + - run: + name: Run tests + command: poetry run pytest --cov --cov-report xml:reports/coverage.xml --junitxml=reports/test-results.xml - store_test_results: path: reports - - store_artifacts: path: reports - - codecov/upload deploy: @@ -65,7 +55,7 @@ workflows: - test: matrix: parameters: - tag: ["3.7", "3.8", "3.9", "3.10", "3.11"] + tag: ["3.11"] filters: tags: only: /.*/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1649742 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,162 @@ +version: "3.9" +name: "speckle-server" + +services: + #### + # Speckle Server dependencies + ####### + postgres: + image: "postgres:14.5-alpine" + restart: always + environment: + POSTGRES_DB: speckle + POSTGRES_USER: speckle + POSTGRES_PASSWORD: speckle + volumes: + - postgres-data:/var/lib/postgresql/data/ + healthcheck: + # the -U user has to match the POSTGRES_USER value + test: ["CMD-SHELL", "pg_isready -U speckle"] + interval: 5s + timeout: 5s + retries: 30 + + redis: + image: "redis:6.0-alpine" + restart: always + volumes: + - redis-data:/data + healthcheck: + test: ["CMD", "redis-cli", "--raw", "incr", "ping"] + interval: 5s + timeout: 5s + retries: 30 + + minio: + image: "minio/minio" + command: server /data --console-address ":9001" + restart: always + volumes: + - minio-data:/data + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -o /dev/null http://127.0.0.1:9000/minio/index.html", + ] + interval: 5s + timeout: 30s + retries: 30 + start_period: 10s + + #### + # Speckle Server + ####### + speckle-frontend: + image: speckle/speckle-frontend:2 + restart: always + ports: + - "0.0.0.0:8080:8080" + environment: + FILE_SIZE_LIMIT_MB: 100 + + speckle-server: + image: speckle/speckle-server:2 + restart: always + healthcheck: + test: + [ + "CMD", + "node", + "-e", + "require('node:http').request({headers: {'Content-Type': 'application/json'}, port:3000, hostname:'127.0.0.1', path:'/graphql?query={serverInfo{version}}', method: 'GET' }, (res) => { body = ''; res.on('data', (chunk) => {body += chunk;}); res.on('end', () => {process.exit(res.statusCode != 200 || body.toLowerCase().includes('error'));}); }).end();", + ] + interval: 10s + timeout: 3s + retries: 30 + ports: + - "0.0.0.0:3000:3000" + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + minio: + condition: service_healthy + environment: + # TODO: Change this to the URL of the speckle server, as accessed from the network + CANONICAL_URL: "http://127.0.0.1:8080" + SPECKLE_AUTOMATE_URL: "http://127.0.0.1:3030" + + # TODO: Change thvolumes: + REDIS_URL: "redis://redis" + + S3_ENDPOINT: "http://minio:9000" + S3_ACCESS_KEY: "minioadmin" + S3_SECRET_KEY: "minioadmin" + S3_BUCKET: "speckle-server" + S3_CREATE_BUCKET: "true" + + FILE_SIZE_LIMIT_MB: 100 + + # TODO: Change this to a unique secret for this server + SESSION_SECRET: "TODO:ReplaceWithLongString" + + STRATEGY_LOCAL: "true" + DEBUG: "speckle:*" + + POSTGRES_URL: "postgres" + POSTGRES_USER: "speckle" + POSTGRES_PASSWORD: "speckle" + POSTGRES_DB: "speckle" + ENABLE_MP: "false" + + preview-service: + image: speckle/speckle-preview-service:2 + restart: always + depends_on: + speckle-server: + condition: service_healthy + mem_limit: "1000m" + memswap_limit: "1000m" + environment: + DEBUG: "preview-service:*" + PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle" + + webhook-service: + image: speckle/speckle-webhook-service:2 + restart: always + depends_on: + speckle-server: + condition: service_healthy + environment: + DEBUG: "webhook-service:*" + PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle" + WAIT_HOSTS: postgres:5432 + + fileimport-service: + image: speckle/speckle-fileimport-service:2 + restart: always + depends_on: + speckle-server: + condition: service_healthy + environment: + DEBUG: "fileimport-service:*" + PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle" + WAIT_HOSTS: postgres:5432 + + S3_ENDPOINT: "http://minio:9000" + S3_ACCESS_KEY: "minioadmin" + S3_SECRET_KEY: "minioadmin" + S3_BUCKET: "speckle-server" + + SPECKLE_SERVER_URL: "http://speckle-server:3000" + +networks: + default: + name: speckle-server + +volumes: + postgres-data: + redis-data: + minio-data: