Repository: railwayapp/nixpacks
Pull request #434 (2022-08-23 10:06:37)

Run tests on multiple os
Run MSRV, generate plan & library tests on ubuntu, windows and macos

nebulatgs: Can we also run the MSRV tests on a matrix?

Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e4cabc2..6f5fe9f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -74,7 +74,10 @@ jobs:
 
   test-plan:
     name: Test Suite
-    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        os: [ubuntu-latest, windows-latest, macos-latest]
+    runs-on: ${{ matrix.os }}
     outputs:
       matrix: ${{ steps.docker-prep.outputs.matrix }}
     steps:      
@@ -102,6 +105,7 @@ jobs:
           args: --package nixpacks --lib --test generate_plan_tests
       - name: List docker tests (prep test-docker)
         id: docker-prep
+        if: matrix.os == 'ubuntu-latest'
         # generate list of tests in json format for test-docker
         run: |
           echo "::set-output name=matrix::{\"tests\":[\"$(cargo test -q --package nixpacks --test docker_run_tests -- --list --format=terse | sed -z 's/: test\n/\", \"/g' | sed 's/...$//')]}"
@@ -138,7 +142,10 @@ jobs:
 
   msrv:
     name: Test Suite (MSRV)
-    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        os: [ubuntu-latest, windows-latest, macos-latest]
+    runs-on: ${{ matrix.os }}
     steps:
       - name: Cancel Previous Runs
         uses: styfle/cancel-workflow-action@0.10.0
diff --git a/Cargo.lock b/Cargo.lock
index b950adb..adc87c2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -367,7 +367,7 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
 
 [[package]]
 name = "nixpacks"
-version = "0.3.9"
+version = "0.3.10"
 dependencies = [
  "anyhow",
  "base64",
diff --git a/Cargo.toml b/Cargo.toml
index 5bc0569..957f4c3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "nixpacks"
-version = "0.3.9"
+version = "0.3.10"
 edition = "2021"
 license = "MIT"
 authors = ["Railway <contact@railway.app>"]
diff --git a/src/providers/python.rs b/src/providers/python.rs
index eafb7c2..6f70b5c 100644
--- a/src/providers/python.rs
+++ b/src/providers/python.rs
@@ -97,16 +97,15 @@ impl PythonProvider {
 
         if PythonProvider::is_django(app, env)? && PythonProvider::is_using_postgres(app, env)? {
             // Django with Postgres requires postgresql and gcc on top of the original python packages
-            pkgs.append(&mut vec![Pkg::new("postgresql"), Pkg::new("gcc")]);
+            pkgs.append(&mut vec![Pkg::new("postgresql")]);
         }
 
         let mut setup_phase = Phase::setup(Some(pkgs));
 
-        // Numpy needs some C headers to be available
+        // Many Python packages need some C headers to be available
         // stdenv.cc.cc.lib -> https://discourse.nixos.org/t/nixos-with-poetry-installed-pandas-libstdc-so-6-cannot-open-shared-object-file/8442/3
-        if PythonProvider::uses_dep(app, "numpy")? || PythonProvider::uses_dep(app, "pandas")? {
-            setup_phase.add_pkgs_libs(vec!["zlib".to_string(), "stdenv.cc.cc.lib".to_string()]);
-        }
+        setup_phase.add_pkgs_libs(vec!["zlib".to_string(), "stdenv.cc.cc.lib".to_string()]);
+        setup_phase.add_nix_pkgs(vec![Pkg::new("gcc")]);
 
         Ok(Some(setup_phase))
     }
@@ -323,6 +322,7 @@ impl PythonProvider {
         ))
     }
 
