diff --git a/.github/workflows/stage-tests.yml b/.github/workflows/stage-tests.yml new file mode 100644 index 000000000..0b5677732 --- /dev/null +++ b/.github/workflows/stage-tests.yml @@ -0,0 +1,33 @@ +name: Dreambuilder stage tests +on: + push: + branches: + - "main" + pull_request: + branches: [ "main" ] +permissions: + contents: read +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Create .env file + run: | + mkdir compose/.envs && touch compose/.envs/.env.stage && echo ${{ secrets.STAGE__ENV_DATA}} > compose/.envs/.env.stage + - name: Create client_secret + run: | + touch client_secret.json && echo ${{ secrets.CLIENT_SECRET}} > client_secret.json + - name: Create .env for tests + run: | + touch compose/.envs/.env.test && echo ${{ secrets.STAGE__TEST_ENV}} > compose/.envs/.env.test + - name: Build stack + run: docker-compose -f compose/stage/docker-compose.stage.yml build --no-cache postgres redis auth-api distributions-api deployment-worker + - name: Start stack + run: | + docker-compose -f compose/stage/docker-compose.stage.yml up -d postgres redis + docker-compose -f compose/stage/docker-compose.stage.yml up -d auth-api + docker-compose -f compose/stage/docker-compose.stage.yml up -d distributions-api deployment-worker + - name: Build tests + run: | + docker-compose -f compose/stage/docker-compose.stage.yml up tests diff --git a/compose/stage/docker-compose.stage.yml b/compose/stage/docker-compose.stage.yml index 5e03c286e..d01672cb4 100644 --- a/compose/stage/docker-compose.stage.yml +++ b/compose/stage/docker-compose.stage.yml @@ -107,7 +107,17 @@ services: - /var/run/docker.sock:/var/run/docker.sock # depends_on: # - redis - + tests: + env_file: [ ../.envs/.env.test ] + restart: on-failure + build: + context: ../.. + dockerfile: ./tests/backend/Dockerfile + volumes: + - ../../apiconfig:/src/apiconfig + - ../../database:/src/database + - ../../git_storage:/src/git_storage + - ../../tests:/src/tests # # flower: # env_file: [ ../.envs/.env.dev.local ] diff --git a/tests/backend/Dockerfile b/tests/backend/Dockerfile index e14d098c4..e27cb6447 100644 --- a/tests/backend/Dockerfile +++ b/tests/backend/Dockerfile @@ -5,9 +5,12 @@ WORKDIR src/ ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONBUFFERED 1 -COPY tests/backend/requirements.txt . +RUN apt-get update && apt-get install -y --no-install-recommends git + +COPY tests/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt +COPY services/ services/ COPY tests/backend /src/tests/backend -CMD ["pytest", "tests/backend", "-v"] +CMD ["pytest", "tests/backend", "-sv", "-m", "regression"] diff --git a/tests/requirements.txt b/tests/requirements.txt index 0ca63e0e2..668627c20 100644 Binary files a/tests/requirements.txt and b/tests/requirements.txt differ