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
|
||||||
|
.env.*
|
||||||
*.cpuprofile
|
*.cpuprofile
|
||||||
*.swp
|
*.swp
|
||||||
|
*.log
|
||||||
|
node_modules
|
||||||
|
cov_profile
|
||||||
deno-test.xml
|
deno-test.xml
|
||||||
|
|
||||||
/data
|
/data
|
||||||
|
Dockerfile
|
||||||
|
Dockerfile.*
|
||||||
|
docker-compose.*
|
||||||
|
.dockerignore
|
||||||
|
.gitlab-ci.yml
|
||||||
|
|
@ -5,11 +5,20 @@ default:
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- trigger-playwright-tests
|
- e2e-setup
|
||||||
|
- e2e-test
|
||||||
|
|
||||||
|
# Original test stage
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
timeout: 2 minutes
|
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:
|
script:
|
||||||
- deno fmt --check
|
- deno fmt --check
|
||||||
- deno task lint
|
- deno task lint
|
||||||
|
|
@ -20,7 +29,6 @@ test:
|
||||||
services:
|
services:
|
||||||
- postgres:16
|
- postgres:16
|
||||||
variables:
|
variables:
|
||||||
DITTO_NSEC: nsec1zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs4rm7hz
|
|
||||||
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
|
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
POSTGRES_HOST_AUTH_METHOD: trust
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
|
|
@ -31,22 +39,58 @@ test:
|
||||||
reports:
|
reports:
|
||||||
junit: deno-test.xml
|
junit: deno-test.xml
|
||||||
|
|
||||||
trigger-playwright-tests:
|
# Start E2E environment
|
||||||
stage: trigger-playwright-tests
|
e2e-environment:
|
||||||
image: ubuntu:latest
|
stage: e2e-setup
|
||||||
before_script:
|
image: docker/compose:latest
|
||||||
- apt update && apt install -y curl
|
services:
|
||||||
|
- docker:dind
|
||||||
|
variables:
|
||||||
|
DOCKER_HOST: tcp://docker:2375
|
||||||
|
DOCKER_TLS_CERTDIR: ""
|
||||||
|
DOCKER_DRIVER: overlay2
|
||||||
script:
|
script:
|
||||||
|
- docker compose -f docker-compose.test.yml up -d
|
||||||
|
# Wait for Ditto to be healthy
|
||||||
- |
|
- |
|
||||||
curl --request POST \
|
until docker compose -f docker-compose.test.yml ps ditto | grep -q "healthy"; do
|
||||||
--form "token=${PLAYWRIGHT_TRIGGER_TOKEN}" \
|
echo "Waiting for Ditto to be ready..."
|
||||||
--form "ref=main" \
|
sleep 2
|
||||||
--form "merge_requests_events=true" \
|
done
|
||||||
--form "variables[CI_PROJECT_ID]=${CI_PROJECT_ID}" \
|
# Generate dynamic child pipeline configuration
|
||||||
--form "variables[CI_MERGE_REQUEST_IID]=${CI_MERGE_REQUEST_IID}" \
|
- |
|
||||||
--form "variables[CI_COMMIT_SHA]=${CI_COMMIT_SHA}" \
|
cat > child-pipeline.yml << EOF
|
||||||
--form "variables[CI_COMMIT_SHORT_SHA]=${CI_COMMIT_SHORT_SHA}" \
|
playwright-tests:
|
||||||
--form "variables[CI_COMMIT_REF_NAME]=${CI_COMMIT_REF_NAME}" \
|
trigger:
|
||||||
"https://gitlab.com/api/v4/projects/67335996/trigger/pipeline"
|
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:
|
only:
|
||||||
- merge_requests
|
- 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