From 07df4ea85b926603eb51ea033413ae85687bb470 Mon Sep 17 00:00:00 2001 From: Kadin Buckton Date: Thu, 10 Oct 2019 13:54:15 -0400 Subject: [PATCH 1/5] Updated tests to reflect default port --- tests/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/base.py b/tests/base.py index e7385e7..dd1e625 100644 --- a/tests/base.py +++ b/tests/base.py @@ -91,7 +91,7 @@ class BaseTestCase(BaseCase): super(BaseTestCase, self).tearDown() def open_nitter(self, page=''): - self.open(f'http://localhost:5000/{page}') + self.open(f'http://localhost:8080/{page}') def search_username(self, username): self.open_nitter() From fcaf57f6676bf33e2b334ec3e81df9d9f8cc8a27 Mon Sep 17 00:00:00 2001 From: Kadin Buckton Date: Thu, 10 Oct 2019 13:55:16 -0400 Subject: [PATCH 2/5] Added Dockerfile --- Dockerfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e32a5a3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM nimlang/nim:alpine as nim +MAINTAINER setenforce@protonmail.com +EXPOSE 8080 +ENV HOSTNAME nitter.net + +COPY . /src/nitter +WORKDIR /src/nitter + +RUN apk update \ + && apk add python3 python3-dev bash libsass libsass-dev chromium chromium-chromedriver libffi libffi-dev openssl-dev \ + && pip3 install --upgrade pip && pip3 install -U seleniumbase pytest \ + && nimble build -y -d:release -d:hostname=${HOSTNAME} \ + && nimble scss \ + && mkdir -p ./tmp \ + && bash -c "./nitter & cd tests && pytest --headless -n 8 --reruns 5 --reruns-delay 1 && kill %1" + +FROM alpine +WORKDIR /src/ +COPY --from=nim /src/nitter . +RUN apk add pcre-dev sqlite-dev +CMD ./nitter From 4f35e2ec95e710087e6dad347c251ad21ccd2b52 Mon Sep 17 00:00:00 2001 From: Kadin Buckton Date: Thu, 10 Oct 2019 13:55:30 -0400 Subject: [PATCH 3/5] Added helper script to deploy docker image --- scripts/deploy.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 scripts/deploy.sh diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 0000000..ddd68f6 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,4 @@ +#!/bin/sh +docker build -t $IMAGE_NAME . \ +&& echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin \ +&& docker push $IMAGE_NAME:latest From 0fb59f111b2f0e369016544648ebe722e8c6bfa8 Mon Sep 17 00:00:00 2001 From: Kadin Buckton Date: Thu, 10 Oct 2019 13:55:55 -0400 Subject: [PATCH 4/5] Added Travis CI configuration --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..84b3695 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +sudo: required +language: minimal +services: +- docker + +script: +- sh scripts/deploy.sh + From a39a16a4a93303d7ff74aa61bbf69e8c6a2a4725 Mon Sep 17 00:00:00 2001 From: Kadin Buckton Date: Sat, 12 Oct 2019 14:29:55 -0400 Subject: [PATCH 5/5] Moved tests from Dockerfile to Travis --- .travis.yml | 48 +++++++++++++++++++++++++++++++++++++++-------- Dockerfile | 7 ++----- scripts/deploy.sh | 4 ---- 3 files changed, 42 insertions(+), 17 deletions(-) delete mode 100755 scripts/deploy.sh diff --git a/.travis.yml b/.travis.yml index 84b3695..088342d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,40 @@ -sudo: required -language: minimal -services: -- docker - -script: -- sh scripts/deploy.sh - +jobs: + include: + - stage: build + language: minimal + services: + - docker + script: + - docker build -t $IMAGE_NAME:$TRAVIS_COMMIT . + - echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin + - docker push $IMAGE_NAME:$TRAVIS_COMMIT + - stage: deploy + if: (NOT type IN (pull_request)) AND (branch = master) + language: minimal + services: + - docker + script: + - docker pull $IMAGE_NAME:$TRAVIS_COMMIT + - docker tag $IMAGE_NAME:$TRAVIS_COMMIT $IMAGE_NAME:latest + - echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin + - docker push $IMAGE_NAME:latest + - stage: test + sudo: required + dist: bionic + language: python + addons: + chrome: stable + python: + - 3.6 + services: + - docker + - xvfb + script: + - sudo apt update + - sudo apt install --force-yes chromium-browser chromium-chromedriver + - pip3 install --upgrade pip + - pip3 install -U seleniumbase pytest + - docker run -d -p 127.0.0.1:8080:8080/tcp $IMAGE_NAME:$TRAVIS_COMMIT + - sleep 10 + - cd tests + - pytest --headless -n 8 --reruns 10 --reruns-delay 2 diff --git a/Dockerfile b/Dockerfile index e32a5a3..7629a5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,12 +7,9 @@ COPY . /src/nitter WORKDIR /src/nitter RUN apk update \ - && apk add python3 python3-dev bash libsass libsass-dev chromium chromium-chromedriver libffi libffi-dev openssl-dev \ - && pip3 install --upgrade pip && pip3 install -U seleniumbase pytest \ + && apk add libsass-dev libffi-dev openssl-dev \ && nimble build -y -d:release -d:hostname=${HOSTNAME} \ - && nimble scss \ - && mkdir -p ./tmp \ - && bash -c "./nitter & cd tests && pytest --headless -n 8 --reruns 5 --reruns-delay 1 && kill %1" + && nimble scss FROM alpine WORKDIR /src/ diff --git a/scripts/deploy.sh b/scripts/deploy.sh deleted file mode 100755 index ddd68f6..0000000 --- a/scripts/deploy.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -docker build -t $IMAGE_NAME . \ -&& echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin \ -&& docker push $IMAGE_NAME:latest