Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
ci: add new tests workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
imincik committed Apr 12, 2024
1 parent 6ddf2b1 commit 214fc38
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ jobs:
--command python -c "import fiona; print(fiona.supported_drivers)"
launch-test:
needs: build-packages
uses: ./.github/workflows/test.yml
secrets: inherit

launch-test-geonixcli:
needs: build-packages
uses: ./.github/workflows/test-geonixcli.yml
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test

on:
pull_request:
push:
branches:
- master
workflow_dispatch:

env:
NIX_CONFIG: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}"

jobs:
test:
strategy:
fail-fast: false
matrix:
test:
- custom-package
os:
- ubuntu-22.04
# - macos-11

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install nix
uses: cachix/install-nix-action@v26

- name: Setup cachix
uses: cachix/cachix-action@v14
with:
name: geonix
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Run test
run: bash ./test.sh
working-directory: tests/${{ matrix.test }}
44 changes: 44 additions & 0 deletions tests/custom-package/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
description = "Geospatial NIX";

nixConfig = {
extra-substituters = [
"https://geonix.cachix.org"
];
extra-trusted-public-keys = [
"geonix.cachix.org-1:iyhIXkDLYLXbMhL3X3qOLBtRF8HEyAbhPXjjPeYsCl0="
];
bash-prompt = "\\[\\033[1m\\][geonix]\\[\\033\[m\\]\\040\\w >\\040";
};

inputs = {
geonix.url = "github:imincik/geospatial-nix";
nixpkgs.follows = "geonix/nixpkgs";
};

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {

imports = [
# inputs.geoenv.flakeModule
];

systems = [ "x86_64-linux" ];

perSystem = { config, self', inputs', pkgs, system, ... }: {
packages =
let
geopkgs = inputs.geonix.lib.customizePackages {
nixpkgs = pkgs;
geopkgs = inputs.geonix.packages.${pkgs.system};
overridesFile = ./overrides.nix;
};
in
{
gdal = geopkgs.gdal;
};
};

flake = { };
};
}
15 changes: 15 additions & 0 deletions tests/custom-package/gdal.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- a/overrides.nix
+++ b/overrides.nix
@@ -67,6 +67,12 @@ rec {

# >>> CUSTOMIZE HERE

+ version = "1000.0.0";
+
+ postPatch = ''
+ substituteInPlace apps/gdalinfo_bin.cpp --replace "Usage: gdalinfo" "Usage: gdalinfo (patched)"
+ '';
+
})).override { inherit geos libgeotiff libspatialite proj tiledb; useJava = false; };
_gdal = gdal;

1 change: 1 addition & 0 deletions tests/custom-package/overrides.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# overrides.nix file placeholder
10 changes: 10 additions & 0 deletions tests/custom-package/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail


cp ../../overrides.nix overrides.nix
patch -u overrides.nix -i gdal.patch

"$(nix build --accept-flake-config --no-link --print-out-paths .#gdal)"/bin/gdalinfo --help \
| grep "Usage: gdalinfo (patched)"

0 comments on commit 214fc38

Please sign in to comment.