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..8b40e43167 --- /dev/null +++ b/scripts/lint.no_internal.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Copyright (C) 2024, Ava Labs, Inc. All rights reserved. +# See the file LICENSE for licensing terms. + +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