Skip to content

Commit

Permalink
[WIP] Migrate to GitHub actions (#695)
Browse files Browse the repository at this point in the history
* Fix exposed ports

* Add flake8 config

* Add github actions

* Remove travis.yml
  • Loading branch information
Askaholic authored Dec 28, 2020
1 parent 315012f commit 28117f8
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 46 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Build docker image
name: Build

on:
release:
types: [published, created, edited]

jobs:
docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build and publish docker image
uses: docker/[email protected]
with:
repository: faforever/faf-python-server
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
build-args: GITHUB_REF=${GITHUB_REF}
tag_with_ref: true
69 changes: 69 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Run unit tests
name: Test

on: [push, pull_request]

env:
FAF_DB_VERSION: v106

jobs:
static-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install dependencies with pipenv
run: |
pip install pipenv
pipenv sync --dev
pipenv install --dev isort flake8
- run: pipenv run isort --recursive --diff
- run: pipenv run flake8

unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Setup Database
run: |
git clone https://github.com/FAForever/db.git faf-db
&& pushd faf-db
&& git checkout ${FAF_DB_VERSION}
&& ./ci/bootstrap.sh
&& popd
docker exec -i faf-db mysql -uroot -pbanana faf -e "select * from login;"

- name: Install dependencies with pipenv
run: |
pip install pipenv
pipenv sync --dev
- run: pipenv run tests
- run: sed -i.bak s#/code/#$(pwd)/#g .coverage
- run: coveralls

docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build docker image
run: docker build --build-arg GITHUB_REF -t test_image .

- name: Test image
run: |
docker run --rm -d --name test_container -p 8000:8000 test_image
docker run --link test_container:test_container waisbrot/wait
nc -z localhost 8001
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ RUN pipenv install --ignore-pipfile --system --deploy

ADD . /code/

ARG TRAVIS_TAG
ENV VERSION=$TRAVIS_TAG
ARG GITHUB_REF
ENV VERSION=$GITHUB_REF
RUN python3 -m pip install -e .

# Main entrypoint and the default command that will be run
CMD ["/usr/local/bin/python3", "server.py"]

# Game server runs on 8000/tcp, lobby server runs on 8001/tcp, nat echo server runs on 30351/udp
EXPOSE 8000 8001 30351
# lobby server runs on 8001/tcp (QDataStream) and 8002/tcp (JSON)
EXPOSE 8001 8002

RUN python3 -V
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
multi_line_output=3
known_first_party=server,tests,integration_tests
default_section=THIRDPARTY

[flake8]
ignore=E501,F405
exclude=server/db/models.py

0 comments on commit 28117f8

Please sign in to comment.