diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 4eb51184a..9e98644bb 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -5,10 +5,10 @@ on: [push,pull_request] jobs: build-ubuntu: - runs-on: [ubuntu-22.04] + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run project tests run: | @@ -24,7 +24,6 @@ jobs: set -e set -x cd _unittests - ln -s .. cmake CMAKE_BIN="cmake" $CMAKE_BIN --version $CMAKE_BIN -P test_pkg-config.cmake diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 000000000..e63a4d5a5 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,25 @@ +name: "CI - Nix" + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + tests: + name: "Nix build on ${{ matrix.os }}" + runs-on: "${{ matrix.os }}-latest" + strategy: + matrix: + os: [ubuntu, macos] + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + - uses: cachix/cachix-action@v15 + with: + name: gepetto + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - run: nix build -L diff --git a/.github/workflows/update-flake-lock.yml b/.github/workflows/update-flake-lock.yml new file mode 100644 index 000000000..9d44212ea --- /dev/null +++ b/.github/workflows/update-flake-lock.yml @@ -0,0 +1,19 @@ +name: update-flake-lock + +on: + workflow_dispatch: + schedule: + - cron: '0 19 3 * *' + +jobs: + lockfile: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + - name: Update flake.lock + uses: DeterminateSystems/update-flake-lock@main + with: + token: ${{ secrets.GH_TOKEN_FOR_UPDATES }} diff --git a/_unittests/cmake b/_unittests/cmake new file mode 120000 index 000000000..a96aa0ea9 --- /dev/null +++ b/_unittests/cmake @@ -0,0 +1 @@ +.. \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..0e305811e --- /dev/null +++ b/flake.lock @@ -0,0 +1,58 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1738453229, + "narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1739736696, + "narHash": "sha256-zON2GNBkzsIyALlOCFiEBcIjI4w38GYOb+P+R4S8Jsw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d74a2335ac9c133d6bbec9fc98d91a77f1604c1f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1738452942, + "narHash": "sha256-vJzFZGaCpnmo7I6i416HaBLpC+hvcURh/BQwROcGIp8=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..ec4d11f73 --- /dev/null +++ b/flake.nix @@ -0,0 +1,55 @@ +{ + description = "CMake utility toolbox"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = inputs.nixpkgs.lib.systems.flakeExposed; + perSystem = + { pkgs, self', ... }: + { + packages = { + default = self'.packages.jrl-cmakemodules; + jrl-cmakemodules = pkgs.jrl-cmakemodules.overrideAttrs (super: { + src = pkgs.lib.fileset.toSource { + root = ./.; + fileset = pkgs.lib.fileset.gitTracked ./.; + }; + + # TODO: remove all this once it is in nixpkgs + postPatch = '' + patchShebangs _unittests/run_unit_tests.sh + ''; + + outputs = [ "out" "doc" ]; + nativeBuildInputs = super.nativeBuildInputs ++ [ + pkgs.sphinxHook + ]; + sphinxRoot = "../.docs"; + + doCheck = true; + checkInputs = [ + pkgs.python3 + ]; + checkPhase = '' + runHook preCheck + + pushd ../_unittests + ./run_unit_tests.sh + cmake -P test_pkg-config.cmake + + rm -rf build install + popd + + runHook postCheck + ''; + }); + }; + }; + }; +}