From 0a725422871c6ae5b3d2d0849ae0d42d24066958 Mon Sep 17 00:00:00 2001 From: Rodrigo Villar Date: Fri, 27 Sep 2024 10:48:18 -0400 Subject: [PATCH 1/2] add no internal linter --- .github/workflows/hypersdk-ci.yml | 3 +++ scripts/lint.no_internal.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 scripts/lint.no_internal.sh diff --git a/.github/workflows/hypersdk-ci.yml b/.github/workflows/hypersdk-ci.yml index 9005f47243..e603d8acb1 100644 --- a/.github/workflows/hypersdk-ci.yml +++ b/.github/workflows/hypersdk-ci.yml @@ -53,6 +53,9 @@ jobs: - name: Run actionlint shell: bash run: scripts/tests.actionlint.sh + - name: Run noInternalLint + shell: bash + run: scripts/lint.no_internal.sh hypersdk-unit-tests: runs-on: ubuntu-20.04-32 diff --git a/scripts/lint.no_internal.sh b/scripts/lint.no_internal.sh new file mode 100755 index 0000000000..4790a72e62 --- /dev/null +++ b/scripts/lint.no_internal.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Find all Go files in the /examples directory +violations=0 + +if ! [[ "$0" =~ scripts/lint.no_internal.sh ]]; then + echo "must be run from repository root" + exit 255 +fi + +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +EXAMPLES_DIR="${SCRIPT_DIR}/../examples" + +for file in $(find "$EXAMPLES_DIR" -type f -name "*.go"); do + if grep -q '"github.com/ava-labs/hypersdk/internal' "$file"; then + abs_file=$(realpath "$file") + clean_file=${abs_file/"$SCRIPT_DIR\/.."/"$SCRIPT_DIR"} + + echo "Violation: $clean_file imports from /internal" + violations=$((violations+1)) + fi +done + +if [ $violations -gt 0 ]; then + exit 1 +else + echo "Ok." +fi From 2887abffaef8477e8169ca32951c4b2e9d397332 Mon Sep 17 00:00:00 2001 From: Rodrigo Villar Date: Fri, 27 Sep 2024 10:50:10 -0400 Subject: [PATCH 2/2] add license --- scripts/lint.no_internal.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/lint.no_internal.sh b/scripts/lint.no_internal.sh index 4790a72e62..8b40e43167 100755 --- a/scripts/lint.no_internal.sh +++ b/scripts/lint.no_internal.sh @@ -1,6 +1,7 @@ #!/bin/bash +# Copyright (C) 2024, Ava Labs, Inc. All rights reserved. +# See the file LICENSE for licensing terms. -# Find all Go files in the /examples directory violations=0 if ! [[ "$0" =~ scripts/lint.no_internal.sh ]]; then