Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEBUG windows docker build #537

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ updates:
- RobertCraigie
rebase-strategy: auto
target-branch: main
- package-ecosystem: pip
directory: /pipelines/requirements/
schedule:
interval: daily
reviewers:
- RobertCraigie
rebase-strategy: auto
target-branch: main
22 changes: 15 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ on:
- "LICENSE"
- "mkdocs.yml"
pull_request:
branches:
- main
paths-ignore:
- "*.md"
- ".vscode/**"
Expand Down Expand Up @@ -256,11 +254,14 @@ jobs:
strategy:
fail-fast: false
matrix:
docker-platform: ["linux/amd64"]
docker-platform: [linux/amd64]
# TODO: Uncomment this to add testing support for arm64 and delete
# the above
# docker-platform: ["linux/amd64", "linux/arm64"]
python-os-distro: ["slim-bullseye", "alpine"]
# TODO: Uncomment this later, Go-based CLI does not run on Alpine
# https://github.com/prisma/prisma-client-go/issues/357
# python-os-distro: [slim-bullseye, alpine]
python-os-distro: [slim-bullseye]
steps:
- uses: actions/checkout@v3
# https://github.com/docker/build-push-action/
Expand All @@ -276,14 +277,21 @@ jobs:
context: .
file: tests/Dockerfile
platforms: "${{ matrix.docker-platform }}"
build-args: "${{ matrix.python-os-distro }}"
build-args: OS_DISTRO=${{ matrix.python-os-distro }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Note: Windows does not play well with the standard GH Docker + buildx
# actions
docker-windows:
name: docker (windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Docker Build
# Use --% to allow double hyphen
# Caching not currently working since we don't use buildx yet, windows
# support seems poor because of interactions with --prvileged
# --cache-from=type=gha --cache-to=type=gha,mode=max
run: |
docker build -f tests/windows.Dockerfile -t prisma-client-py .
docker build --% -f tests/windows.Dockerfile -t prisma-client-py .
2 changes: 1 addition & 1 deletion pipelines/requirements/lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
interrogate==1.5.0
blue==0.9.1
mypy==0.950
slotscheck==0.14.0
slotscheck==0.15.0
2 changes: 1 addition & 1 deletion pipelines/requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ mock==4.0.3
pytest-mock==3.6.1
pytest-asyncio==0.17.0
pytest-subprocess==1.1.2
syrupy==1.5.0
syrupy==3.0.2
fastapi==0.73.0
4 changes: 2 additions & 2 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mkdocs==1.4.0
mkdocs-material==8.5.6
mkdocs==1.4.1
mkdocs-material==8.5.7
8 changes: 7 additions & 1 deletion src/prisma/cli/_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pydantic.typing import get_args

from .. import config
from ..utils import DEBUG
from .._proxy import LazyProxy
from ..binaries import platform
from ..errors import PrismaError
Expand Down Expand Up @@ -152,14 +153,19 @@ def from_nodeenv(cls, target: Target) -> NodeBinaryStrategy:
path,
)
else:
nodeenv_args = (
['--verbose', *config.nodeenv_extra_args]
if DEBUG
else config.nodeenv_extra_args
)
log.debug('Installing nodeenv to %s', path)
subprocess.run(
[
sys.executable,
'-m',
'nodeenv',
str(path),
*config.nodeenv_extra_args,
*nodeenv_args,
],
check=True,
stdout=sys.stdout,
Expand Down
3 changes: 1 addition & 2 deletions src/prisma/mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
NameExpr,
Var,
BytesExpr,
UnicodeExpr,
CallExpr,
IntExpr,
Context,
Expand Down Expand Up @@ -362,7 +361,7 @@ def _callexpr_to_dict(
return parsed

def _resolve_expression(self, expression: Expression) -> Any:
if isinstance(expression, (StrExpr, BytesExpr, UnicodeExpr, IntExpr)):
if isinstance(expression, (StrExpr, BytesExpr, IntExpr)):
return expression.value

if isinstance(expression, NameExpr):
Expand Down
39 changes: 37 additions & 2 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,50 @@ ARG OS_DISTRO=slim-bullseye

FROM python:${PYTHON_VERSION}-${OS_DISTRO}

RUN useradd --create-home --uid 9999 --shell /bin/bash prisma
# These are are own build args recorded as env variables
ARG OS_DISTRO
ENV OS_DISTRO=${OS_DISTRO}
ENV PRISMA_USER_ID=9999

# These are provided by Docker
ARG BUILDPLATFORM
ARG BUILDOS
ARG BUILDARCH
ARG BUILDVARIANT
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH

ENV DOCKER_BUILDPLATFORM=${BUILDPLATFORM}
ENV DOCKER_BUILDOS=${BUILDOS}
ENV DOCKER_BUILDARCH=${BUILDARCH}
ENV DOCKER_BUILDVARIANT=${BUILDVARIANT}
ENV DOCKER_TARGETPLATFORM=${TARGETPLATFORM}
ENV DOCKER_TARGETOS=${TARGETOS}
ENV DOCKER_TARGETARCH=${TARGETARCH}

# TODO: Using the slim variant is a bit hackier. Better to
# cat and grep /etc/*release*. Also, the [[ ]] command
# is a bash thing so thats why we subshell for the test
RUN \
if [[ $OS_DISTRO =~ alpine ]]; then \
adduser -u ${PRISMA_USER_ID} -D prisma; \
apk add gcc musl-dev yaml-dev yaml libffi-dev; \
elif bash -c "[[ ${OS_DISTRO} =~ slim ]]"; then \
useradd --create-home --uid ${PRISMA_USER_ID} --shell /bin/bash prisma; \
else \
echo "Unrecognized distro $OS_DISTRO"; \
exit 99; \
fi

USER prisma
WORKDIR /home/prisma/prisma-client-py
ENV PATH="/home/prisma/.local/bin:${PATH}"

COPY --chown=prisma:prisma . .

RUN pip install .[dev]
RUN pip install --upgrade pip && \
pip install .[dev]

# This has the side-effect of downing the prisma binaries
# and will fail if the CLI cannot get run
Expand Down
48 changes: 24 additions & 24 deletions tests/__snapshots__/test_builder.ambr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# name: test_basic_building
'
'''
query {
result: findUniqueUser
(
Expand All @@ -14,10 +14,10 @@
created_at
}
}
'
---
'''
# ---
# name: test_basic_building.1
'
'''
mutation {
result: queryRaw
(
Expand All @@ -26,10 +26,10 @@
}
)
}
'
---
'''
# ---
# name: test_custom_serialization
'
'''
query {
result: findUniquePost
(
Expand All @@ -48,10 +48,10 @@
author_id
}
}
'
---
'''
# ---
# name: test_datetime_serialization_tz_aware
'
'''
query {
result: findUniquePost
(
Expand All @@ -70,10 +70,10 @@
author_id
}
}
'
---
'''
# ---
# name: test_datetime_serialization_tz_unaware
'
'''
query {
result: findUniquePost
(
Expand All @@ -92,10 +92,10 @@
author_id
}
}
'
---
'''
# ---
# name: test_include_with_arguments
'
'''
query {
result: findUniqueUser
(
Expand Down Expand Up @@ -125,21 +125,21 @@
}
}
}
'
---
'''
# ---
# name: test_raw_queries
'
'''
mutation {
result: queryRaw
(
query: "SELECT * FROM User where id = $1"
parameters: "[\"1263526\"]"
)
}
'
---
'''
# ---
# name: test_unicode
'
'''
query {
result: findUniqueUser
(
Expand All @@ -154,5 +154,5 @@
created_at
}
}
'
---
'''
# ---
Loading