Skip to content
Merged
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
46 changes: 8 additions & 38 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,21 @@ permissions:
contents: read

jobs:
# Inspiration taken from https://jacobian.org/til/github-actions-poetry/
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version-file: "pyproject.toml"

- name: Cache Poetry install
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-1.1.14-0

- uses: snok/install-poetry@v1
with:
version: 1.1.14
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache dependencies
uses: actions/cache@v2
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies (if uncached)
run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'

- name: Install netplay-index
run: poetry install --no-interaction

- name: Run unit tests
run: poetry run pytest --cov=netplay_index
env:
GEOIP_DATABASE_PATH: testdata/GeoLite2-Country.mmdb
- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Upload coverage information
run: poetry run coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sync dependencies
run: uv sync --locked --all-extras --dev

- name: Check coding style
run: poetry run black --check .
run: uv run black --check .
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A NetPlay Index server for Dolphin.

## Requirements

- Python 3 and Poetry
- Python 3.10 and uv
- [GeoLite2 Country](https://dev.maxmind.com/geoip/geoip2/geolite2/)

## Setup
Expand All @@ -29,21 +29,21 @@ nix run github:dolphin-emu/netplay-index

### Without Nix

This project uses [Poetry](https://python-poetry.org/) for dependency
This project uses [uv](https://github.com/astral-sh/uv) for dependency
management.

```bash
# Install dependencies (use --no-dev to skip optional dev dependencies).
poetry install
# Install dependencies.
uv sync

# Run tests (Optional)
GEOIP_DATABASE_PATH=testdata/GeoLite2-Country.mmdb poetry run pytest
GEOIP_DATABASE_PATH=testdata/GeoLite2-Country.mmdb uv run pytest

# Creates a sysop account and gives you a randomly generated password (can be changed later)
poetry run netplay-index --add_sysop=SYSOP_NAME
uv run netplay-index --add_sysop=SYSOP_NAME

# Run the server
poetry run netplay-index
uv run netplay-index
```

## Contributing
Expand Down
151 changes: 66 additions & 85 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 46 additions & 25 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,54 @@
description = "Dolphin's NetPlay Index / Lobby Server";

inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
inputs.poetry2nix.url = "github:nix-community/poetry2nix";
inputs.poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";

outputs = { self, nixpkgs, flake-utils, poetry2nix }: {
overlay = nixpkgs.lib.composeManyExtensions [
poetry2nix.overlays.default
(final: prev: {
netplay-index = prev.poetry2nix.mkPoetryApplication {
projectDir = ./.;
checkPhase = "GEOIP_DATABASE_PATH=testdata/GeoLite2-Country.mmdb ASYNC_TEST_TIMEOUT=30 pytest";
inputs.uv2nix.url = "github:pyproject-nix/uv2nix";
inputs.uv2nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.uv2nix.inputs.pyproject-nix.follows = "pyproject-nix";

inputs.pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
inputs.pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";

inputs.pyproject-build-systems.url = "github:pyproject-nix/build-system-pkgs";
inputs.pyproject-build-systems.inputs.nixpkgs.follows = "nixpkgs";
inputs.pyproject-build-systems.inputs.pyproject-nix.follows = "pyproject-nix";

outputs = { self, nixpkgs, flake-utils, uv2nix, pyproject-nix, pyproject-build-systems }:
let
perSystem = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
overlay = workspace.mkPyprojectOverlay {
sourcePreference = "wheel";
};
})
];
} // (flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlay ];
};
in rec {
packages.netplay-index = pkgs.netplay-index;
defaultPackage = pkgs.netplay-index;
python = pkgs.python310;
pythonSet =
(pkgs.callPackage pyproject-nix.build.packages { inherit python; })
.overrideScope (pkgs.lib.composeManyExtensions [
pyproject-build-systems.overlays.default
overlay
]);
venv = pythonSet.mkVirtualEnv "netplay-index-env" workspace.deps.default;
in {
packages.netplay-index = venv;
packages.default = venv;

devShells.default = with pkgs; mkShell {
buildInputs = [ python3Packages.poetry ];
apps.default = {
type = "app";
program = "${venv}/bin/netplay-index";
};

devShells.default = with pkgs; mkShell {
packages = [ uv ];
};
});
in
perSystem // {
overlays.default = final: prev: {
netplay-index = self.packages.${final.system}.netplay-index;
};
}
));
overlay = self.overlays.default;
};
}
Loading