Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-modules/packages: Run unit tests under subdirs #173702

Merged
merged 8 commits into from
Jun 28, 2022
Merged

Conversation

bdd
Copy link
Contributor

@bdd bdd commented May 20, 2022

Bug Fix:

  • Due to the way buildGoDir function was repurposed to also run go test, if checkFlags was defined, go test was ran only at the top
    level directory.

  • Only the first element of checkFlags array would get passed to the
    go test command as arguments.

  • Now the first parameter to buildGoDir is handled as the command.
    If the command is "test" checkFlags get passed as arguments along
    with other build flags like ldflags, tags, etc.

Readability:

  • Iteratively build a flag array in buildGoDir instead of single long
    variable expansion command line.
  • Bash style: Single line local assignment of positional parameters.

Fix broken packages with newly enabled tests:

  • kompose: tests require git
  • gitbatch: test require git & a writable HOME. disable tests requiring
    non-localhost networking.
  • delve: tests require source to be a git repo. fix fortify issues with
    cgo.
  • go-mtpfs: disable tests requiring an android devices connected over
    USB.
  • mmake: disable test. almost all require non-localhost networking.
  • skeema: tests require coreutils and substitutions. disable tests
    requiring non-localhost networking
  • gucci: disable integrations tests.
Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@bdd
Copy link
Contributor Author

bdd commented May 20, 2022

Continuation of #171177.

Fixes the test breakages unearthed by the subdirectory fix.

@NixOS/nixos-release-managers: Should build fixes be split into to per-package commits or should they stay as part of this a single commit?

@aaronjheng
Copy link
Contributor

Great work.

@aaronjheng
Copy link
Contributor

Since checkFlags never works, why not use testFlags instead?

@aaronjheng
Copy link
Contributor

I belive most of these checkFlags are added by me. Sorry about that.

The following packages also need to fix:

  • kube-router
  • temporal
  • goconvey
  • mysqld_exporter
  • docker-credential-gcr
  • cloud-sql-proxy

I would like to help to fix it.

@bdd
Copy link
Contributor Author

bdd commented May 20, 2022

Since checkFlags never works, why not use testFlags instead?

Well, this change fixes checkFlags.

@bdd
Copy link
Contributor Author

bdd commented May 20, 2022

I belive most of these checkFlags are added by me. Sorry about that.

The following packages also need to fix:

  • kube-router
  • temporal
  • goconvey
  • mysqld_exporter
  • docker-credential-gcr
  • cloud-sql-proxy

I would like to help to fix it.

You may opt for dropping checkFlags = [ "-short" ]; from these in the master and re-enable tests for their subdirectories. I'm fairly certain they won't break, otherwise it'd be caught by the previous staging-next Hydra run.

@bdd bdd requested a review from vcunat May 20, 2022 23:00
@dasJ
Copy link
Member

dasJ commented May 21, 2022

The question about whether multiple commits are required is something I cannot really answer because it's not related to the release process.
While I think it's mergable as-is, multiple commits would be cleaner if you want to go the extra steps

@bdd
Copy link
Contributor Author

bdd commented May 31, 2022

@ofborg build kompose

@bdd bdd requested a review from SuperSandro2000 May 31, 2022 23:03
bdd added 8 commits June 1, 2022 00:52
Bug:
Due to the way `buildGoDir` function was repurposed to also run `go
test`, if `checkFlags` was defined, `go test` was ran only at the top
level directory. Only the first element of `checkFlags` array would get
passed to the `go test` command as arguments.

Fix:
Now the first parameter to `buildGoDir` is handled as the command.  If
the command is "test" `checkFlags` get passed as arguments along with
other build flags like ldflags, tags, etc.

Readability:
- Iteratively build a flag array in `buildGoDir` instead of single long
  variable expansion command line.
- Bash style: Single line local assignment of positional parameters.
The version of Ginkgo it relies on might be the problem.

Bug fixed by NixOS#173702 runs the previously skipped tests for this
package.
- Disable the tests requiring access to gitlab.com.
- Add coreutils to `nativeBuildInputs` for printf and echo binaries.
- Fix hard coded paths to coreutils binaries.

Bug fixed by NixOS#173702 runs the previously skipped tests for this
package.
Bug fixed by NixOS#173702 runs the previously skipped tests for this
package.
Bug fixed by NixOS#173702 runs the previously skipped tests for this
package.
These test are written in a way that they don't skip themselves if they
cannot find an Android device attached over USB to the running host.

Bug fixed by NixOS#173702 runs the previously skipped tests for this
package.
Disable the tests requiring access to gitlab.com

Bug fixed by NixOS#173702 runs the previously skipped tests for this
package.
Bug fixed by NixOS#173702 runs the previously skipped tests for this
package.
@bdd
Copy link
Contributor Author

bdd commented Jun 4, 2022

Note to committer: Do not squash.

@bdd
Copy link
Contributor Author

bdd commented Jun 10, 2022

@zowoq may I get your review? In the previous iteration of this, you provided valuable comments. I think this PR addresses unearthing of packages with broken test that was previously skipped (unintentionally). We're out of ZHF, so maybe we can try this in staging?

