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
36 changes: 8 additions & 28 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +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.3.0-0

- uses: snok/install-poetry@v1
with:
version: 1.3.0
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 uv
uses: astral-sh/setup-uv@v6

- name: Install analytics-ingest
run: poetry install --no-interaction
- name: Sync dependencies
run: uv sync --locked --all-extras --dev

- name: Check coding style
run: poetry run black --check .
run: uv run black --check .
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ without requiring server side changes.

## Requirements

- Python 3 and Poetry
- Python 3 and uv
- ClickHouse

## Setup
Expand All @@ -23,15 +23,15 @@ nix run github:dolphin-emu/analytics-ingest

### 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 the server
poetry run analytics-ingest
uv run analytics-ingest
```

## License
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.

70 changes: 46 additions & 24 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,54 @@
description = "Dolphin's Analytics ingest 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: {
analytics-ingest = prev.poetry2nix.mkPoetryApplication {
projectDir = ./.;
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.analytics-ingest = pkgs.analytics-ingest;
defaultPackage = pkgs.analytics-ingest;
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 "analytics-ingest-env" workspace.deps.default;
in {
packages.analytics-ingest = venv;
packages.default = venv;

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

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