Skip to content

Commit

Permalink
adding ci files
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Töpel committed Sep 15, 2023
1 parent 0bb80ec commit 90cc0d3
Show file tree
Hide file tree
Showing 19 changed files with 1,208 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/scripts/helpers.sh
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2023 Rivos Inc.
#
# SPDX-License-Identifier: Apache-2.0

# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

group_start() {
echo "::group::$1"
}

group_end() {
echo "::endgroup::"
}
31 changes: 31 additions & 0 deletions .github/scripts/patches.sh
@@ -0,0 +1,31 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2023 Rivos Inc.
#
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

d=$(dirname "${BASH_SOURCE[0]}")

. ${d}/helpers.sh

basesha=$(git log -1 --pretty=%H .github/scripts/helpers.sh)
patches=( $(git rev-list --reverse ${basesha}..HEAD) )

group_start "Per-patch"
cnt=1
for i in "${patches[@]}"; do
tests=( $(ls ${d}/patches/*.sh) )
tcnt=1
for j in "${tests[@]}"; do
git reset --hard $i
msg="Patch ${cnt}/${#patches[@]}: Test ${tcnt}/${#tests[@]}: ${j}"
echo "::group::${msg} @ $(date --utc +%Y-%m-%dT%H:%M:%S.%NZ)"
bash ${j} "${msg}" || true
echo "Completed $(date --utc +%Y-%m-%dT%H:%M:%S.%NZ)"
echo "::endgroup::"
tcnt=$(( tcnt + 1 ))
done
cnt=$(( cnt + 1 ))
done
group_end
26 changes: 26 additions & 0 deletions .github/scripts/patches/build_rv32_defconfig.sh
@@ -0,0 +1,26 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2022 by Rivos Inc.

tmpdir=build
tmpfile=$(mktemp)
rc=0

tuxmake --wrapper ccache --target-arch riscv --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir --toolchain llvm -z none -k rv32_defconfig \
CROSS_COMPILE=riscv64-linux-gnu- \
> $tmpfile || rc=1

if [ $rc -ne 0 ]; then
echo "::error::FAIL PATCH: $1"
grep "\(warning\|error\):" $tmpfile >&2
else
echo "::notice::OK PATCH: $1"
fi

rm -rf $tmpdir $tmpfile

exit $rc
116 changes: 116 additions & 0 deletions .github/scripts/patches/build_rv64_clang_allmodconfig.sh
@@ -0,0 +1,116 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2019 Netronome Systems, Inc.

# Modified tests/patch/build_defconfig_warn.sh for RISC-V builds

tmpfile_e=$(mktemp)
tmpfile_o=$(mktemp)
tmpfile_n=$(mktemp)

tmpdir_b=build_llvm
tmpdir_o=output

rc=0

echo "Redirect to $tmpfile_o and $tmpfile_n"

HEAD=$(git rev-parse HEAD)

echo "Tree base:"
git log -1 --pretty='%h ("%s")' HEAD~

echo "Building the whole tree with the patch"

tuxmake --wrapper ccache --target-arch riscv -e PATH=$PATH --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir_o -b $tmpdir_b --toolchain llvm -z none --kconfig allmodconfig \
-K CONFIG_WERROR=n -K CONFIG_RANDSTRUCT_NONE=y W=1 \
CROSS_COMPILE=riscv64-linux-gnu- \
config default \
> $tmpfile_e || rc=1

if [ $rc -eq 1 ]
then
echo "::error::FAIL PATCH: $1"
grep "\(error\):" $tmpfile_e >&2
rm -rf $tmpdir_o $tmpfile_o $tmpfile_n $tmpdir_b $tmpfile_e
exit $rc
fi

current=$(grep -c "\(warning\|error\):" $tmpfile_n)

git checkout -q HEAD~

echo "Building the tree before the patch"

tuxmake --wrapper ccache --target-arch riscv -e PATH=$PATH --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir_o -b $tmpdir_b --toolchain llvm -z none --kconfig allmodconfig \
-K CONFIG_WERROR=n -K CONFIG_RANDSTRUCT_NONE=y W=1 \
CROSS_COMPILE=riscv64-linux-gnu- \
config default \
> $tmpfile_o

incumbent=$(grep -c "\(warning\|error\):" $tmpfile_o)

git checkout -q $HEAD

echo "Building the tree with the patch"

tuxmake --wrapper ccache --target-arch riscv -e PATH=$PATH --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir_o -b $tmpdir_b --toolchain llvm -z none --kconfig allmodconfig \
-K CONFIG_WERROR=n -K CONFIG_RANDSTRUCT_NONE=y W=1 \
CROSS_COMPILE=riscv64-linux-gnu- \
config default \
> $tmpfile_n || rc=1

if [ $rc -eq 1 ]
then
echo "::error::FAIL PATCH: $1"
grep "\(warning\|error\):" $tmpfile_n >&2
rm -rf $tmpdir_o $tmpfile_o $tmpfile_n $tmpdir_b
exit $rc
fi

current=$(grep -c "\(warning\|error\):" $tmpfile_n)

if [ $current -gt $incumbent ]; then
echo "New errors added:" 1>&2

tmpfile_errors_before=$(mktemp)
tmpfile_errors_now=$(mktemp)
grep "\(warning\|error\):" $tmpfile_o | sort | uniq -c > $tmpfile_errors_before
grep "\(warning\|error\):" $tmpfile_n | sort | uniq -c > $tmpfile_errors_now

diff -U 0 $tmpfile_errors_before $tmpfile_errors_now 1>&2

rm $tmpfile_errors_before $tmpfile_errors_now

echo "Per-file breakdown" 1>&2
tmpfile_fo=$(mktemp)
tmpfile_fn=$(mktemp)

grep "\(warning\|error\):" $tmpfile_o | sed -n 's@\(^\.\./[/a-zA-Z0-9_.-]*.[ch]\):.*@\1@p' | sort | uniq -c \
> $tmpfile_fo
grep "\(warning\|error\):" $tmpfile_n | sed -n 's@\(^\.\./[/a-zA-Z0-9_.-]*.[ch]\):.*@\1@p' | sort | uniq -c \
> $tmpfile_fn

diff -U 0 $tmpfile_fo $tmpfile_fn 1>&2
rm $tmpfile_fo $tmpfile_fn
echo "::error::FAIL pre: $incumbent post: $current PATCH: $1"
rc=1
fi

rm -rf $tmpdir_o $tmpfile_o $tmpfile_n $tmpdir_b $tmpfile_e

if [ $rc -eq 0 ]; then
echo "::notice::OK PATCH: $1"
fi

exit $rc
115 changes: 115 additions & 0 deletions .github/scripts/patches/build_rv64_gcc_allmodconfig.sh
@@ -0,0 +1,115 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2019 Netronome Systems, Inc.

# Modified tests/patch/build_defconfig_warn.sh for RISC-V builds

tmpfile_e=$(mktemp)
tmpfile_o=$(mktemp)
tmpfile_n=$(mktemp)

tmpdir_b=build_gcc
tmpdir_o=output

rc=0

echo "Redirect to $tmpfile_o and $tmpfile_n"

HEAD=$(git rev-parse HEAD)

echo "Tree base:"
git log -1 --pretty='%h ("%s")' HEAD~

echo "Building the whole tree with the patch"

tuxmake --wrapper ccache --target-arch riscv -e PATH=$PATH --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir_o -b $tmpdir_b --toolchain gcc -z none --kconfig allmodconfig \
-K CONFIG_WERROR=n -K CONFIG_GCC_PLUGINS=n W=1 \
CROSS_COMPILE=riscv64-linux-gnu- \
config default \
> $tmpfile_e || rc=1

if [ $rc -eq 1 ]
then
echo "::error::FAIL PATCH: $1"
grep "\(error\):" $tmpfile_e >&2
rm -rf $tmpdir_o $tmpfile_o $tmpfile_n $tmpdir_b $tmpfile_e
exit $rc
fi

git checkout -q HEAD~

echo "Building the tree before the patch"

tuxmake --wrapper ccache --target-arch riscv -e PATH=$PATH --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir_o -b $tmpdir_b --toolchain gcc -z none --kconfig allmodconfig \
-K CONFIG_WERROR=n -K CONFIG_GCC_PLUGINS=n W=1 \
CROSS_COMPILE=riscv64-linux-gnu- \
config default \
> $tmpfile_o

incumbent=$(grep -c "\(warning\|error\):" $tmpfile_o)

git checkout -q $HEAD

echo "Building the tree with the patch"

tuxmake --wrapper ccache --target-arch riscv -e PATH=$PATH --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir_o -b $tmpdir_b --toolchain gcc -z none --kconfig allmodconfig \
-K CONFIG_WERROR=n -K CONFIG_GCC_PLUGINS=n W=1 \
CROSS_COMPILE=riscv64-linux-gnu- \
config default \
> $tmpfile_n || rc=1

if [ $rc -eq 1 ]
then
echo "::error::FAIL PATCH: $1"
grep "\(warning\|error\):" $tmpfile_n >&2
rm -rf $tmpdir_o $tmpfile_o $tmpfile_n $tmpdir_b
exit $rc
fi

current=$(grep -c "\(warning\|error\):" $tmpfile_n)

if [ $current -gt $incumbent ]; then
echo "New errors added:" 1>&2

tmpfile_errors_before=$(mktemp)
tmpfile_errors_now=$(mktemp)
grep "\(warning\|error\):" $tmpfile_o | sort | uniq -c > $tmpfile_errors_before
grep "\(warning\|error\):" $tmpfile_n | sort | uniq -c > $tmpfile_errors_now

diff -U 0 $tmpfile_errors_before $tmpfile_errors_now 1>&2

rm $tmpfile_errors_before $tmpfile_errors_now

echo "Per-file breakdown" 1>&2
tmpfile_fo=$(mktemp)
tmpfile_fn=$(mktemp)

grep "\(warning\|error\):" $tmpfile_o | sed -n 's@\(^\.\./[/a-zA-Z0-9_.-]*.[ch]\):.*@\1@p' | sort | uniq -c \
> $tmpfile_fo
grep "\(warning\|error\):" $tmpfile_n | sed -n 's@\(^\.\./[/a-zA-Z0-9_.-]*.[ch]\):.*@\1@p' | sort | uniq -c \
> $tmpfile_fn

diff -U 0 $tmpfile_fo $tmpfile_fn 1>&2
rm $tmpfile_fo $tmpfile_fn
echo "::error::FAIL pre: $incumbent post: $current PATCH: $1"

rc=1
fi

rm -rf $tmpdir_o $tmpfile_o $tmpfile_n $tmpdir_b $tmpfile_e

if [ $rc -eq 0 ]; then
echo "::notice::OK PATCH: $1"
fi

exit $rc
26 changes: 26 additions & 0 deletions .github/scripts/patches/build_rv64_nommu_k210_defconfig.sh
@@ -0,0 +1,26 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2022 by Rivos Inc.

tmpdir=$(mktemp -d)
tmpfile=$(mktemp)
rc=0

tuxmake --wrapper ccache --target-arch riscv --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir --toolchain gcc -z none -k nommu_k210_defconfig \
CROSS_COMPILE=riscv64-linux-gnu- \
> $tmpfile || rc=1

if [ $rc -ne 0 ]; then
echo "::error::FAIL PATCH: $1"
grep "\(warning\|error\):" $tmpfile >&2
else
echo "::notice::OK PATCH: $1"
fi

rm -rf $tmpdir $tmpfile

exit $rc
26 changes: 26 additions & 0 deletions .github/scripts/patches/build_rv64_nommu_virt_defconfig.sh
@@ -0,0 +1,26 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2022 by Rivos Inc.

tmpdir=$(mktemp -d)
tmpfile=$(mktemp)
rc=0

tuxmake --wrapper ccache --target-arch riscv --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir --toolchain gcc -z none -k nommu_virt_defconfig \
CROSS_COMPILE=riscv64-linux-gnu- \
> $tmpfile || rc=1

if [ $rc -ne 0 ]; then
echo "::error::FAIL PATCH: $1"
grep "\(warning\|error\):" $tmpfile >&2
else
echo "::notice::OK PATCH: $1"
fi

rm -rf $tmpdir $tmpfile

exit $rc
36 changes: 36 additions & 0 deletions .github/scripts/patches/checkpatch.sh
@@ -0,0 +1,36 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2019 Netronome Systems, Inc.

IGNORED=\
COMMIT_LOG_LONG_LINE,\
MACRO_ARG_REUSE,\
ALLOC_SIZEOF_STRUCT,\
NO_AUTHOR_SIGN_OFF,\
GIT_COMMIT_ID,\
CAMELCASE

tmpfile=$(mktemp)

./scripts/checkpatch.pl --strict --ignore=$IGNORED -g HEAD | tee $tmpfile

grep 'total: 0 errors, 0 warnings, 0 checks' $tmpfile
ret=$?

# return 250 (warning) if there are not errors
[ $ret -ne 0 ] && grep -P 'total: 0 errors, \d+ warnings, \d+ checks' $tmpfile && ret=250

if [ $ret -ne 0 ]; then
echo "::error::FAIL PATCH: $1"
grep '\(WARNING\|ERROR\|CHECK\): ' $tmpfile | LC_COLLATE=C sort -u
else
echo "::notice::OK PATCH: $1"
grep 'total: ' $tmpfile | LC_COLLATE=C sort -u
fi

rm $tmpfile

exit $ret

# ./scripts/checkpatch.pl --ignore=SPACING_CAST,LONG_LINE,LONG_LINE_COMMENT,LONG_LINE_STRING,LINE_SPACING_STRUCT,FILE_PATH_CHANGES,CAMELCASE,OPEN_ENDED_LINE,AVOID_EXTERNS_HEADER,UNCOMMENTED_DEFINITION

0 comments on commit 90cc0d3

Please sign in to comment.