@aaronjheng aaronjheng mentioned this pull request Jun 25, 2022
13 tasks
@bdd bdd requested review from Frostman and a team June 25, 2022 16:32
@Mic92
Copy link
Member

Mic92 commented Jun 26, 2022

Looks like an eval error?

% nix-review pr 173702
$ git -c fetch.prune=false fetch --no-tags --force https://github.com/NixOS/nixpkgs staging:refs/nixpkgs-review/0 pull/173702/head:refs/nixpkgs-review/1
remote: Enumerating objects: 37310, done.
remote: Counting objects: 100% (11221/11221), done.
remote: Compressing objects: 100% (37/37), done.
remote: Total 37310 (delta 11196), reused 11188 (delta 11184), pack-reused 26089
Receiving objects: 100% (37310/37310), 59.45 MiB | 24.67 MiB/s, done.
Resolving deltas: 100% (25850/25850), completed with 2706 local objects.
From https://github.com/NixOS/nixpkgs
   7f5523d1333..6905fbbcef2  staging               -> refs/nixpkgs-review/0
 + 90e3c08600e...9d09650cef6 refs/pull/173702/head -> refs/nixpkgs-review/1  (forced update)
$ git worktree add /home/joerg/.cache/nixpkgs-review/pr-173702/nixpkgs 6905fbbcef2f0b123d55a73de83bc4d594c41834
Preparing worktree (detached HEAD 6905fbbcef2)
Updating files: 100% (30856/30856), done.
HEAD is now at 6905fbbcef2 Merge staging-next into staging
$ git merge --no-commit --no-ff 9d09650cef6cf183500d3e4c8ae0356fa0e878e4
Auto-merging pkgs/development/go-modules/generic/default.nix
Auto-merging pkgs/development/tools/delve/default.nix
Auto-merging pkgs/tools/system/skeema/default.nix
Automatic merge went well; stopped before committing as requested
error: Function called without required argument "testVersion" at /home/joerg/.cache/nixpkgs-review/pr-173702/nixpkgs/pkgs/development/tools/jira-cli-go/default.nix:1
(use '--show-trace' to show detailed location information)
nix --experimental-features nix-command --system x86_64-linux eval --json --impure --expr (import /nix/store/p8yz74kbcp1nprrcmxkd2qaczr7givwn-nixpkgs-review-2.7.0/lib/python3.9/site-packages/nixpkgs_review/nix/evalAttrs.nix { allowAliases = false; attr-json = /tmp/tmpdj2jfqm8; }) failed to run, /tmp/tmpdj2jfqm8 was stored inspection
https://github.com/NixOS/nixpkgs/pull/173702 failed to build
$ git worktree prune
nix-review pr 173702  15,41s user 7,21s system 42% cpu 53,838 total

@ofborg eval

@bdd
Copy link
Contributor Author

bdd commented Jun 26, 2022

Looks like an eval error?

[...]
error: Function called without required argument "testVersion" at /home/joerg/.cache/nixpkgs-review/pr-173702/nixpkgs/pkgs/development/tools/jira-cli-go/default.nix:1
[...]

I'm confused. This PR neither touches the failing package nor anything that'd affect the evaluation of testVersion which is an alias for testers.testVersion as defined in toplevel/aliases.nix.

My caveman test doesn't catch an eval failure:

% git reset --hard upstream/staging
HEAD is now at fe5d77ff39b liburing: 2.1 -> 2.2
% curl -LSsf https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/173702.patch | git am
Applying: go-modules/packages: Run unit tests under subdirs
Applying: gucci: Disable integration tests.
Applying: skeema: Disable tests requiring network & fix deps
Applying: mmake: Disable non-localhost network access tests
Applying: delve: Fix tests on Linux, disable tests on Darwin
Applying: go-mtpfs: Disable tests req'ing USB attached devs
Applying: gitbatch: Fix tests requiring .git & writable HOME
Applying: kompose: Fix test dependencies
% nix eval .#jira-cli-go.name
"jira-cli-go-0.3.0"

@bdd
Copy link
Contributor Author

bdd commented Jun 26, 2022

@ofborg eval
@ofborg build

@bdd
Copy link
Contributor Author

bdd commented Jun 26, 2022

@Mic92 thanks to @vcunat I think the problem nixpkgs-review hits this eval issue is because it's disabling allowAliases option; which is what testVersion is. ...but as I said above, this PR doesn't touch any packages relying on aliases.

BTW, I also filed #179226 to remove use of testVersion from master.

@Mic92 Mic92 mentioned this pull request Jun 27, 2022
13 tasks
@bdd
Copy link
Contributor Author

bdd commented Jun 27, 2022

@ofborg eval

@Mic92
Copy link
Member

Mic92 commented Jun 28, 2022

I could not test all packages because of broken dependencies, but these go ones here failed (also maybe not because of the change).

@ofborg build reproxy
@ofborg build s5cmd
@ofborg build shopify-themekit
@ofborg build toxiproxy
@ofborg build victoriametrics

@Mic92
Copy link
Member

Mic92 commented Jun 28, 2022

Mhm, weird. They failed to build, but maybe it was some concurrency issue.

@Mic92 Mic92 merged commit 4f8a04f into NixOS:staging Jun 28, 2022
@bdd bdd deleted the go-checkFlags branch December 4, 2022 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants