forked from linode/linode-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-bats
51 lines (38 loc) · 1.88 KB
/
Dockerfile-bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FROM python:2
ENV TOKEN_1 ""
ENV TOKEN_2 ""
ENV TEST_ENVIRONMENT "prod"
ENV PYTHONPATH=.
ENV PATH="/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin"
RUN apt-get update && apt-get install -y python3 python3-pip parallel \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Install BATS testing framework
RUN git clone --branch v1.1.0 https://github.com/bats-core/bats-core.git \
&& cd bats-core \
&& ./install.sh /usr/local
WORKDIR /src/linode-cli
COPY requirements.txt .
RUN pip install -r requirements.txt \
&& pip3 install -r requirements.txt
COPY . .
# Modify the cli.py to suppress version warnings by default
# Modify the cli.py to no longer verify certs and suppress warnings (allows running tests on custom environments)
RUN sed -i="" "s/data=body/data=body,verify=False/" /src/linode-cli/linodecli/cli.py \
&& sed -i="" "s/suppress_warnings = False/suppress_warnings = True/" /src/linode-cli/linodecli/cli.py \
&& echo "from requests.packages.urllib3.exceptions import InsecureRequestWarning\nrequests.packages.urllib3.disable_warnings(InsecureRequestWarning)" >> /src/linode-cli/linodecli/cli.py
# Override the base url in the openapi spec to the build argument
ARG API_OVERRIDE=api.linode.com
# Override the Spec url
ARG SPEC=https://developers.linode.com/api/docs/v4/openapi.yaml
# Fetch the openapi spec, build and install the Linode CLI
RUN curl --cacert ./cacert.pem -o ./openapi.yaml "${SPEC}" \
&& sed -n "s|url: https://api.linode.com/v4|url: https://${API_OVERRIDE}/v4|g;w cli-tests.yaml" /src/linode-cli/openapi.yaml \
&& git submodule init \
&& git submodule update \
&& make build SPEC=/src/linode-cli/cli-tests.yaml \
&& make install SPEC=/src/linode-cli/cli-tests.yaml \
&& cd dist \
&& pip install --user $(ls)
WORKDIR /src/linode-cli/test
ENTRYPOINT ["./test-runner.sh", "--force"]