Chris Smowton
209f9ec93d
Amend comments per review
2024-09-23 15:20:18 +01:00
Chris Smowton
bb44a2fc8c
Populate pkgInfoMapping for test packages if relevant
2024-09-21 13:38:41 +01:00
Chris Smowton
bcb84a84e1
Only skip test packages at the file-extraction phase
2024-09-20 12:48:08 +01:00
Chris Smowton
f5ff822681
Convert extract-tests option to an official extractor option
2024-09-20 10:03:54 +01:00
Chris Smowton
c3dffc955b
Apply review comments
2024-09-20 09:56:29 +01:00
Chris Smowton
76e6942594
Go: support extracting test code
...
This implements support for test extraction by two mechanisms:
* In autobuild mode, setting `CODEQL_EXTRACTOR_GO_EXTRACT_TESTS` to `true`.
* In manual build mode, tracing a `go test` command (`go test -c` is to be recommended for efficiency).
Go deals with test compilation by creating several extra packages on top of those expected from inspection of the source code (see docs of `packages.Load` for more detail): packages whose IDs include a suffix like `mydomain.com/mypackage [mydomain.com/mypackage.test]`, and packages containing generated test driver code like `mydomain.com/mypackage.test`. There are also additional packages like `mydomain.com/mypackage_tests` which are explicitly present in source code, but not compiled by a normal `go build`.
So far as I can tell, the purpose of the two variants of the package is to resolve dependency cycles (because the tests variant of the package can have more dependencies than the non-tests variant, and non-test code can compile against non-test package variants). Since the test package variants seems to be a superset of the non-tests variant, I employ the simple heuristic of ignoring the variant of each package with the shortest ID. I haven't seen a case where there are three or more variants of a package, so I expect this to always identify the tests variant as the preferred one. If several variants were extracted, and we were to attempt to match Golang's linkage strategy among the different variants, we would need to extend trap-file name and most top-level symbol trap IDs with the package variant they come from; I hope this won't prove necessary.
"Real" `_tests` packages, and wholly synthetic driver code packages, are extracted just like normal.
2024-09-20 09:56:28 +01:00
dependabot[bot]
67fa9738e6
Bump golang.org/x/tools
...
Bumps the extractor-dependencies group in /go/extractor with 1 update: [golang.org/x/tools](https://github.com/golang/tools ).
Updates `golang.org/x/tools` from 0.24.0 to 0.25.0
- [Release notes](https://github.com/golang/tools/releases )
- [Commits](https://github.com/golang/tools/compare/v0.24.0...v0.25.0 )
---
updated-dependencies:
- dependency-name: golang.org/x/tools
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: extractor-dependencies
...
Signed-off-by: dependabot[bot] <support@github.com >
2024-09-19 03:46:50 +00:00
Dave Bartolomeo
485fc04029
Initial merge from main
2024-09-15 08:55:31 -04:00
Owen Mansel-Chan
84c41744c1
Include type parameter's index in its label
2024-09-10 16:52:44 +01:00
dependabot[bot]
3c1e3b66ec
Bump golang.org/x/mod
...
Bumps the extractor-dependencies group in /go/extractor with 1 update: [golang.org/x/mod](https://github.com/golang/mod ).
Updates `golang.org/x/mod` from 0.20.0 to 0.21.0
- [Commits](https://github.com/golang/mod/compare/v0.20.0...v0.21.0 )
---
updated-dependencies:
- dependency-name: golang.org/x/mod
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: extractor-dependencies
...
Signed-off-by: dependabot[bot] <support@github.com >
2024-09-06 03:21:50 +00:00
Michael B. Gale
772bc9b5c8
Go: Bump everything to 1.23.1
2024-09-05 21:12:46 +01:00
Michael B. Gale
9aeaae6068
Go: Bump maxGoVersion to 1.23
2024-09-05 21:12:45 +01:00
Michael B. Gale
1a9608a1f5
Go: Don't extract objects for type aliases
2024-09-05 21:12:42 +01:00
Michael B. Gale
97c3efccd1
Go: Factor out isAlias function
2024-09-05 21:12:42 +01:00
Michael B. Gale
c5b8163493
Go: Handle Alias types by extracting the underlying types
2024-09-05 21:12:41 +01:00
Michael B. Gale
4dead2bd8d
Go: Use 1.23 for extractor
2024-09-05 21:12:40 +01:00
Chris Smowton
2939cefc68
Use platform path separators for file testing, and forward-slashes for reporting to CodeQL
2024-08-21 10:15:44 +01:00
Chris Smowton
15b5bcc67c
Output to stdout, not stderr
2024-08-20 17:01:54 +01:00
Chris Smowton
8b9617cd38
Update bazel build files
2024-08-20 15:56:28 +01:00
Chris Smowton
ea3e5c8a99
Clarify comment
2024-08-20 15:56:27 +01:00
Chris Smowton
f1f6f9b580
Share vendor-dir extraction logic between extractor and configure-baseline script
2024-08-20 15:56:26 +01:00
Chris Smowton
22802fd41f
Improve struct naming
2024-08-20 15:56:25 +01:00
Chris Smowton
624d2b83c0
Tidy comments
2024-08-20 15:56:23 +01:00
Chris Smowton
21366dd502
Go / configure-baseline: account for multiple vendor directories and the CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS setting
...
Our existing configure-baseline scripts would give the wrong result if a `vendor` directory wasn't at the root of the repository, or if the `CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS` variable was set to `true` indicating the user wants their vendored code scanned.
Here I replace the shell scripts that implemented the very simplest behaviour with a small Go program.
2024-08-20 15:56:22 +01:00
dependabot[bot]
c1e242ecda
Bump golang.org/x/tools
...
Bumps the extractor-dependencies group in /go/extractor with 1 update: [golang.org/x/tools](https://github.com/golang/tools ).
Updates `golang.org/x/tools` from 0.23.0 to 0.24.0
- [Release notes](https://github.com/golang/tools/releases )
- [Commits](https://github.com/golang/tools/compare/v0.23.0...v0.24.0 )
---
updated-dependencies:
- dependency-name: golang.org/x/tools
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: extractor-dependencies
...
Signed-off-by: dependabot[bot] <support@github.com >
2024-08-08 03:50:32 +00:00
Paolo Tranquilli
841f317cbd
Merge branch 'main' into redsun82/go
2024-08-05 14:30:28 +02:00
Paolo Tranquilli
ccec347b0a
Go/Bazel: fix gazelle invocation to use bundled bazel go
2024-08-05 10:13:14 +02:00
dependabot[bot]
74596ef000
Bump golang.org/x/mod
...
Bumps the extractor-dependencies group in /go/extractor with 1 update: [golang.org/x/mod](https://github.com/golang/mod ).
Updates `golang.org/x/mod` from 0.19.0 to 0.20.0
- [Commits](https://github.com/golang/mod/compare/v0.19.0...v0.20.0 )
---
updated-dependencies:
- dependency-name: golang.org/x/mod
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: extractor-dependencies
...
Signed-off-by: dependabot[bot] <support@github.com >
2024-08-05 03:18:38 +00:00
Michael B. Gale
3a9ff64780
Go: Output stdout/stderr for go version if something goes wrong
2024-07-18 15:37:59 +01:00
dependabot[bot]
3641dfebff
Bump the extractor-dependencies group across 1 directory with 2 updates
...
Bumps the extractor-dependencies group with 2 updates in the /go/extractor directory: [golang.org/x/mod](https://github.com/golang/mod ) and [golang.org/x/tools](https://github.com/golang/tools ).
Updates `golang.org/x/mod` from 0.15.0 to 0.19.0
- [Commits](https://github.com/golang/mod/compare/v0.15.0...v0.19.0 )
Updates `golang.org/x/tools` from 0.18.0 to 0.23.0
- [Release notes](https://github.com/golang/tools/releases )
- [Commits](https://github.com/golang/tools/compare/v0.18.0...v0.23.0 )
---
updated-dependencies:
- dependency-name: golang.org/x/mod
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: extractor-dependencies
- dependency-name: golang.org/x/tools
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: extractor-dependencies
...
Signed-off-by: dependabot[bot] <support@github.com >
2024-07-17 11:46:01 +00:00
Paolo Tranquilli
e469534b84
Go/Bazel: use gazelle go_deps instead of a vendor directory
2024-07-16 13:12:37 +02:00
Michael B. Gale
7ca57e114f
Go: Add CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS env var
...
If set to `true`, this allows `vendor` directories to be extracted
2024-07-08 14:08:19 +01:00
Michael B. Gale
039537f7ba
Merge pull request #16727 from github/mbg/go/fix/too-many-go-mod-files-initialised
2024-06-14 10:14:57 +01:00
Michael B. Gale
8629e00686
Go: Remove workspace from vendor/modules.txt
2024-06-12 15:22:56 +01:00
Michael B. Gale
a04f08f026
Go: Remove go.work file
2024-06-12 15:10:28 +01:00
Michael B. Gale
e9bd85e0ba
Merge pull request #16704 from github/mbg/go/fix/build-scripts-running-more-than-once
2024-06-11 22:23:15 +01:00
Michael B. Gale
d8d1ae632c
Merge branch 'mbg/go/fix/build-scripts-running-more-than-once' into mbg/go/fix/too-many-go-mod-files-initialised
2024-06-11 18:31:03 +01:00
Michael B. Gale
0f56e408f8
Merge branch 'main' into mbg/go/fix/build-scripts-running-more-than-once
2024-06-11 18:29:41 +01:00
Michael B. Gale
864d629a13
Go: Prevent go.mod files from being added to every directory with stray source files
2024-06-11 18:24:11 +01:00
Michael B. Gale
20b7def543
Go: Only log one line for stray .go files
2024-06-11 18:06:08 +01:00
Michael B. Gale
d4adc373c6
Replace if with else if in RequiredGoVersion
2024-06-10 15:48:29 +01:00
Michael B. Gale
e7a60b72f1
Go: Check dependencies per workspace
2024-06-07 16:22:41 +00:00
Michael B. Gale
b9586a81ef
Go: Add functions for constructing go list commands
2024-06-07 16:22:40 +00:00
Michael B. Gale
6c0c3365cf
Go: Fix vendor issues and go.sum files in separate loop
2024-06-07 16:22:39 +00:00
Michael B. Gale
d344f720aa
Go: Add methods to GoModule for the tidy and vendor commands
...
These ensure that the module path is used automatically
2024-06-07 16:22:37 +00:00
Michael B. Gale
881b2586e1
Go: Add tests for RequiredGoVersion
2024-06-07 12:20:44 +00:00
Michael B. Gale
504a233299
Go: Use Toolchain directives in go.mod files, if available
2024-06-07 12:20:43 +00:00
Michael B. Gale
1d6f09c750
Go: Refactor go.mod version retrieval into its own method
2024-06-07 12:20:42 +00:00
Michael B. Gale
44a16cef6c
Go: Use Toolchain directives in go.work files, if available
2024-06-07 12:20:41 +00:00
Michael B. Gale
9d1c2c6ba1
Merge branch 'main' into mbg/go/semver-type
2024-06-07 12:09:10 +00:00