Skip to content

Commit

Permalink
Add pipeline to test against git latest, 2.34.1, 2.25.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bicschneider committed Nov 23, 2023
1 parent 2f7a2c7 commit 0dc9438
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 3 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test-git-native:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Run tests git-native
run: |
git config --global user.email "[email protected]"
git config --global user.name "Git Artifact"
git --version
verbose=true bash _tests.sh || {
exit_code=$?
find . -name run.log
find . -name run.log | xargs -I % cat %
exit $exit_code
}
test-git-alpine-latest:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run tests
run: |
docker build --build-arg ALPINE_GIT_DOCKER_VERSION=latest -t git-artifact:latest .
docker run --rm -e debug=${debug:-false} -e verbose=true -v $(pwd):/git -v $HOME/.ssh:/root/.ssh git-artifact:latest --version
docker run --rm -e debug=${debug:-false} -e verbose=true -v $(pwd):/git -v $HOME/.ssh:/root/.ssh git-artifact:latest artifact-tests || {
exit_code=$?
find . -name run.log
find . -name run.log | xargs -I % cat %
exit $exit_code
}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG ALPINE_GIT_DOCKER_VERSION=dummy

FROM alpine/git:${ALPINE_GIT_DOCKER_VERSION}

RUN apk fix && \
apk --no-cache --update add bash

RUN git config --global user.email "[email protected]"
RUN git config --global user.name "Git Artifacts"

RUN git config --global --add safe.directory /git

ENV PATH="/git:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

18 changes: 16 additions & 2 deletions _tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@ set -euo pipefail
[[ ${debug:-} == true ]] && set -x
PATH=$(pwd):$PATH

#echo "${docker_git_version:-}"
#if [[ ${docker_git_version:-} != "" ]]; then
# echo "make function"
# docker build --build-arg ALPINE_GIT_DOCKER_VERSION=${docker_git_version} -t git-artifact:${docker_git_version} .
#function git () {
# (docker run -it --rm -v ${HOME}:/root -v $(pwd):/git git-artifact:${docker_git_version} "$@")
#}
#fi
git --version

cd .test
root_folder=$(pwd)
echo "Cleaning $(pwd)"
git clean -xffdq .

local_tester_repo=.local
remote_tester_repo=.remote
clone_tester_repo=.clone



function testcase_header() {
[[ ${verbose:-} == true ]] || return 0
echo
Expand All @@ -29,7 +43,7 @@ function eval_testcase() {
git log --graph --all --oneline --decorate --format="%d %s" > "${root_folder}/${test}/git-test.log"
fi
cd "${root_folder}/${test}"
if diff -Z git-test.log git-reference.log ; then
if diff -w git-test.log git-reference.log ; then
if [[ ${verbose:-} == true ]] ; then
cat git-test.log
echo "INFO: Test $test : OK"
Expand Down Expand Up @@ -157,7 +171,7 @@ testcase_header
cd ../$clone_tester_repo
git artifact fetch-co-latest --regex 'v*.*'

} > ${test}/run.log 2>&1 || { pwd && cat ../run.log; }
} > ${test}/run.log 2>&1 || { echo "ERROR_CODE: $?"; pwd && cat ../run.log; }
eval_testcase

test="5.1"
Expand Down
2 changes: 1 addition & 1 deletion git-artifact
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ cmd_fetch-co() {
find-latest() {
local -n _latest_tag=${1}
# https://stackoverflow.com/questions/10649814/get-last-git-tag-from-a-remote-repo-without-cloning
_latest_tag=$(git ls-remote --tags --refs --sort='-version:refname' origin ${arg_regex} | head --lines=1 | cut -f2 | cut -d / -f3-)
_latest_tag=$(git ls-remote --tags --refs --sort='-version:refname' origin ${arg_regex} | head -n 1 | cut -f2 | cut -d / -f3-)
if [ -z "${_latest_tag:-}" ]; then
echo "ERROR: No tag found using regex: ${arg_regex} "
exit 1
Expand Down
1 change: 1 addition & 0 deletions git-artifact-tests

0 comments on commit 0dc9438

Please sign in to comment.