diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1088950 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,17 @@ +name: "CI/CD" + +"on": + push: {} + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v9 + - + name: "Test: integration test" + run: nix flake check diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3093a13 --- /dev/null +++ b/flake.lock @@ -0,0 +1,125 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1710066242, + "narHash": "sha256-bO7kahLdawW7rBqUTfWgf9mdPYrnOo5DGvWRJa9N8Do=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "db339f1706f555794b71aa4eb26a5a240fb6a599", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1703499205, + "narHash": "sha256-lF9rK5mSUfIZJgZxC3ge40tp1gmyyOXZ+lRY3P8bfbg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e1fa12d4f6c6fe19ccb59cac54b5b3f25e160870", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "tomono": "tomono" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "tomono": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1709233426, + "narHash": "sha256-aXCsAxmxAydDuQrOxOKvfazbyW21d4R0wVNYLuTMQ4k=", + "owner": "hraban", + "repo": "tomono", + "rev": "ea66e5a0a76de4f6625b99e100cb5bdc120e82b0", + "type": "github" + }, + "original": { + "owner": "hraban", + "repo": "tomono", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ceb4d58 --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + inputs = { + tomono.url = "github:hraban/tomono"; + }; + + outputs = { + self, nixpkgs, flake-utils, tomono + }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + checks.default = with pkgs; stdenvNoCC.mkDerivation { + name = "test"; + checkPhase = writeShellScript "test" (builtins.readFile ./test.sh); + doCheck = true; + dontUnpack = true; + nativeBuildInputs = [ moreutils git tomono.packages.${system}.default ]; + installPhase = "touch $out"; + }; + }); + } diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..657c804 --- /dev/null +++ b/test.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -euo pipefail +set -x + +# Ensure testing always works even on unconfigured CI etc +export GIT_AUTHOR_NAME="Test" +export GIT_AUTHOR_EMAIL="test@test.com" +export GIT_COMMITTER_NAME="Test" +export GIT_COMMITTER_EMAIL="test@test.com" + +d="$(mktemp -d)" +cd "$d" +pwd + +mkdir a +( + cd a + git init + (for i in {1..9} ; do echo $i ; done) > count.txt + git add count.txt + git commit -m "count from 1 to 9" + git checkout -b more-numbers + echo 10 >> count.txt + git add count.txt + git commit -m "append 10" +) + +echo "$PWD/a" a | tomono + +( + cd core/a + # In master + (echo 0; cat count.txt) | sponge count.txt + git add count.txt + git commit -m "count from 0" + # Continue dev + git checkout more-numbers + echo 11 >> count.txt + git add count.txt + git commit -m "count to 11" + # Merge it all + git checkout master + git merge more-numbers -m "merge dev" +) + +echo "Finished dev:" +cat core/a/count.txt