Skip to content

Commit

Permalink
test for #21
Browse files Browse the repository at this point in the history
  • Loading branch information
hraban committed Mar 17, 2024
1 parent 228340c commit 5204fe3
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
125 changes: 125 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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";
};
});
}
48 changes: 48 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -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="[email protected]"
export GIT_COMMITTER_NAME="Test"
export GIT_COMMITTER_EMAIL="[email protected]"

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

0 comments on commit 5204fe3

Please sign in to comment.