Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove nix #291

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Dockerize
run: make dockerize
- name: Deploy to DockerHub
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ jobs:
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
poetry-version: [1.1.6]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: pip install poetry==${{ matrix.poetry-version }}
- name: Install requirements
run: pip install -r requirements_frozen.txt
run: poetry install
- name: Run tests
run: pytest
run: poetry run pytest
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ ENV/
*.egg-info
.coverage
.pytest_cache

# nix stuff
result
result-*
/MANIFEST
/build/
/dist/

# Editor
*.sw[po]
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.9-slim AS builder

ARG POETRY_VERSION=1.1.4
RUN pip install poetry==$POETRY_VERSION

WORKDIR /src

COPY pyproject.toml poetry.lock README.md pylintrc ./
COPY marge/ ./marge/
RUN poetry export -o requirements.txt && \
poetry build


FROM python:3.9-slim

RUN apt-get update && apt-get install -y \
git-core \
&& \
rm -rf /var/lib/apt/lists/*

COPY --from=builder /src/requirements.txt /src/dist/marge-*.tar.gz /tmp/

RUN pip install -r /tmp/requirements.txt && \
pip install /tmp/marge-*.tar.gz

ENTRYPOINT ["marge"]
36 changes: 19 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
VERSION?=$$(git rev-parse --abbrev-ref HEAD)

.PHONY: all
all: requirements_frozen.txt requirements.nix requirements_override.nix marge-bot dockerize
all: dockerize

.PHONY: marge-bot
marge-bot:
nix-build --keep-failed --attr marge-bot default.nix
.PHONY: bump
bump: bump-requirements

.PHONY: clean
clean:
rm -rf .cache result result-* requirements_frozen.txt
poetry.lock:
poetry install

.PHONY: bump
bump: bump-requirements bump-sources
requirements.txt: poetry.lock
poetry export -o $@

.PHONY: bump-sources
bump-sources:
nix-shell --run niv update
requirements_development.txt: poetry.lock
poetry export --dev -o $@

.PHONY: bump-requirements
bump-requirements: clean requirements_frozen.txt
.PHONY: bump-poetry-lock
bump-poetry-lock:
poetry update

requirements_frozen.txt requirements.nix requirements_override.nix: requirements.txt
pypi2nix -V 3.6 -r $^
.PHONY: clean-requirements
clean-requirements:
rm -rf requirements.txt requirements_development.txt

.PHONY: bump-requirements
bump-requirements: bump-poetry-lock clean-requirements requirements.txt requirements_development.txt

.PHONY: dockerize
dockerize:
docker load --input $$(nix-build --attr docker-image default.nix)
docker build --tag smarkets/marge-bot:$$(cat version) .

.PHONY: docker-push
docker-push:
Expand Down
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,19 +364,8 @@ run:

### Running marge-bot as a plain python app

#### Installing marge-bot with nix

Alternatively, if you prefer not to use docker, you can also directly run marge.
If you use [nix](https://nixos.org/nix/) do `nix-env --install -f default.nix`.

The nix install should be fully reproducible on any version of linux (and also
work on OS X, although this is not something we properly test). If you don't
want to use docker we recommend you give nix a try.

#### Installing marge-bot the old-fashioned way

Finally, although this is our least preferred alternative, you can always do
`python3 setup.py install` (note that you will need python3.6).
You need to install the requirements first `pip install -r requirements_frozen.txt`,
and then install Marge itself `python3 setup.py install` (note that you will need python3.6+).

Afterwards, the minimal way to run marge is as follows.

Expand Down
6 changes: 0 additions & 6 deletions default.nix

This file was deleted.

40 changes: 0 additions & 40 deletions dockerize.nix

This file was deleted.

12 changes: 0 additions & 12 deletions marge.app

This file was deleted.

40 changes: 0 additions & 40 deletions marge.nix

This file was deleted.

19 changes: 19 additions & 0 deletions marge/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from marge.app import main


def run():
try:
main()
except Exception as err:
print('Exception occured')
if hasattr(err, 'stdout'):
# pylint: disable=no-member
print(f'stdout was: {err.stdout}')
if hasattr(err, 'stderr'):
# pylint: disable=no-member
print(f'stderr was: {err.stderr}')
raise


if __name__ == '__main__':
run()
25 changes: 0 additions & 25 deletions nix/sources.json

This file was deleted.

11 changes: 0 additions & 11 deletions nix/sources.nix

This file was deleted.

Loading