Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: add lint for codersdk dependencies#14638

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -451,6 +451,7 @@ lint/ts:

lint/go:
./scripts/check_enterprise_imports.sh
./scripts/check_codersdk_imports.sh
linter_ver=$(shell egrep -o 'GOLANGCI_LINT_VERSION=\S+' dogfood/contents/Dockerfile | cut -d '=' -f 2)
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v$$linter_ver run
.PHONY: lint/go
Expand Down
20 changes: 20 additions & 0 deletionsscripts/check_codersdk_imports.sh
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# This file checks all codersdk imports to be sure it doesn't import any packages
# that are being replaced in go.mod.

set -euo pipefail
# shellcheck source=scripts/lib.sh
source"$(dirname"${BASH_SOURCE[0]}")/lib.sh"
cdroot

deps=$(./scripts/list_dependencies.sh github.com/coder/coder/v2/codersdk)

set +e
replaces=$(grep"^replace" go.mod| awk'{print $2}')
conflicts=$(echo"$deps"| grep -xF -f<(echo"$replaces"))

if [-n"${conflicts}" ];then
error"$(printf'codersdk cannot import the following packages being replaced in go.mod:\n%s'"${conflicts}")"
fi
log"codersdk imports OK"
25 changes: 25 additions & 0 deletionsscripts/list_dependencies.sh
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# This script lists all dependencies of a given package, including dependencies
# of test files.

# Usage: list_dependencies <package>

set -euo pipefail

if [["$#"-ne 1 ]];then
echo"Usage:$0 <package>"
exit 1
fi

package="$1"
all_deps=$(go list -f'{{join .Deps "\n"}}'"$package")
test_imports=$(go list -f'{{ join .TestImports " " }}'"$package")
xtest_imports=$(go list -f'{{ join .XTestImports " " }}'"$package")

forpkgin$test_imports$xtest_imports;do
deps=$(go list -f'{{join .Deps "\n"}}'"$pkg")
all_deps+=$'\n'"$deps"
done

echo"$all_deps"| sort| uniq
Loading

[8]ページ先頭

©2009-2025 Movatter.jp