Skip to content

Commit

Permalink
Problem: ci test dependency install fail (#140)
Browse files Browse the repository at this point in the history
* Problem: ci test dependency install fail

Solution:
- switch to nix

* Update .github/workflows/test.yml

Signed-off-by: yihuang <[email protected]>

* fix workflow

* add magic cache

---------

Signed-off-by: yihuang <[email protected]>
  • Loading branch information
yihuang authored Oct 14, 2024
1 parent ef603d0 commit 7b83d80
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 30 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v15
- uses: cachix/install-nix-action@v30
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Run linting
run: nix develop -c make lint-ci
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: python3 -m pip install --user --upgrade poetry
- name: install
run: poetry install
- uses: cachix/install-nix-action@v30
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Run tests
run: make test
run: nix develop -c python -mpytest -vv -s
nix-flake:
runs-on: ubuntu-latest
steps:
Expand Down
62 changes: 40 additions & 22 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,53 @@
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
(flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
flake-utils,
poetry2nix,
}:
(flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = (import nixpkgs {
inherit system;
config = { };
overlays = [
poetry2nix.overlays.default
];
});
overrides = pkgs.poetry2nix.overrides.withDefaults (self: super:
pkgs = (
import nixpkgs {
inherit system;
config = { };
overlays = [
poetry2nix.overlays.default
];
}
);
overrides = pkgs.poetry2nix.overrides.withDefaults (
self: super:
let
buildSystems = {
durations = [ "setuptools" ];
multitail2 = [ "setuptools" ];
pytest-github-actions-annotate-failures = [ "setuptools" ];
flake8-black = [ "setuptools" ];
flake8-isort = [ "hatchling" ];
docker = [ "hatchling" "hatch-vcs" ];
docker = [
"hatchling"
"hatch-vcs"
];
};
in
pkgs.lib.mapAttrs
(attr: systems: super.${attr}.overridePythonAttrs
(old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems;
}))
buildSystems
pkgs.lib.mapAttrs (
attr: systems:
super.${attr}.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems;
})
) buildSystems
);
in
rec {
packages.default = pkgs.poetry2nix.mkPoetryApplication
{
projectDir = ./.;
inherit overrides;
};
packages.default = pkgs.poetry2nix.mkPoetryApplication {
projectDir = ./.;
inherit overrides;
};
apps.default = {
type = "app";
program = "${packages.default}/bin/pystarport";
Expand All @@ -53,6 +65,12 @@
projectDir = ./.;
inherit overrides;
})
(pkgs.poetry2nix.mkPoetryEditablePackage {
projectDir = ./.;
editablePackageSources = {
pystarport = ./pystarport;
};
})
];
};
}
Expand Down
6 changes: 4 additions & 2 deletions pystarport/tests/test_expansion/test_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ def test_expansion(type, func):
}
}

path = Path(__file__).parent

# overriding dotenv with absolute path is expanded and has diff
dotenv = os.path.abspath("test_expansion/dotenv1")
dotenv = os.path.abspath(path / "dotenv1")
config = func(cronos_has_dotenv, dotenv)
assert DeepDiff(
base_config,
Expand All @@ -72,7 +74,7 @@ def test_expansion(type, func):
}

# overriding dotenv with absolute path is expanded and no diff
dotenv = os.path.abspath("test_expansion/dotenv")
dotenv = os.path.abspath(path / "dotenv")
config = func(cronos_has_posix_no_dotenv, dotenv)
assert not DeepDiff(
base_config,
Expand Down

0 comments on commit 7b83d80

Please sign in to comment.