From abbccb07a52f4a96b7768c04d800e811204932a6 Mon Sep 17 00:00:00 2001 From: justinsb Date: Sat, 29 Jul 2023 10:56:59 -0400 Subject: [PATCH 1/2] Add simple github actions Makes it easy for anyone to run tests on github, doesn't preclude us using prow also. --- .github/workflows/main.yml | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..7a4de1e46 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,48 @@ +--- +name: CI + +'on': + - push + - pull_request + +env: + GOPROXY: https://proxy.golang.org + GOPATH: ${{ github.workspace }}/go + +permissions: + contents: read + +jobs: + build-linux-amd64: + runs-on: ubuntu-latest + steps: + - name: Set up go + uses: actions/setup-go@v4 + with: + go-version: '1.20.6' + + - uses: actions/checkout@v3 + with: + path: git-sync + + - name: make all-build + working-directory: git-sync + run: | + make all-build + + test: + runs-on: ubuntu-latest + steps: + - name: Set up go + uses: actions/setup-go@v4 + with: + go-version: '1.20.6' + + - uses: actions/checkout@v3 + with: + path: git-sync + + - name: make test + working-directory: git-sync + run: | + make test From 91f41dc719fc42bcc35f6d5811a941445f673481 Mon Sep 17 00:00:00 2001 From: justinsb Date: Sat, 29 Jul 2023 11:03:21 -0400 Subject: [PATCH 2/2] tests: don't rely on global git configuration in tests Otherwise got: ``` test root is /tmp/git-sync-e2e.228068759 Author identity unknown *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. ``` --- test_e2e.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test_e2e.sh b/test_e2e.sh index 1e18bfe55..e9d288f8d 100755 --- a/test_e2e.sh +++ b/test_e2e.sh @@ -185,6 +185,17 @@ function clean_work() { mkdir -p "$WORK" } +# config_repo sets required git config, so we don't depend on (shared) global git config. +# +# Args: +# $1: directory of git repo +function config_repo() { + local repo=$1 + + git -C "$repo" config user.email "git-sync-test@example.com" + git -C "$repo" config user.name "git-sync-test" +} + # REPO and REPO2 are the source repos under test. REPO="$DIR/repo" REPO2="${REPO}2" @@ -193,6 +204,7 @@ function init_repo() { rm -rf "$REPO" mkdir -p "$REPO" git -C "$REPO" init -q -b "$MAIN_BRANCH" + config_repo "$REPO" touch "$REPO/file" git -C "$REPO" add file git -C "$REPO" commit -aqm "init file" @@ -374,6 +386,7 @@ function e2e::init_root_is_under_another_repo() { mkdir -p "$ROOT/subdir/root" date > "$ROOT/subdir/root/file" # so it is not empty git -C "$ROOT/subdir" init -q + config_repo "$ROOT/subdir" GIT_SYNC \ --one-time \ @@ -395,6 +408,7 @@ function e2e::init_root_fails_sanity() { # Make an invalid git repo. git -C "$ROOT" init -q + config_repo "$ROOT" echo "ref: refs/heads/nonexist" > "$ROOT/.git/HEAD" GIT_SYNC \ @@ -2380,6 +2394,7 @@ function e2e::submodule_sync_default() { mkdir "$SUBMODULE" git -C "$SUBMODULE" init -q -b "$MAIN_BRANCH" + config_repo "$SUBMODULE" echo "submodule" > "$SUBMODULE/submodule" git -C "$SUBMODULE" add submodule git -C "$SUBMODULE" commit -aqm "init submodule file" @@ -2390,6 +2405,7 @@ function e2e::submodule_sync_default() { mkdir "$NESTED_SUBMODULE" git -C "$NESTED_SUBMODULE" init -q -b "$MAIN_BRANCH" + config_repo "$NESTED_SUBMODULE" echo "nested-submodule" > "$NESTED_SUBMODULE/nested-submodule" git -C "$NESTED_SUBMODULE" add nested-submodule git -C "$NESTED_SUBMODULE" commit -aqm "init nested-submodule file" @@ -2486,6 +2502,7 @@ function e2e::submodule_sync_depth() { mkdir "$SUBMODULE" git -C "$SUBMODULE" init -q -b "$MAIN_BRANCH" + config_repo "$SUBMODULE" # First sync expected_depth="1" @@ -2566,6 +2583,7 @@ function e2e::submodule_sync_off() { mkdir "$SUBMODULE" git -C "$SUBMODULE" init -q -b "$MAIN_BRANCH" + config_repo "$SUBMODULE" echo "submodule" > "$SUBMODULE/submodule" git -C "$SUBMODULE" add submodule git -C "$SUBMODULE" commit -aqm "init submodule file" @@ -2596,6 +2614,7 @@ function e2e::submodule_sync_shallow() { mkdir "$SUBMODULE" git -C "$SUBMODULE" init -q -b "$MAIN_BRANCH" + config_repo "$SUBMODULE" echo "submodule" > "$SUBMODULE/submodule" git -C "$SUBMODULE" add submodule git -C "$SUBMODULE" commit -aqm "init submodule file" @@ -2606,6 +2625,7 @@ function e2e::submodule_sync_shallow() { mkdir "$NESTED_SUBMODULE" git -C "$NESTED_SUBMODULE" init -q -b "$MAIN_BRANCH" + config_repo "$NESTED_SUBMODULE" echo "nested-submodule" > "$NESTED_SUBMODULE/nested-submodule" git -C "$NESTED_SUBMODULE" add nested-submodule git -C "$NESTED_SUBMODULE" commit -aqm "init nested-submodule file" @@ -2642,6 +2662,7 @@ function e2e::submodule_sync_relative() { mkdir "$SUBMODULE" git -C "$SUBMODULE" init -q -b "$MAIN_BRANCH" + config_repo "$SUBMODULE" echo "submodule" > "$SUBMODULE/submodule" git -C "$SUBMODULE" add submodule git -C "$SUBMODULE" commit -aqm "init submodule file"