-
-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[internal] go: rewrite third party package analysis to not use `go li…
…st` (#14157) ## Problem The existing Go backend uses `go list` to analyze third party modules. Several users encountered a problem where the call to `go list` was demanding changes to `go.mod` with this error message: ``` go: updates to go.mod needed; to update it: go mod tidy ``` Running `go mod tidy`, however, made no changes to the `go.mod`, so there was no way to ever satisfy `go list`. ## Solution Solve the issue by rewriting the Go backend to use the same custom package analyzer used for first-party package analysis. This removes the reliance on `go list` for package analysis which was the `go` invocation that was generating the error message. (`go list` is still used to compute what modules are dependencies.) `ThirdPartyPkgInfo` is renamed to `ThirdPartyPkgAnalysis` to better align with `FirstPartyPkgAnalysis`. [ci skip-rust]
- Loading branch information
Tom Dyas
authored
Jan 14, 2022
1 parent
cbbd230
commit d28b781
Showing
8 changed files
with
480 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from dataclasses import dataclass | ||
|
||
from pants.backend.go.go_sources import load_go_binary | ||
from pants.backend.go.go_sources.load_go_binary import LoadedGoBinary, LoadedGoBinaryRequest | ||
from pants.engine.fs import Digest | ||
from pants.engine.internals.selectors import Get | ||
from pants.engine.rules import collect_rules, rule | ||
|
||
|
||
@dataclass(frozen=True) | ||
class PackageAnalyzerSetup: | ||
digest: Digest | ||
path: str | ||
|
||
|
||
@rule | ||
async def setup_go_package_analyzer() -> PackageAnalyzerSetup: | ||
binary_path = "./package_analyzer" | ||
binary = await Get( | ||
LoadedGoBinary, | ||
LoadedGoBinaryRequest("analyze_package", ("main.go", "read.go"), binary_path), | ||
) | ||
return PackageAnalyzerSetup( | ||
digest=binary.digest, | ||
path=binary_path, | ||
) | ||
|
||
|
||
def rules(): | ||
return ( | ||
*collect_rules(), | ||
*load_go_binary.rules(), | ||
) |
Oops, something went wrong.