-
Notifications
You must be signed in to change notification settings - Fork 42
add license checker #997
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
add license checker #997
Changes from 4 commits
d90e3d4
d8ba0f4
3622820
c6a9fa0
e83ee34
718c61d
78d2798
c7fdc11
70c5906
cf98482
5844c5a
71055de
58ba8e9
91f14d7
9dd2283
30fada6
e82e88f
86933e6
90ec139
937359a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| # Check code with compilers' sanitizers | ||
| name: Sanitizers | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. heh, this file shouldn't be here |
||
|
|
||
| on: workflow_call | ||
|
|
||
| env: | ||
| BUILD_DIR : "${{github.workspace}}/build" | ||
| INSTL_DIR : "${{github.workspace}}/../install-dir" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| ubuntu-build: | ||
| name: Ubuntu | ||
| strategy: | ||
| matrix: | ||
| compiler: [{c: gcc, cxx: g++}, {c: clang, cxx: clang++}, {c: icx, cxx: icpx}] | ||
| # TSAN is mutually exclusive with other sanitizers | ||
| sanitizers: [{asan: ON, ubsan: ON, tsan: OFF}, {asan: OFF, ubsan: OFF, tsan: ON}] | ||
| runs-on: ubuntu-22.04 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Install apt packages | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y clang cmake libhwloc-dev libnuma-dev libjemalloc-dev libtbb-dev | ||
| - name: Install oneAPI basekit | ||
| if: matrix.compiler.cxx == 'icpx' | ||
| run: | | ||
| sudo apt-get install -y gpg-agent wget | ||
| wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null | ||
| echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list | ||
| sudo apt-get update | ||
| sudo apt-get install -y intel-oneapi-ippcp-devel intel-oneapi-ipp-devel intel-oneapi-common-oneapi-vars intel-oneapi-compiler-dpcpp-cpp | ||
| - name: Set ptrace value for IPC test | ||
| run: sudo bash -c "echo 0 > /proc/sys/kernel/yama/ptrace_scope" | ||
|
|
||
| - name: Configure build | ||
| run: > | ||
| ${{ matrix.compiler.cxx == 'icpx' && '. /opt/intel/oneapi/setvars.sh &&' || ''}} | ||
| cmake | ||
| -B ${{env.BUILD_DIR}} | ||
| -DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}" | ||
| -DCMAKE_BUILD_TYPE=Debug | ||
| -DUMF_BUILD_SHARED_LIBRARY=OFF | ||
| -DCMAKE_C_COMPILER=${{matrix.compiler.c}} | ||
| -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} | ||
| -DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON | ||
| -DUMF_FORMAT_CODE_STYLE=OFF | ||
| -DUMF_DEVELOPER_MODE=ON | ||
| -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON | ||
| -DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON | ||
| -DUMF_USE_ASAN=${{matrix.sanitizers.asan}} | ||
| -DUMF_USE_UBSAN=${{matrix.sanitizers.ubsan}} | ||
| -DUMF_USE_TSAN=${{matrix.sanitizers.tsan}} | ||
| -DUMF_BUILD_EXAMPLES=ON | ||
| -DUMF_TESTS_FAIL_ON_SKIP=ON | ||
| - name: Build UMF | ||
| run: | | ||
| ${{ matrix.compiler.cxx == 'icpx' && '. /opt/intel/oneapi/setvars.sh' || true }} | ||
| cmake --build ${{env.BUILD_DIR}} -j $(nproc) | ||
| - name: Run tests | ||
| working-directory: ${{env.BUILD_DIR}} | ||
| run: > | ||
| ${{ matrix.compiler.cxx == 'icpx' && '. /opt/intel/oneapi/setvars.sh &&' || ''}} | ||
| ctest --output-on-failure | ||
| windows-build: | ||
| name: cl and clang-cl on Windows | ||
| env: | ||
| VCPKG_PATH: "${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows" | ||
| strategy: | ||
| matrix: | ||
| compiler: [{c: cl, cxx: cl}, {c: clang-cl, cxx: clang-cl}] | ||
| # Only ASAN is supported | ||
| sanitizers: [{asan: ON}] | ||
| runs-on: windows-2022 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| # Use the latest MSVC toolset available, when compiling UMF with ASan. | ||
| # Running binaries compiled with older toolsets results in a | ||
| # 'STATUS_DLL_INIT_FAILED' error despite being linked with ASan from | ||
| # the same toolset as the compiler being used. | ||
| # https://github.com/actions/runner-images/issues/8891 | ||
| - name: Setup MSVC dev command prompt | ||
| if: matrix.sanitizers.asan == 'ON' | ||
| uses: TheMrMilchmann/setup-msvc-dev@48edcef51a12c80d7e62ace57aae1417795e511c # v3.0.0 | ||
| with: | ||
| arch: x64 | ||
| toolset: '14' | ||
|
|
||
| - name: Initialize vcpkg | ||
| uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5 | ||
| with: | ||
| vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289 | ||
| vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg | ||
| vcpkgJsonGlob: '**/vcpkg.json' | ||
|
|
||
| - name: Install dependencies | ||
| run: vcpkg install | ||
| shell: pwsh # Specifies PowerShell as the shell for running the script. | ||
|
|
||
| # TODO enable level zero provider | ||
| - name: Configure build | ||
| run: > | ||
| cmake | ||
| -B ${{env.BUILD_DIR}} | ||
| -DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}" | ||
| -DCMAKE_C_COMPILER=${{matrix.compiler.c}} | ||
| -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} | ||
| -DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}" | ||
| -DUMF_BUILD_SHARED_LIBRARY=OFF | ||
| -DUMF_FORMAT_CODE_STYLE=OFF | ||
| -DUMF_DEVELOPER_MODE=ON | ||
| -DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON | ||
| -DUMF_USE_ASAN=${{matrix.sanitizers.asan}} | ||
| -DUMF_BUILD_EXAMPLES=ON | ||
| -DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF | ||
| -DUMF_TESTS_FAIL_ON_SKIP=ON | ||
| - name: Build UMF | ||
| run: cmake --build ${{env.BUILD_DIR}} --config Debug -j $Env:NUMBER_OF_PROCESSORS | ||
|
|
||
| - name: Run tests | ||
| working-directory: ${{env.BUILD_DIR}} | ||
| run: ctest -C Debug --output-on-failure | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| #!/usr/bin/env bash | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when all done, the last thing to do would be to make order in your commits. In this PR it would be at best to have 3 commits:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, so this is not done ideally - a few notes on commits:
in case you need any hint on this matter, please let me, or anyone else from the team know and we'll gladly help |
||
| # Copyright (C) 2024 Intel Corporation | ||
| # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| # check-headers.sh - check copyright and license in source files | ||
|
|
||
| SELF=$0 | ||
|
|
||
| function usage() { | ||
| echo "Usage: $SELF <source_root_path> <license_tag> [-h|-v|-a|-d]" | ||
| echo " -h, --help this help message" | ||
| echo " -v, --verbose verbose mode" | ||
| echo " -a, --all check all files (only modified files are checked by default)" | ||
| echo " -d, --update_dates change Copyright dates in all analyzed files (rather not use with -a)" | ||
| } | ||
|
|
||
| if [ "$#" -lt 2 ]; then | ||
| usage >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| SOURCE_ROOT=$1 | ||
| shift | ||
| LICENSE=$1 | ||
| shift | ||
|
|
||
| PATTERN=`mktemp` | ||
| TMP=`mktemp` | ||
| TMP2=`mktemp` | ||
| TEMPFILE=`mktemp` | ||
| rm -f $PATTERN $TMP $TMP2 | ||
|
|
||
| if [ "$1" == "-h" -o "$1" == "--help" ]; then | ||
| usage | ||
| exit 0 | ||
| fi | ||
|
|
||
| export GIT="git -C ${SOURCE_ROOT}" | ||
| $GIT rev-parse || exit 1 | ||
|
|
||
| if [ -f $SOURCE_ROOT/.git/shallow ]; then | ||
| SHALLOW_CLONE=1 | ||
| echo | ||
| echo "Warning: This is a shallow clone. Checking dates in copyright headers" | ||
| echo " will be skipped in case of files that have no history." | ||
| echo | ||
| else | ||
| SHALLOW_CLONE=0 | ||
| fi | ||
|
|
||
| VERBOSE=0 | ||
| CHECK_ALL=0 | ||
| UPDATE_DATES=0 | ||
| while [ "$1" != "" ]; do | ||
| case $1 in | ||
| -v|--verbose) | ||
| VERBOSE=1 | ||
| ;; | ||
| -a|--all) | ||
| CHECK_ALL=1 | ||
| ;; | ||
| -d|--update_dates) | ||
| UPDATE_DATES=1 | ||
| ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| if [ $CHECK_ALL -eq 0 ]; then | ||
| CURRENT_COMMIT=$($GIT log --pretty=%H -1) | ||
| MERGE_BASE=$($GIT merge-base HEAD origin/master 2>/dev/null) | ||
| [ -z $MERGE_BASE ] && \ | ||
| MERGE_BASE=$($GIT log --pretty="%cN:%H" | grep GitHub | head -n1 | cut -d: -f2) | ||
| [ -z $MERGE_BASE -o "$CURRENT_COMMIT" = "$MERGE_BASE" ] && \ | ||
| CHECK_ALL=1 | ||
| fi | ||
|
|
||
| if [ $CHECK_ALL -eq 1 ]; then | ||
| echo "INFO: Checking copyright headers of all files..." | ||
| GIT_COMMAND="ls-tree -r --name-only HEAD" | ||
| else | ||
| echo "INFO: Checking copyright headers of modified files only..." | ||
| GIT_COMMAND="diff --name-only $MERGE_BASE $CURRENT_COMMIT" | ||
| fi | ||
|
|
||
| FILES=$($GIT $GIT_COMMAND | ${SOURCE_ROOT}/check_license/file-exceptions.sh) | ||
|
|
||
| RV=0 | ||
|
|
||
| for file in $FILES ; do | ||
| if [ $VERBOSE -eq 1 ]; then | ||
| echo "Checking file: $file" | ||
| fi | ||
|
|
||
| # The src_path is a path which should be used in every command except git. | ||
| # git is called with -C flag so filepaths should be relative to SOURCE_ROOT | ||
| src_path="${SOURCE_ROOT}/$file" | ||
| [ ! -f $src_path ] && continue | ||
| # ensure that file is UTF-8 encoded | ||
| ENCODING=`file -b --mime-encoding $src_path` | ||
| iconv -f $ENCODING -t "UTF-8" $src_path > $TEMPFILE | ||
|
|
||
| if ! grep -q "SPDX-License-Identifier: $LICENSE" $src_path; then | ||
| echo >&2 "error: no $LICENSE SPDX tag in file: $src_path" | ||
| RV=1 | ||
| fi | ||
|
|
||
| if [ $SHALLOW_CLONE -eq 0 ]; then | ||
| $GIT log --no-merges --format="%ai %aE" -- $file | sort > $TMP | ||
| else | ||
| # mark the grafted commits (commits with no parents) | ||
| $GIT log --no-merges --format="%ai %aE grafted-%p-commit" -- $file | sort > $TMP | ||
| fi | ||
|
|
||
| # skip checking dates for non-Intel commits | ||
| [[ ! $(tail -n1 $TMP) =~ "@intel.com" ]] && continue | ||
|
|
||
| # skip checking dates for new files | ||
| [ $(cat $TMP | wc -l) -le 1 ] && continue | ||
|
|
||
| # grep out the grafted commits (commits with no parents) | ||
| # and skip checking dates for non-Intel commits | ||
| grep -v -e "grafted--commit" $TMP | grep -e "@intel.com" > $TMP2 | ||
|
|
||
| [ $(cat $TMP2 | wc -l) -eq 0 ] && continue | ||
|
|
||
| FIRST=`head -n1 $TMP2` | ||
| LAST=` tail -n1 $TMP2` | ||
|
|
||
| YEARS=$(sed ' | ||
| /.*Copyright (C) \+.*[0-9-]\+ Intel Corporation/!d | ||
| s/.*Copyright (C) \([0-9]\+\)-\([0-9]\+\).*/\1-\2/ | ||
| s/.*Copyright (C) \([0-9]\+\).*/\1/' "$src_path") | ||
| if [ -z "$YEARS" ]; then | ||
| echo >&2 "No copyright years in $src_path" | ||
| RV=1 | ||
| continue | ||
| fi | ||
|
|
||
| HEADER_FIRST=`echo $YEARS | cut -d"-" -f1` | ||
| HEADER_LAST=` echo $YEARS | cut -d"-" -f2` | ||
|
|
||
| COMMIT_FIRST=`echo $FIRST | cut -d"-" -f1` | ||
| COMMIT_LAST=` echo $LAST | cut -d"-" -f1` | ||
|
|
||
| if [ "$COMMIT_FIRST" != "" -a "$COMMIT_LAST" != "" ]; then | ||
| if [[ -n "$COMMIT_FIRST" && -n "$COMMIT_LAST" ]]; then | ||
| FL=0 | ||
| if [[ $HEADER_FIRST -lt $COMMIT_FIRST ]]; then | ||
| FL=1 | ||
| fi | ||
|
|
||
| COMMIT_LAST=`date +%G` | ||
|
|
||
| if [[ $FL -eq 1 ]]; then | ||
| NEW=$HEADER_FIRST-$COMMIT_LAST | ||
| else | ||
|
|
||
| if [[ $COMMIT_FIRST -eq $COMMIT_LAST ]]; then | ||
| NEW=$COMMIT_LAST | ||
| else | ||
| NEW=$COMMIT_FIRST-$COMMIT_LAST | ||
| fi | ||
| fi | ||
|
|
||
| if [[ "$YEARS" == "$NEW" ]]; then | ||
| echo "No change needed: $YEARS" | ||
| else | ||
| if [[ ${UPDATE_DATES} -eq 1 ]]; then | ||
| sed -i "s/Copyright ${YEARS}/Copyright ${NEW}/g" "${src_path}" | ||
| else | ||
| echo "$file:1: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2 | ||
| RV=1 | ||
| fi | ||
| fi | ||
| fi | ||
| else | ||
| echo "error: unknown commit dates in file: $file" >&2 | ||
| RV=1 | ||
| fi | ||
| done | ||
| rm -f $TMP $TMP2 $TEMPFILE | ||
|
|
||
| # check if error found | ||
| if [ $RV -eq 0 ]; then | ||
| echo "Copyright headers are OK." | ||
| else | ||
| echo "Error(s) in copyright headers found!" >&2 | ||
| fi | ||
| exit $RV | ||
lukaszstolarczuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/bin/sh -e | ||
| # Copyright (C) 2024 Intel Corporation | ||
| # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| # You can add an exception file | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this exception list for license check or for copyright check? or both? please mention it in the comment here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is for both
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as I stated above - please mention it in the comment here |
||
| grep -v -E -e 'src/uthash/.*' \ | ||
| -e 'benchmark/ubench.h' \ | ||
| -e 'include/umf/proxy_lib_new_delete.h' \ | ||
| -e 'scripts/docs_config/conf.py' \ | ||
|
||
| -e 'src/uthash/utlist.h' \ | ||
| -e 'src/uthash/uthash.h' \ | ||
| -e '\.yml$'\ | ||
| -e '\.clang-format$' \ | ||
| -e '\.md$' \ | ||
| -e '\.cmake-format$' \ | ||
| -e 'CODEOWNERS$' \ | ||
| -e 'scripts/assets/images/.*' \ | ||
| -e 'scripts/docs_config/.*' \ | ||
|
||
| -e '\.xml$' \ | ||
| -e '\.txt$' \ | ||
| -e 'test/supp/.*' \ | ||
| -e '\.json$' \ | ||
| -e 'LICENSE.TXT' \ | ||
| -e '.github/workflows/.spellcheck-conf.toml' \ | ||
| -e '.gitignore' \ | ||
| -e '.mailmap' \ | ||
| -e '.trivyignore' \ | ||
| -e 'ChangeLog' \ | ||
| -e '\.cmake.in$' \ | ||
| -e '\.patch$' | ||
Uh oh!
There was an error while loading. Please reload this page.