Skip to content

Draft: testing CI [2] #1907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,20 @@ jobs:
- name: prepare libc6 for actions
if: matrix.vector.jobname == 'linux32'
run: apt -q update && apt -q -y install libc6-amd64 lib64stdc++6
- name: install git in container
run: |
if command -v git
then
: # nothing to do
elif command -v apk
then
apk add --update git
elif command -v dnf
then
dnf -yq update && dnf -yq install git
else
apt-get -q update && apt-get -q -y install git
fi
- uses: actions/checkout@v4
- run: ci/install-dependencies.sh
- run: useradd builder --create-home
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3330,8 +3330,10 @@ HCC = $(HCO:hco=hcc)
$(HCO): %.hco: %.hcc $(GENERATED_H) FORCE
$(QUIET_HDR)$(CC) $(ALL_CFLAGS) -o /dev/null -c -xc $<

.PHONY: hdr-check $(HCO)
# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+
.PHONY: hdr-check check-headers $(HCO)
hdr-check: $(HCO)
check-headers: hdr-check

.PHONY: style
style:
Expand Down
4 changes: 2 additions & 2 deletions ci/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ ubuntu-*|i386/ubuntu-*|debian-*)
-C "$CUSTOM_PATH" --strip-components=1 "git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs"
rm "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"

wget --quiet "$JGITWHENCE" --output-document="$CUSTOM_PATH/jgit"
chmod a+x "$CUSTOM_PATH/jgit"
: wget --quiet "$JGITWHENCE" --output-document="$CUSTOM_PATH/jgit"
: chmod a+x "$CUSTOM_PATH/jgit"
;;
esac
;;
Expand Down
2 changes: 1 addition & 1 deletion ci/run-static-analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ then
exit 1
fi

make hdr-check ||
make check-headers ||
exit 1

make check-pot
Expand Down
31 changes: 8 additions & 23 deletions contrib/coccinelle/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ if not spatch.found()
subdir_done()
endif

third_party_sources = [
':!contrib',
':!compat/inet_ntop.c',
':!compat/inet_pton.c',
':!compat/nedmalloc',
':!compat/obstack.*',
':!compat/poll',
':!compat/regex',
':!sha1collisiondetection',
':!sha1dc',
':!t/unit-tests/clar',
':!t/unit-tests/clar',
':!t/t[0-9][0-9][0-9][0-9]*',
]

rules = [
'array.cocci',
'commit.cocci',
Expand Down Expand Up @@ -55,18 +40,18 @@ concatenated_rules = custom_target(
capture: true,
)

sources = [ ]
foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_sources, check: true).stdout().split()
sources += source
coccinelle_sources = []
foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_excludes, check: true).stdout().split()
coccinelle_sources += source
endforeach

headers = [ ]
foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()
headers += meson.project_source_root() / header
coccinelle_headers = []
foreach header : headers_to_check
coccinelle_headers += meson.project_source_root() / header
endforeach

patches = [ ]
foreach source : sources
foreach source : coccinelle_sources
patches += custom_target(
command: [
spatch,
Expand All @@ -78,7 +63,7 @@ foreach source : sources
input: meson.project_source_root() / source,
output: source.underscorify() + '.patch',
capture: true,
depend_files: headers,
depend_files: coccinelle_headers,
)
endforeach

Expand Down
86 changes: 86 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,28 @@ builtin_sources = [
'builtin/write-tree.c',
]

third_party_excludes = [
':!contrib',
':!compat/inet_ntop.c',
':!compat/inet_pton.c',
':!compat/nedmalloc',
':!compat/obstack.*',
':!compat/poll',
':!compat/regex',
':!sha1collisiondetection',
':!sha1dc',
':!t/unit-tests/clar',
':!t/t[0-9][0-9][0-9][0-9]*',
':!xdiff',
]

headers_to_check = []
if git.found() and fs.exists(meson.project_source_root() / '.git')
foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_excludes, check: true).stdout().split()
headers_to_check += header
endforeach
endif

if not get_option('breaking_changes')
builtin_sources += 'builtin/pack-redundant.c'
endif
Expand Down Expand Up @@ -2012,6 +2034,70 @@ endif

subdir('contrib')

exclude_from_check_headers = [
'compat/',
'unicode-width.h',
]

if sha1_backend != 'openssl'
exclude_from_check_headers += 'sha1/openssl.h'
endif
if sha256_backend != 'openssl'
exclude_from_check_headers += 'sha256/openssl.h'
endif
if sha256_backend != 'nettle'
exclude_from_check_headers += 'sha256/nettle.h'
endif
if sha256_backend != 'gcrypt'
exclude_from_check_headers += 'sha256/gcrypt.h'
endif

if headers_to_check.length() != 0 and compiler.get_argument_syntax() == 'gcc'
hco_targets = []
foreach h : headers_to_check
skip_header = false
foreach exclude : exclude_from_check_headers
if h.startswith(exclude)
skip_header = true
break
endif
endforeach

if skip_header
continue
endif

hcc = custom_target(
input: h,
output: h.underscorify() + 'cc',
command: [
shell,
'-c',
'echo \'#include "git-compat-util.h"\' > @OUTPUT@ && echo \'#include "' + h + '"\' >> @OUTPUT@'
]
)

hco = custom_target(
input: hcc,
output: fs.replace_suffix(h.underscorify(), '.hco'),
command: [
compiler.cmd_array(),
libgit_c_args,
'-I', meson.project_source_root(),
'-I', meson.project_source_root() / 't/unit-tests',
'-o', '/dev/null',
'-c', '-xc',
'@INPUT@'
]
)
hco_targets += hco
endforeach

# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+
hdr_check = alias_target('hdr-check', hco_targets)
alias_target('check-headers', hdr_check)
endif

foreach key, value : {
'DIFF': diff.full_path(),
'GIT_SOURCE_DIR': meson.project_source_root(),
Expand Down
Loading