mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-06 01:31:39 -05:00
Redefine Github Actions in Nix using nix-github-actions
This commit is contained in:
parent
11b4de721e
commit
3f72aebfae
4 changed files with 85 additions and 56 deletions
43
.github/ci.nix
vendored
Normal file
43
.github/ci.nix
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
let
|
||||||
|
sources = import ../nix/sources.nix;
|
||||||
|
|
||||||
|
inherit (import sources.nix-github-actions) mkGithubMatrix;
|
||||||
|
|
||||||
|
mkPkgs = system: import sources.nixpkgs {
|
||||||
|
config = {
|
||||||
|
allowAliases = false;
|
||||||
|
allowInsecurePredicate = x: true;
|
||||||
|
};
|
||||||
|
overlays = [
|
||||||
|
(import ../overlay.nix)
|
||||||
|
];
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
mkGithubMatrix {
|
||||||
|
attrPrefix = "";
|
||||||
|
checks = {
|
||||||
|
x86_64-linux =
|
||||||
|
let
|
||||||
|
pkgs = mkPkgs "x86_64-linux";
|
||||||
|
in
|
||||||
|
import ../tests { inherit pkgs; };
|
||||||
|
|
||||||
|
x86_64-darwin =
|
||||||
|
let
|
||||||
|
pkgs = mkPkgs "x86_64-darwin";
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
|
||||||
|
|
||||||
|
tests = import ../tests { inherit pkgs; };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Aggregate all tests into one derivation so that only one GHA runner is scheduled for all darwin jobs
|
||||||
|
aggregate = pkgs.runCommand "darwin-aggregate"
|
||||||
|
{
|
||||||
|
env.TEST_INPUTS = (lib.concatStringsSep " " (lib.attrValues (lib.filterAttrs (n: v: lib.isDerivation v) tests)));
|
||||||
|
} "touch $out";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
41
.github/workflows/ci.yml
vendored
41
.github/workflows/ci.yml
vendored
|
@ -43,58 +43,39 @@ jobs:
|
||||||
- name: Check format
|
- name: Check format
|
||||||
run: nix-shell --arg packages 'pkgs:[ pkgs.p2nix-tools.env ]' --run 'black --check .'
|
run: nix-shell --arg packages 'pkgs:[ pkgs.p2nix-tools.env ]' --run 'black --check .'
|
||||||
|
|
||||||
matrix_generate:
|
nix-matrix:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: cachix/install-nix-action@v22
|
- uses: cachix/install-nix-action@v22
|
||||||
with:
|
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
|
||||||
- id: set-matrix
|
- id: set-matrix
|
||||||
|
name: Generate Nix Matrix
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -Eeu
|
||||||
|
echo "matrix=$(nix eval --json -f ./.github/ci.nix matrix)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
matrix="$(nix-instantiate --eval --json --expr 'builtins.attrNames (import ./tests {})' | jq -rcM '{attr: .}')"
|
nix-build:
|
||||||
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
|
needs: nix-matrix
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
builds-linux:
|
|
||||||
needs: matrix_generate
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix: ${{fromJSON(needs.matrix_generate.outputs.matrix)}}
|
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: cachix/install-nix-action@v22
|
- uses: cachix/install-nix-action@v22
|
||||||
with:
|
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
|
||||||
- uses: cachix/cachix-action@v12
|
- uses: cachix/cachix-action@v12
|
||||||
with:
|
with:
|
||||||
name: poetry2nix
|
name: poetry2nix
|
||||||
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
|
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
|
||||||
- run: nix-build --keep-going --show-trace tests/default.nix -A '${{ matrix.attr }}'
|
- run: nix-build --keep-going --show-trace .github/ci.nix -A '${{ matrix.attr }}'
|
||||||
|
|
||||||
builds-macos:
|
|
||||||
runs-on: macos-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: cachix/install-nix-action@v22
|
|
||||||
with:
|
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
|
||||||
- uses: cachix/cachix-action@v12
|
|
||||||
with:
|
|
||||||
name: poetry2nix
|
|
||||||
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
|
|
||||||
- run: nix-build --keep-going --show-trace tests/default.nix -A '${{ matrix.attr }}'
|
|
||||||
|
|
||||||
collect:
|
collect:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- nixpkgs-fmt
|
- nixpkgs-fmt
|
||||||
- black-fmt
|
- black-fmt
|
||||||
- builds-linux
|
- nix-build
|
||||||
- builds-macos
|
|
||||||
- sort-build-systems
|
- sort-build-systems
|
||||||
steps:
|
steps:
|
||||||
- run: exit 0
|
- run: true
|
||||||
|
|
|
@ -1,4 +1,16 @@
|
||||||
{
|
{
|
||||||
|
"nix-github-actions": {
|
||||||
|
"branch": "master",
|
||||||
|
"description": "A library to turn Nix Flake attribute sets into Github Actions matrices [maintainer=@adisbladis]",
|
||||||
|
"homepage": "",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nix-github-actions",
|
||||||
|
"rev": "165b1650b753316aa7f1787f3005a8d2da0f5301",
|
||||||
|
"sha256": "0rkh2dcnl4rna4snqd7cdnvddjyqrgj3rais0dkhs4ygz64j8ip1",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/nix-community/nix-github-actions/archive/165b1650b753316aa7f1787f3005a8d2da0f5301.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
|
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
|
||||||
|
|
|
@ -18,14 +18,11 @@ let
|
||||||
pep425 = pkgs.callPackage ../pep425.nix { inherit poetryLib; python = pkgs.python3; };
|
pep425 = pkgs.callPackage ../pep425.nix { inherit poetryLib; python = pkgs.python3; };
|
||||||
pep425PythonOldest = pkgs.callPackage ../pep425.nix { inherit poetryLib; python = pkgs.python38; };
|
pep425PythonOldest = pkgs.callPackage ../pep425.nix { inherit poetryLib; python = pkgs.python38; };
|
||||||
pep425OSX = pkgs.callPackage ../pep425.nix { inherit poetryLib; isLinux = false; python = pkgs.python3; };
|
pep425OSX = pkgs.callPackage ../pep425.nix { inherit poetryLib; isLinux = false; python = pkgs.python3; };
|
||||||
skipTests = builtins.filter (t: builtins.typeOf t != "list") (builtins.split "," (builtins.getEnv "SKIP_TESTS"));
|
|
||||||
callTest = test: attrs: pkgs.callPackage test ({ inherit poetry2nix; } // attrs);
|
callTest = test: attrs: pkgs.callPackage test ({ inherit poetry2nix; } // attrs);
|
||||||
|
|
||||||
# HACK: Return null on MacOS since the test in question fails
|
inherit (pkgs) lib stdenv;
|
||||||
skipOSX = drv: if pkgs.stdenv.isDarwin then builtins.trace "Note: Skipping ${drv.name} on OSX" (pkgs.runCommand drv.name { } "touch $out") else drv;
|
|
||||||
|
|
||||||
in
|
in
|
||||||
builtins.removeAttrs
|
|
||||||
{
|
{
|
||||||
trivial = callTest ./trivial { };
|
trivial = callTest ./trivial { };
|
||||||
|
|
||||||
|
@ -39,7 +36,6 @@ builtins.removeAttrs
|
||||||
common-pkgs-1 = callTest ./common-pkgs-1 { };
|
common-pkgs-1 = callTest ./common-pkgs-1 { };
|
||||||
common-pkgs-2 = callTest ./common-pkgs-2 { };
|
common-pkgs-2 = callTest ./common-pkgs-2 { };
|
||||||
pep425 = pkgs.callPackage ./pep425 { inherit pep425; inherit pep425OSX; inherit pep425PythonOldest; };
|
pep425 = pkgs.callPackage ./pep425 { inherit pep425; inherit pep425OSX; inherit pep425PythonOldest; };
|
||||||
pep600 = skipOSX (callTest ./pep600 { });
|
|
||||||
env = callTest ./env { };
|
env = callTest ./env { };
|
||||||
pytest-metadata = callTest ./pytest-metadata { };
|
pytest-metadata = callTest ./pytest-metadata { };
|
||||||
pytest-randomly = callTest ./pytest-randomly { };
|
pytest-randomly = callTest ./pytest-randomly { };
|
||||||
|
@ -62,25 +58,16 @@ builtins.removeAttrs
|
||||||
inherit poetry;
|
inherit poetry;
|
||||||
inherit (pkgs) postgresql;
|
inherit (pkgs) postgresql;
|
||||||
};
|
};
|
||||||
# pyqt5 = skipOSX (callTest ./pyqt5 { });
|
|
||||||
extras = callTest ./extras { };
|
extras = callTest ./extras { };
|
||||||
source-filter = callTest ./source-filter { };
|
source-filter = callTest ./source-filter { };
|
||||||
canonical-module-names = callTest ./canonical-module-names { };
|
canonical-module-names = callTest ./canonical-module-names { };
|
||||||
wandb = callTest ./wandb { };
|
wandb = callTest ./wandb { };
|
||||||
utf8-pyproject = callTest ./utf8-pyproject { };
|
utf8-pyproject = callTest ./utf8-pyproject { };
|
||||||
|
|
||||||
# Test deadlocks on darwin, sandboxing issue?
|
|
||||||
dependency-environment = skipOSX (callTest ./dependency-environment { });
|
|
||||||
|
|
||||||
# Editable tests fails on Darwin because of sandbox paths
|
|
||||||
editable = skipOSX (callTest ./editable { });
|
|
||||||
editable-egg = skipOSX (callTest ./editable-egg { });
|
|
||||||
|
|
||||||
ansible-molecule = callTest ./ansible-molecule { };
|
ansible-molecule = callTest ./ansible-molecule { };
|
||||||
bcrypt = callTest ./bcrypt { };
|
bcrypt = callTest ./bcrypt { };
|
||||||
mk-poetry-packages = callTest ./mk-poetry-packages { };
|
mk-poetry-packages = callTest ./mk-poetry-packages { };
|
||||||
markupsafe2 = callTest ./markupsafe2 { };
|
markupsafe2 = callTest ./markupsafe2 { };
|
||||||
pendulum = skipOSX (callTest ./pendulum { });
|
|
||||||
# uwsgi = callTest ./uwsgi { }; # Commented out because build is flaky (unrelated to poetry2nix)
|
# uwsgi = callTest ./uwsgi { }; # Commented out because build is flaky (unrelated to poetry2nix)
|
||||||
jq = callTest ./jq { };
|
jq = callTest ./jq { };
|
||||||
ubersmith = callTest ./ubersmith { };
|
ubersmith = callTest ./ubersmith { };
|
||||||
|
@ -94,12 +81,6 @@ builtins.removeAttrs
|
||||||
watchfiles = callTest ./watchfiles { };
|
watchfiles = callTest ./watchfiles { };
|
||||||
sqlalchemy = callTest ./sqlalchemy { };
|
sqlalchemy = callTest ./sqlalchemy { };
|
||||||
tzlocal = callTest ./tzlocal { };
|
tzlocal = callTest ./tzlocal { };
|
||||||
text-generation-webui = skipOSX (callTest ./text-generation-webui { });
|
|
||||||
|
|
||||||
# Cross tests fail on darwin for some strange reason:
|
|
||||||
# ERROR: MarkupSafe-2.0.1-cp39-cp39-linux_aarch64.whl is not a supported wheel on this platform.
|
|
||||||
extended-cross = skipOSX (callTest ./extended-cross { });
|
|
||||||
trivial-cross = skipOSX (callTest ./trivial-cross { });
|
|
||||||
|
|
||||||
ml-stack = callTest ./ml-stack { };
|
ml-stack = callTest ./ml-stack { };
|
||||||
|
|
||||||
|
@ -171,11 +152,23 @@ builtins.removeAttrs
|
||||||
cairocffi-no-wheel = callTest ./cairocffi-no-wheel { };
|
cairocffi-no-wheel = callTest ./cairocffi-no-wheel { };
|
||||||
rpds-py = callTest ./rpds-py { };
|
rpds-py = callTest ./rpds-py { };
|
||||||
|
|
||||||
# Currently broken
|
} // lib.optionalAttrs (!stdenv.isDarwin) {
|
||||||
# pandas = callTest ./pandas { };
|
# pyqt5 = (callTest ./pyqt5 { });
|
||||||
# Inherit test cases from nixpkgs
|
|
||||||
# nixops = pkgs.nixops;
|
|
||||||
nixops_unstable = skipOSX pkgs.nixops_unstable;
|
|
||||||
|
|
||||||
|
# Test deadlocks on darwin, sandboxing issue?
|
||||||
|
dependency-environment = (callTest ./dependency-environment { });
|
||||||
|
|
||||||
|
# Editable tests fails on Darwin because of sandbox paths
|
||||||
|
pep600 = (callTest ./pep600 { });
|
||||||
|
editable = (callTest ./editable { });
|
||||||
|
editable-egg = (callTest ./editable-egg { });
|
||||||
|
pendulum = (callTest ./pendulum { });
|
||||||
|
|
||||||
|
# Fails because of missing inputs on darwin
|
||||||
|
text-generation-webui = callTest ./text-generation-webui { };
|
||||||
|
|
||||||
|
# Cross tests fail on darwin for some strange reason:
|
||||||
|
# ERROR: MarkupSafe-2.0.1-cp39-cp39-linux_aarch64.whl is not a supported wheel on this platform.
|
||||||
|
extended-cross = (callTest ./extended-cross { });
|
||||||
|
trivial-cross = (callTest ./trivial-cross { });
|
||||||
}
|
}
|
||||||
skipTests
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue