Merge pull request #74 from setenforce0/master

Implement CI via Travis and Docker
This commit is contained in:
Zed 2019-10-17 23:29:26 +02:00 committed by GitHub
commit 1877b4fd83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 1 deletions

40
.travis.yml Normal file
View file

@ -0,0 +1,40 @@
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

18
Dockerfile Normal file
View file

@ -0,0 +1,18 @@
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 libsass-dev libffi-dev openssl-dev \
&& nimble build -y -d:release -d:hostname=${HOSTNAME} \
&& nimble scss
FROM alpine
WORKDIR /src/
COPY --from=nim /src/nitter .
RUN apk add pcre-dev sqlite-dev
CMD ./nitter

View file

@ -91,7 +91,7 @@ class BaseTestCase(BaseCase):
super(BaseTestCase, self).tearDown() super(BaseTestCase, self).tearDown()
def open_nitter(self, page=''): def open_nitter(self, page=''):
self.open(f'http://localhost:5000/{page}') self.open(f'http://localhost:8080/{page}')
def search_username(self, username): def search_username(self, username):
self.open_nitter() self.open_nitter()