Skip to content

Commit 4285fda

Browse files
committed
Add test automation for SQL Server backend
1 parent 7e2ba5d commit 4285fda

File tree

3 files changed

+49
-15
lines changed

3 files changed

+49
-15
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ python:
66
env:
77
- DATABASE=sqlite
88
- DATABASE=postgres
9+
- DATABASE=mssql
910

1011
services:
1112
- docker
@@ -16,6 +17,11 @@ before_install:
1617
if [[ "${DATABASE}" = "postgres" ]]; then
1718
docker run --rm --name=postgres --network=doccano -d -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass -e POSTGRES_DB=db postgres
1819
export DATABASE_URL="postgres://user:pass@postgres:5432/db?sslmode=disable"
20+
21+
elif [[ "${DATABASE}" = "mssql" ]]; then
22+
docker run --rm --name=mssql --network=doccano -d -e ACCEPT_EULA=y -e SA_PASSWORD=sUp3rS3cr3t mcr.microsoft.com/mssql/server:2017-latest
23+
docker exec -it mssql sh -c "while ! /opt/mssql-tools/bin/sqlcmd -U SA -P sUp3rS3cr3t -Q 'CREATE DATABASE db;'; do sleep 3; done"
24+
export DATABASE_URL="mssql://SA:sUp3rS3cr3t@mssql:1433/db?sslmode=disable"
1925
fi
2026
2127
install:

Dockerfile

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ RUN curl -sL "https://deb.nodesource.com/setup_${NODE_VERSION}" | bash - \
66
&& apt-get install --no-install-recommends -y \
77
nodejs=8.16.0-1nodesource1
88

9-
RUN apt-get install --no-install-recommends -y \
10-
unixodbc-dev=2.3.4-1
9+
COPY tools/install-mssql.sh /doccano/tools/install-mssql.sh
10+
RUN /doccano/tools/install-mssql.sh --dev
1111

1212
COPY app/server/static/package*.json /doccano/app/server/static/
1313
RUN cd /doccano/app/server/static \
@@ -33,19 +33,8 @@ RUN cd /doccano \
3333

3434
FROM python:${PYTHON_VERSION}-slim-stretch AS runtime
3535

36-
RUN apt-get update \
37-
&& apt-get install --no-install-recommends -y \
38-
curl=7.52.1-5+deb9u9 \
39-
gnupg=2.1.18-8~deb9u4 \
40-
apt-transport-https=1.4.9 \
41-
&& curl -fsS https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
42-
&& curl -fsS https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql.list \
43-
&& apt-get update \
44-
&& ACCEPT_EULA=Y apt-get install --no-install-recommends -y \
45-
msodbcsql17=17.3.1.1-1 \
46-
mssql-tools=17.3.0.1-1 \
47-
&& apt-get remove -y curl gnupg apt-transport-https \
48-
&& rm -rf /var/lib/apt/lists/*
36+
COPY --from=builder /doccano/tools/install-mssql.sh /doccano/tools/install-mssql.sh
37+
RUN /doccano/tools/install-mssql.sh
4938

5039
RUN useradd -ms /bin/sh doccano
5140

tools/install-mssql.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
# parse arguments
4+
mode="prod"
5+
for opt in "$@"; do
6+
case "${opt}" in
7+
--dev) mode="dev" ;;
8+
esac
9+
done
10+
11+
set -eo pipefail
12+
13+
# install build dependencies
14+
apt-get update
15+
apt-get install --no-install-recommends -y \
16+
curl=7.52.1-5+deb9u9 \
17+
gnupg=2.1.18-8~deb9u4 \
18+
apt-transport-https=1.4.9
19+
20+
# install dependency to compile django-pyodbc-azure
21+
if [[ "${mode}" = "dev" ]]; then
22+
apt-get install --no-install-recommends -y \
23+
unixodbc-dev=2.3.4-1
24+
fi
25+
26+
# add mssql repo
27+
curl -fsS https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
28+
curl -fsS https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql.list
29+
apt-get update
30+
31+
# install mssql
32+
ACCEPT_EULA=Y apt-get install --no-install-recommends -y \
33+
msodbcsql17=17.3.1.1-1 \
34+
mssql-tools=17.3.0.1-1
35+
36+
# remove build dependencies and artifacts
37+
apt-get remove -y \
38+
curl gnupg apt-transport-https
39+
rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)