mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Attempt to build ditto locally for test run target.
This commit is contained in:
parent
5ee1fc1b7f
commit
9355ab9b17
4 changed files with 127 additions and 18 deletions
|
|
@ -1,6 +1,16 @@
|
|||
.git
|
||||
.env
|
||||
.env.*
|
||||
*.cpuprofile
|
||||
*.swp
|
||||
*.log
|
||||
node_modules
|
||||
cov_profile
|
||||
deno-test.xml
|
||||
|
||||
/data
|
||||
/data
|
||||
Dockerfile
|
||||
Dockerfile.*
|
||||
docker-compose.*
|
||||
.dockerignore
|
||||
.gitlab-ci.yml
|
||||
|
|
@ -5,11 +5,20 @@ default:
|
|||
|
||||
stages:
|
||||
- test
|
||||
- trigger-playwright-tests
|
||||
- e2e-setup
|
||||
- e2e-test
|
||||
|
||||
# Original test stage
|
||||
test:
|
||||
stage: test
|
||||
timeout: 2 minutes
|
||||
before_script:
|
||||
# Install nak for test environment
|
||||
- apt-get update && apt-get install -y curl build-essential
|
||||
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
- . "$HOME/.cargo/env" && cargo install nak
|
||||
# Generate NSEC
|
||||
- export DITTO_NSEC=$(nak key generate | nak encode nsec)
|
||||
script:
|
||||
- deno fmt --check
|
||||
- deno task lint
|
||||
|
|
@ -20,7 +29,6 @@ test:
|
|||
services:
|
||||
- postgres:16
|
||||
variables:
|
||||
DITTO_NSEC: nsec1zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs4rm7hz
|
||||
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
RUST_BACKTRACE: 1
|
||||
|
|
@ -31,22 +39,58 @@ test:
|
|||
reports:
|
||||
junit: deno-test.xml
|
||||
|
||||
trigger-playwright-tests:
|
||||
stage: trigger-playwright-tests
|
||||
image: ubuntu:latest
|
||||
before_script:
|
||||
- apt update && apt install -y curl
|
||||
# Start E2E environment
|
||||
e2e-environment:
|
||||
stage: e2e-setup
|
||||
image: docker/compose:latest
|
||||
services:
|
||||
- docker:dind
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_DRIVER: overlay2
|
||||
script:
|
||||
- docker compose -f docker-compose.test.yml up -d
|
||||
# Wait for Ditto to be healthy
|
||||
- |
|
||||
curl --request POST \
|
||||
--form "token=${PLAYWRIGHT_TRIGGER_TOKEN}" \
|
||||
--form "ref=main" \
|
||||
--form "merge_requests_events=true" \
|
||||
--form "variables[CI_PROJECT_ID]=${CI_PROJECT_ID}" \
|
||||
--form "variables[CI_MERGE_REQUEST_IID]=${CI_MERGE_REQUEST_IID}" \
|
||||
--form "variables[CI_COMMIT_SHA]=${CI_COMMIT_SHA}" \
|
||||
--form "variables[CI_COMMIT_SHORT_SHA]=${CI_COMMIT_SHORT_SHA}" \
|
||||
--form "variables[CI_COMMIT_REF_NAME]=${CI_COMMIT_REF_NAME}" \
|
||||
"https://gitlab.com/api/v4/projects/67335996/trigger/pipeline"
|
||||
until docker compose -f docker-compose.test.yml ps ditto | grep -q "healthy"; do
|
||||
echo "Waiting for Ditto to be ready..."
|
||||
sleep 2
|
||||
done
|
||||
# Generate dynamic child pipeline configuration
|
||||
- |
|
||||
cat > child-pipeline.yml << EOF
|
||||
playwright-tests:
|
||||
trigger:
|
||||
project: your-group/ditto-playwright
|
||||
strategy: depend
|
||||
variables:
|
||||
BASE_URL: http://localhost:4036
|
||||
CI_PROJECT_ID: ${CI_PROJECT_ID}
|
||||
CI_MERGE_REQUEST_IID: ${CI_MERGE_REQUEST_IID}
|
||||
CI_COMMIT_SHA: ${CI_COMMIT_SHA}
|
||||
CI_COMMIT_SHORT_SHA: ${CI_COMMIT_SHORT_SHA}
|
||||
CI_COMMIT_REF_NAME: ${CI_COMMIT_REF_NAME}
|
||||
EOF
|
||||
artifacts:
|
||||
paths:
|
||||
- child-pipeline.yml
|
||||
only:
|
||||
- merge_requests
|
||||
|
||||
# Trigger child pipeline
|
||||
e2e-test:
|
||||
stage: e2e-test
|
||||
trigger:
|
||||
include:
|
||||
- artifact: child-pipeline.yml
|
||||
job: e2e-environment
|
||||
strategy: depend
|
||||
needs:
|
||||
- e2e-environment
|
||||
variables:
|
||||
BASE_URL: http://localhost:4036
|
||||
after_script:
|
||||
- docker compose -f docker-compose.test.yml down -v
|
||||
only:
|
||||
- merge_requests
|
||||
27
Dockerfile.test
Normal file
27
Dockerfile.test
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
FROM denoland/deno:2.2.2
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install curl and Rust for nak installation
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
jq \
|
||||
unzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy the application files
|
||||
COPY . .
|
||||
|
||||
# Install soapbox
|
||||
RUN deno task soapbox
|
||||
|
||||
# Generate NSEC at build time
|
||||
RUN export DITTO_NSEC=$(deno task nsec) && \
|
||||
echo "export DITTO_NSEC=$DITTO_NSEC" > /app/nsec.env
|
||||
|
||||
ENV DATABASE_URL=""
|
||||
|
||||
EXPOSE 4036
|
||||
|
||||
# Use array form with shell -c to properly handle the command
|
||||
CMD ["/bin/sh", "-c", ". /app/nsec.env && deno run -A /app/packages/ditto/server.ts"]
|
||||
28
docker-compose.test.yml
Normal file
28
docker-compose.test.yml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: postgres
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
ditto:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.test
|
||||
environment:
|
||||
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres
|
||||
- RUST_BACKTRACE=1
|
||||
ports:
|
||||
- "4036:4036"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
Loading…
Add table
Reference in a new issue