Skip to content

Commit c0158ce

Browse files
authored
gh-18 : fix git version 2.49.0 test problem (#19)
* gh-18 : fix git version 2.49.0 test problem * gh-18 : fix git version 2.49.0 test problem - handle debug * gh-18 : fix git version 2.49.0 test problem - handle logs * gh-18 : fix git version 2.49.0 test problem - handle logs - rm origin/HEAD pointer * gh-18 : fix git version 2.49.0 test problem - pr comments from ai-code-bot
1 parent 00ae9bc commit c0158ce

File tree

10 files changed

+126
-50
lines changed

10 files changed

+126
-50
lines changed

.github/workflows/pr.yml

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,100 @@ on:
66
branches: [ "main" ]
77
pull_request:
88
branches: [ "main" ]
9+
schedule:
10+
- cron: '0 0 1 * *'
911

1012
# Allows you to run this workflow manually from the Actions tab
1113
workflow_dispatch:
12-
14+
inputs:
15+
debug:
16+
description: 'Enable debug mode'
17+
type: boolean
18+
required: false
19+
default: false
20+
verbose:
21+
description: 'Enable verbose output'
22+
type: boolean
23+
required: false
24+
default: true
25+
1326
jobs:
1427
test-git-native:
1528
runs-on: ubuntu-latest
1629

1730
steps:
1831
- name: Checkout code
19-
uses: actions/checkout@v2
32+
uses: actions/checkout@v4
2033

2134
- name: Run tests git-native
2235
run: |
2336
git config --global user.email "[email protected]"
2437
git config --global user.name "Git Artifact"
2538
git --version
26-
verbose=true bash _tests.sh || {
27-
exit_code=$?
28-
find . -name run.log
29-
find . -name run.log | xargs -I % cat %
30-
exit $exit_code
31-
}
39+
verbose=true bash _tests.sh
40+
3241
test-git-alpine-latest:
3342
runs-on: ubuntu-latest
3443
steps:
3544
- name: Checkout code
36-
uses: actions/checkout@v2
45+
uses: actions/checkout@v4
3746
- name: Run tests
3847
run: |
3948
set -eux
4049
git_version=latest
41-
docker build --build-arg ALPINE_GIT_DOCKER_VERSION=${git_version} -t git-artifact:latest .
42-
docker run --rm -e debug=${debug:-false} -e verbose=true -v $(pwd):/git -v $HOME/.ssh:/root/.ssh git-artifact:latest --version
43-
docker run --rm -e debug=${debug:-false} -e verbose=true -v $(pwd):/git -v $HOME/.ssh:/root/.ssh git-artifact:latest artifact-tests || {
44-
exit_code=$?
45-
find . -name run.log
46-
find . -name run.log | xargs -I % cat %
47-
exit $exit_code
48-
}
49-
50-
test-git-alpine-v2-36-2:
50+
docker build --build-arg ALPINE_GIT_DOCKER_VERSION="${git_version}" --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" -t "git-artifact:${git_version}" .
51+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:latest" --version
52+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:latest" artifact-tests
53+
54+
test-git-alpine-v2-49-0:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
- name: Run tests
60+
run: |
61+
set -eux
62+
git_version=v2.49.0
63+
docker build --build-arg ALPINE_GIT_DOCKER_VERSION="${git_version}" --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" -t "git-artifact:${git_version}" .
64+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:${git_version}" --version
65+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:${git_version}" artifact-tests
66+
67+
68+
test-git-alpine-v2-47-2:
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@v4
73+
- name: Run tests
74+
run: |
75+
set -eux
76+
git_version=v2.47.2
77+
docker build --build-arg ALPINE_GIT_DOCKER_VERSION="${git_version}" --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" -t "git-artifact:${git_version}" .
78+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:${git_version}" --version
79+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:${git_version}" artifact-tests
80+
81+
test-git-alpine-v2-36-2:
5182
runs-on: ubuntu-latest
5283
steps:
5384
- name: Checkout code
54-
uses: actions/checkout@v2
85+
uses: actions/checkout@v4
5586
- name: Run tests
5687
run: |
5788
set -eux
5889
git_version=v2.36.2
59-
docker build --build-arg ALPINE_GIT_DOCKER_VERSION=${git_version} -t git-artifact:${git_version} .
60-
docker run --rm -e debug=${debug:-false} -e verbose=true -v $(pwd):/git -v $HOME/.ssh:/root/.ssh git-artifact:${git_version} --version
61-
docker run --rm -e debug=${debug:-false} -e verbose=true -v $(pwd):/git -v $HOME/.ssh:/root/.ssh git-artifact:${git_version} artifact-tests || {
62-
exit_code=$?
63-
find . -name run.log
64-
find . -name run.log | xargs -I % cat %
65-
exit $exit_code
66-
}
90+
docker build --build-arg ALPINE_GIT_DOCKER_VERSION="${git_version}" --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" -t "git-artifact:${git_version}" .
91+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:${git_version}" --version
92+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:${git_version}" artifact-tests
6793
6894
test-git-alpine-v2-26-2:
6995
runs-on: ubuntu-latest
7096
steps:
7197
- name: Checkout code
72-
uses: actions/checkout@v2
98+
uses: actions/checkout@v4
7399
- name: Run tests
74100
run: |
75101
set -eux
76102
git_version=v2.26.2
77-
docker build --build-arg ALPINE_GIT_DOCKER_VERSION=${git_version} -t git-artifact:${git_version} .
78-
docker run --rm -e debug=${debug:-false} -e verbose=true -v $(pwd):/git -v $HOME/.ssh:/root/.ssh git-artifact:${git_version} --version
79-
docker run --rm -e debug=${debug:-false} -e verbose=true -v $(pwd):/git -v $HOME/.ssh:/root/.ssh git-artifact:${git_version} artifact-tests || {
80-
exit_code=$?
81-
find . -name run.log
82-
find . -name run.log | xargs -I % cat %
83-
exit $exit_code
84-
}
103+
docker build --build-arg ALPINE_GIT_DOCKER_VERSION="${git_version}" --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" -t "git-artifact:${git_version}" .
104+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:${git_version}" --version
105+
docker run --rm -u "$(id -u):$(id -g)" -e debug="${{ github.event.inputs.debug}}" -e verbose="${{ github.event.inputs.verbose}}" -v "$(pwd):/git" -v "$HOME/.ssh:/root/.ssh" "git-artifact:${git_version}" artifact-tests

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
**/.clone
44
**/git-test.log
55
**/run.log
6+
**/nok.log
7+
**/ok.log

.test/2/git-reference.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
* (HEAD, tag: v2.0) v2.0
22
| * (tag: v1.0) v1.0
33
|/
4-
* (origin/main, origin/HEAD, main) First commit of git artifact
4+
* (origin/main, main) First commit of git artifact

.test/3/git-reference.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* (HEAD -> main, origin/main, origin/HEAD) First commit of git artifact
1+
* (HEAD -> main, origin/main) First commit of git artifact

.test/4/git-reference.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
* (tag: v4.1, origin/latest) v4.1
22
| * (tag: v4.0) v4.0
33
|/
4-
* (HEAD -> latest, origin/main, origin/HEAD, main) First commit of git artifact
4+
* (HEAD -> latest, origin/main, main) First commit of git artifact

.test/5/git-reference.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
|/
44
| * (tag: v2.0) v2.0
55
|/
6-
* (origin/main, origin/HEAD, main) First commit of git artifact
6+
* (origin/main, main) First commit of git artifact

.test/6/git-reference.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
* (HEAD, tag: v1.0) v1.0
2-
* (origin/main, origin/HEAD, main, latest) First commit of git artifact
2+
* (origin/main, main, latest) First commit of git artifact

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ FROM alpine/git:${ALPINE_GIT_DOCKER_VERSION}
55
RUN apk fix && \
66
apk --no-cache --update add bash
77

8+
ARG USER_ID
9+
ARG GROUP_ID
10+
11+
RUN addgroup -g ${GROUP_ID} gituser && \
12+
adduser -D -u ${USER_ID} -G gituser gituser
13+
14+
USER gituser
15+
816
RUN git config --global user.email "[email protected]"
917
RUN git config --global user.name "Git Artifacts"
1018

_tests.sh

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
clear
44

55
set -euo pipefail
6-
[[ ${debug:-} == true ]] && set -x
6+
[[ ${debug:-} == true ]] && {
7+
echo "debug: ${debug}"
8+
set -x
9+
}
710
PATH=$(pwd):$PATH
811

912
which git
@@ -17,7 +20,7 @@ git clean -xffdq .
1720
local_tester_repo=.local
1821
remote_tester_repo=.remote
1922
clone_tester_repo=.clone
20-
23+
global_exit_code=0
2124

2225

2326
function testcase_header() {
@@ -30,25 +33,34 @@ function testcase_header() {
3033

3134
function eval_testcase() {
3235
# expect to be in repo to test against
36+
37+
# In git 2.48 changes the way HEAD is handled and for some reason it is not set
38+
# in order to be backward compatible we remove the HEAD reference
39+
rm -rf .git/refs/remotes/origin/HEAD
40+
3341
if ! [[ -s "${root_folder}/${test}/git-test.log" ]]; then
34-
git log --graph --all --oneline --decorate --format="%d %s" > "${root_folder}/${test}/git-test.log"
42+
git log --graph --all --oneline --format="%d %s" > "${root_folder}/${test}/git-test.log"
3543
else
3644
[[ ${debug:-} == true ]] && echo "Test $test : INFO: ${root_folder}/${test}/git-test.log is already available - use it"
3745
fi
3846
cd "${root_folder}/${test}"
39-
if diff -w git-test.log git-reference.log ; then
47+
if diff -w git-reference.log git-test.log ; then
4048
if [[ ${verbose:-} == true ]] ; then
4149
cat git-test.log
4250
echo "Test $test : OK"
4351
echo
4452
else
4553
echo "Test $test : OK : ${testcase_synopsis}"
4654
fi
55+
mv run.log ok.log
4756
else
48-
echo "ERROR: Test $test failed: ${testcase_synopsis}"
49-
exit 1
57+
echo "Test $test : NOK : ${testcase_synopsis}"
58+
mv run.log nok.log
59+
[[ ${verbose:-} == true ]] && cat git-test.log
60+
global_exit_code=2
5061
fi
5162
cd "${root_folder}"
63+
echo
5264
}
5365

5466
function generate_base_repo() {
@@ -70,7 +82,10 @@ function generate_base_repo() {
7082
cd ..
7183
}
7284

73-
echo "Running testcases; You can find run details for each test in <test>/run.log"
85+
echo "Running testcases; You can find run details for each test in:"
86+
echo " - <test>/run.log(unknown)"
87+
echo " - <test>/ok.log(all good)"
88+
echo " - <test>/nok.log(failed tests)"
7489
echo
7590

7691
export test="1"
@@ -197,3 +212,30 @@ testcase_header
197212
git artifact fetch-tags --sha1 "$sha1"
198213
} > ${test}/run.log 2>&1 || cat ../${test}/run.log
199214
eval_testcase
215+
216+
echo
217+
echo "########################################"
218+
echo "All tests completed. Checking results..."
219+
echo "########################################"
220+
echo
221+
222+
if [[ ${global_exit_code:-0} -eq 0 ]]; then
223+
echo "All tests passed successfully."
224+
else
225+
echo
226+
echo "Contents of failed test logs:"
227+
echo "-----------------------------"
228+
for log in $( find . -name run.log -o -name nok.log | sort ); do
229+
echo
230+
echo "--- $log start ------------------------"
231+
cat $log
232+
echo "--- $log end ------------------------"
233+
echo
234+
done
235+
echo
236+
echo "Some tests failed. - List of logs:"
237+
find . -name run.log -o -name nok.log | sort
238+
echo
239+
fi
240+
# Exit with the global exit code
241+
exit $global_exit_code

git-artifact

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,10 @@ cmd_fetch-tags() {
334334
}
335335

336336
main () {
337-
[[ ${debug:-} == true ]] && set -x
337+
[[ ${debug:-} == true ]] && {
338+
echo "debug: ${debug}"
339+
set -x
340+
}
338341
if [[ $# -eq 0 ]] ; then
339342
set -- -h
340343
fi

0 commit comments

Comments
 (0)