+    #[allow(dead_code)]
     fn uses_dep(app: &App, dep: &str) -> Result<bool> {
         let requirements_usage = app.includes_file("requirements.txt")
             && app


Test patch:
diff --git a/tests/snapshots/generate_plan_tests__python.snap b/tests/snapshots/generate_plan_tests__python.snap
index 3fb2e00..db055f3 100644
--- a/tests/snapshots/generate_plan_tests__python.snap
+++ b/tests/snapshots/generate_plan_tests__python.snap
@@ -11,7 +11,14 @@ expression: plan
       "nixPackages": [
         {
           "name": "python38"
+        },
+        {
+          "name": "gcc"
         }
+      ],
+      "nixLibraries": [
+        "zlib",
+        "stdenv.cc.cc.lib"
       ]
     },
     {
diff --git a/tests/snapshots/generate_plan_tests__python_2.snap b/tests/snapshots/generate_plan_tests__python_2.snap
index 3a0a1bd..10a36da 100644
--- a/tests/snapshots/generate_plan_tests__python_2.snap
+++ b/tests/snapshots/generate_plan_tests__python_2.snap
@@ -11,7 +11,14 @@ expression: plan
       "nixPackages": [
         {
           "name": "python27"
+        },
+        {
+          "name": "gcc"
         }
+      ],
+      "nixLibraries": [
+        "zlib",
+        "stdenv.cc.cc.lib"
       ]
     },
     {
diff --git a/tests/snapshots/generate_plan_tests__python_2_runtime.snap b/tests/snapshots/generate_plan_tests__python_2_runtime.snap
index 3a0a1bd..10a36da 100644
--- a/tests/snapshots/generate_plan_tests__python_2_runtime.snap
+++ b/tests/snapshots/generate_plan_tests__python_2_runtime.snap
@@ -11,7 +11,14 @@ expression: plan
       "nixPackages": [
         {
           "name": "python27"
+        },
+        {
+          "name": "gcc"
         }
+      ],
+      "nixLibraries": [
+        "zlib",
+        "stdenv.cc.cc.lib"
       ]
     },
     {
diff --git a/tests/snapshots/generate_plan_tests__python_django.snap b/tests/snapshots/generate_plan_tests__python_django.snap
index 46e8335..61053dc 100644
--- a/tests/snapshots/generate_plan_tests__python_django.snap
+++ b/tests/snapshots/generate_plan_tests__python_django.snap
@@ -18,6 +18,10 @@ expression: plan
         {
           "name": "gcc"
         }
+      ],
+      "nixLibraries": [
+        "zlib",
+        "stdenv.cc.cc.lib"
       ]
     },
     {
diff --git a/tests/snapshots/generate_plan_tests__python_numpy.snap b/tests/snapshots/generate_plan_tests__python_numpy.snap
index bcbe113..db055f3 100644
--- a/tests/snapshots/generate_plan_tests__python_numpy.snap
+++ b/tests/snapshots/generate_plan_tests__python_numpy.snap
@@ -11,6 +11,9 @@ expression: plan
       "nixPackages": [
         {
           "name": "python38"
+        },
+        {
+          "name": "gcc"
         }
       ],
       "nixLibraries": [
diff --git a/tests/snapshots/generate_plan_tests__python_poetry.snap b/tests/snapshots/generate_plan_tests__python_poetry.snap
index 6d8794c..862dede 100644
--- a/tests/snapshots/generate_plan_tests__python_poetry.snap
+++ b/tests/snapshots/generate_plan_tests__python_poetry.snap
@@ -14,7 +14,14 @@ expression: plan
       "nixPackages": [
         {
           "name": "python38"
+        },
+        {
+          "name": "gcc"
         }
+      ],
+      "nixLibraries": [
+        "zlib",
+        "stdenv.cc.cc.lib"
       ]
     },
     {
diff --git a/tests/snapshots/generate_plan_tests__python_procfile.snap b/tests/snapshots/generate_plan_tests__python_procfile.snap
index 242396d..742d163 100644
--- a/tests/snapshots/generate_plan_tests__python_procfile.snap
+++ b/tests/snapshots/generate_plan_tests__python_procfile.snap
@@ -11,7 +11,14 @@ expression: plan
       "nixPackages": [
         {
           "name": "python38"
+        },
+        {
+          "name": "gcc"
         }
+      ],
+      "nixLibraries": [
+        "zlib",
+        "stdenv.cc.cc.lib"
       ]
     },
     {
diff --git a/tests/snapshots/generate_plan_tests__python_setuptools.snap b/tests/snapshots/generate_plan_tests__python_setuptools.snap
index fce379f..63fa064 100644
--- a/tests/snapshots/generate_plan_tests__python_setuptools.snap
+++ b/tests/snapshots/generate_plan_tests__python_setuptools.snap
@@ -11,7 +11,14 @@ expression: plan
       "nixPackages": [
         {
           "name": "python38"
+        },
+        {
+          "name": "gcc"
         }
+      ],
+      "nixLibraries": [
+        "zlib",
+        "stdenv.cc.cc.lib"
       ]
     },
     {