Skip to content

Commit

Permalink
More migration stuff, more endpoints, map categories
Browse files Browse the repository at this point in the history
- First attempt at a CI and make a docker file for tests

PR: #3
  • Loading branch information
alexlambson committed Feb 22, 2024
1 parent b5d2201 commit e638a70
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI
on:
pull_request:
push: { branches: main }

jobs:
test:
name: Run PyTest
runs-on: ubuntu-latest
env:
COMPOSE_FILE: docker-compose.yml

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Build docker images
run: docker-compose build

- name: Run PyTest
run: docker-compose run test
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ COPY requirements.txt /cncnet-map-api
COPY requirements-dev.txt /cncnet-map-api
COPY start.sh /cncnet-map-api

RUN apt-get update && apt-get install -y liblzo2-dev
RUN pip install --upgrade pip
RUN pip install -r ./requirements.txt
RUN pip install -r ./requirements-dev.txt
RUN CFLAGS=-I$(brew --prefix)/include LDFLAGS=-L$(brew --prefix)/lib pip install -r ./requirements-dev.txt

RUN chmod +x /cncnet-map-api/start.sh
ENTRYPOINT "/cncnet-map-api/start.sh"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Just set up your environment file and run the full docker compose.
- Setup the virtual environments `pyenv virtualenv 3.12 cncnet-map-api`
- Set the virtual enviornment for the directory `pyenv local cncnet-map-api`
6. Setup requirements `pip install -r requirements-dev.txt`
- On Apple Silicon you'll need to run
- On Apple Silicon you'll need to install lzo with `brew install lzo` then run
`CFLAGS=-I$(brew --prefix)/include LDFLAGS=-L$(brew --prefix)/lib pip install -r requirements-dev.txt`
to get `python-lzo` to install. You shouldn't need to include those flags again unless `python-lzo` updates.
7. Install the pre-commit hooks `pre-commit install`
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@ services:
- .env
depends_on:
- db
test:
build:
context: ./
dockerfile: test.DockerFile
volumes:
- .:/cncnet-map-api
env_file:
- .env
environment:
POSTGRES_TEST_HOST: db # Necessary to connect to docker db. Overrides the .env setting.
depends_on:
- db
command:
- pytest
17 changes: 17 additions & 0 deletions test.DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.12-bookworm as base

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /cncnet-map-api

# This is just here to crash the build if you don't make a .env file.
COPY .env /cncnet-map-api/

# Copy files needed for build
COPY requirements.txt /cncnet-map-api
COPY requirements-dev.txt /cncnet-map-api
COPY start.sh /cncnet-map-api

RUN apt-get update && apt-get install -y liblzo2-dev
RUN pip install --upgrade pip
RUN CFLAGS=-I$(brew --prefix)/include LDFLAGS=-L$(brew --prefix)/lib pip install -r requirements-dev.txt

0 comments on commit e638a70

Please sign in to comment.