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

Add check command #318

Merged
merged 5 commits into from
Mar 18, 2021
Merged

Add check command #318

merged 5 commits into from
Mar 18, 2021

Conversation

pitag-ha
Copy link
Member

@pitag-ha pitag-ha commented Dec 8, 2020

The PR adds the new check command which allows the user to make sure that the whole release process will be smooth: it checks if the opam-file is dune-release compatible and - unless stated otherwise by the user via the skip options - performs the checks that are done on the distribution archive: if it builds, if it passes its tests and if it passes the dune-release lints.

For all that, the same options are taken into account as will be when releasing. I've left out the options --dist-opam, --readme and --change-log, since they are also left out in dune-release lint. But it would probably be good to make that consistent at some point..

Before the commit adding the check command there are a couple of commits improving and fixing some minor issues in that context (see commit messages).

Copy link
Member

@gpetiot gpetiot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides a few minor comments it looks good to me, thanks! Don't forget to add a changelog entry though

lib/vcs.mli Outdated Show resolved Hide resolved
bin/check.ml Outdated Show resolved Hide resolved
bin/check.ml Outdated Show resolved Hide resolved
lib/check.mli Outdated Show resolved Hide resolved
lib/check.mli Outdated Show resolved Hide resolved
lib/pkg.ml Outdated Show resolved Hide resolved
@NathanReb NathanReb added this to the 1.5.0 milestone Jan 20, 2021
lib/pkg.ml Show resolved Hide resolved
bin/help.ml Show resolved Hide resolved
@pitag-ha pitag-ha changed the title Check Add check command Feb 9, 2021
tests/bin/check/run.t Outdated Show resolved Hide resolved
lib/pkg.ml Show resolved Hide resolved
Copy link
Contributor

@NathanReb NathanReb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good but I think there are a few things to improve and clarify. I left a few review comments but I also have things to report here.

I tried it locally on a dummy project and got the following:

[ OK ] main package dummy.opam is dune-release compatible.
[ OK ] connected to internet
[ OK ] package(s) build
[ OK ] package(s) pass the tests
[FAIL] lint of _build/.dune-release-check and package dummy failure: 1 errors.
For information on the lint errors, run `dune-release lint`.

I think the lint report should be printed here, having to run a separate command to get the results seems kind of unfriendly to the user. Is there a particular reason that made it hard to show the lint results here?

Another thing that strike me is the part about the internet connection. I think that if we want to go down that road there are better things to check like does the repo exist, does the user opam fork exists, is the token properly set and does the user can talk to the github API, do they have their ssh key properly set etc...
In a first iteration I think it is safer to stick to strictly local checks, we can always think of how to improve this further later. The current internet check probably doesn't add much value.

Also a quick note: I think the PR needs a rebase!

CHANGES.md Outdated Show resolved Hide resolved
bin/check.ml Outdated Show resolved Hide resolved
bin/check.ml Outdated
~skip_lint ~skip_build ~skip_tests ~dir ()
in
let () =
match Sos.delete_dir ~dry_run:false ~force:true dir with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not taking the value of dry_run here?

There's a genuine question about what we should do about dry-run in this command but as you seem to pass it to the check_project function I assume it is used there and therefore should be used here. i.e. if we want to allow dry-run for check, it should not create the clone either here.

To be honest I don't think check should allow dry-run since it is only doing things locally and not touching versioned files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

To be honest I don't think check should allow dry-run

I think the same, but lint allows dry-run and I wanted to be coherent. I guess we're going to remove dry-run from lint in 2.0.0. Is that right? Thinking about dry-run in check twice, I also think it's better to directly not have it (even being incoherent with lint for a short time). Is that what you meant? If so, I change it.

Btw, there was a similar problem with some of the command line options: --dist-opam, --readme and --change-log. I think both lint and check should have them. But lint doesn't at the moment. I decided to be coherent with lint there, too. What do you think about that?

lib/pkg.ml Outdated Show resolved Hide resolved
@pitag-ha
Copy link
Member Author

Is there a particular reason that made it hard to show the lint results here?

Letting the lint results get logged directly would look as follows:

[ OK ] main package dummy.opam is dummy compatible.
[ OK ] package(s) build
[ OK ] package(s) pass the tests
[ OK ] File README is present.
[FAIL] File LICENSE is missing.
[ OK ] File CHANGES is present.
[ OK ] File opam is present.
[ OK ] lint opam file dummy.opam.
[ OK ] opam field description is present
[ OK ] opam fields homepage and dev-repo can be parsed by dummy
[ OK ] opam field doc can be parsed by dummy
[FAIL] lint of _build/.dummy-check and package dummy failure: 1 errors.

In a 2-package project it would even look like this:

[ OK ] main package dummy.opam is dummy compatible.
[ OK ] package(s) build
[FAIL] package(s) pass the tests
[ OK ] File README is present.
[FAIL] File LICENSE is missing.
[ OK ] File CHANGES is present.
[ OK ] File opam is present.
[ OK ] lint opam file dummy_sub.opam.
[ OK ] opam field description is present
[ OK ] opam fields homepage and dev-repo can be parsed by dummy
[ OK ] opam field doc can be parsed by dummy
[FAIL] lint of /home/sonja/Documents/Tarides/projects/dummy and package dummy_sub failure: 1 errors.
[ OK ] File README is present.
[FAIL] File LICENSE is missing.
[ OK ] File CHANGES is present.
[ OK ] File opam is present.
[ OK ] lint opam file dummy.opam.
[ OK ] opam field description is present
[ OK ] opam fields homepage and dev-repo can be parsed by dummy
[ OK ] opam field doc can be parsed by dummy
[FAIL] lint of /home/sonja/Documents/Tarides/projects/dummy and package dummy failure: 1 errors.

So I think that the lint output would pollute the output quite a bit. But you're right that having to run a separate command if the lint fails isn't a great solution either. I figured that for now it didn't matter to much, since in 2.0.0 we should improve the lint anyways (in multi-package projects, only run the hygiene checks once since they are package independent).

What do you think about that output "pollution"? Do you think that would be ok for now (and better than having to run another commend)? Maybe I could figure out if it would be easy to indent the lint output (to make clear which check comes from where).

I think that if we want to go down that road there are better things to check like does the repo exist, does the user opam fork exists, is the token properly set and does the user can talk to the github API, do they have their ssh key properly set etc...

That's a very good point! I've removed the internet check and left it on a different branch in case at some point we want to check more things.

tests/bin/check/make_test_directory_deterministic.ml Outdated Show resolved Hide resolved
tests/bin/check/run.t Outdated Show resolved Hide resolved
tests/bin/check/run.t Outdated Show resolved Hide resolved
CHANGES.md Outdated Show resolved Hide resolved
bin/check.ml Outdated Show resolved Hide resolved
lib/pkg.ml Show resolved Hide resolved
lib/pkg.ml Show resolved Hide resolved
bin/help.ml Show resolved Hide resolved
@NathanReb
Copy link
Contributor

Can you rebase it please?

@gpetiot gpetiot requested a review from NathanReb March 15, 2021 13:44
Copy link
Contributor

@NathanReb NathanReb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I just have minor comments regarding the tests but otherwise it's all 👍

tests/bin/check/run.t Show resolved Hide resolved
tests/bin/check/run.t Outdated Show resolved Hide resolved
The command line argument `distrib_uri` has two purposes
- for delegates
- to let dune-release in `dune-relesae opam` know where the distribution
tarball is on the web when having published the distribution independently

Furthermore, `dune-release publish` needs to know on which github url
to publish the release. Therefore it inferres the user and repo name from
the dev-repo url. Before this commit, the user and repo name were instead
inferred from the `distrib_uri` when provided, assuming that it is the
standard release uri of a github realease without checking that. This
commit removes this use of `ditrib_uri`.
Only mentioning the directory of the project is misleading, since the lint
doesn't only check if the standard files in the directory exist, but also
lints the opam file of the package. Before this commit, in multi pckage
projects, the lint summary statement for every package was the same - only
the number of lint errors possibly changed.
Writing "package" in singular misleads into thinking that only the main
package gets checked for build and tests, whereas in fact either all
packages or all packages passed in via `-p` are checked.

Particularly for the `check` command it's important to be precise here,
since in that command some checks are done just for the main package and
others for all packages.
@pitag-ha pitag-ha force-pushed the check branch 2 times, most recently from 1e3a627 to bee0478 Compare March 17, 2021 15:59
@pitag-ha pitag-ha requested a review from NathanReb March 17, 2021 16:02
The new check command allows the user to make sure that the whole release
process will be smooth: it checks if the opam-file is dune-release compatible
and - unless stated otherwise by the
user via the skip options - performs the checks that will be done on the
distribution archive: if it builds, if it passes its tests and if it
passes the dune-release lints. For all that, the same options are taken
into account as will be when releasing.
@pitag-ha pitag-ha mentioned this pull request Mar 17, 2021
@pitag-ha pitag-ha merged commit 9f52358 into tarides:master Mar 18, 2021
NathanReb added a commit to NathanReb/opam-repository that referenced this pull request Jul 5, 2021
CHANGES:

### Added

- Add `--no-auto-open` to the default command. It was previously only available for
  `dune-release opam`. (tarides/dune-release#374, @NathanReb)
- Add a `config create` subcommand to create a fresh configuration if you don't have one yet
  (tarides/dune-release#373, @NathanReb)
- Add `--local-repo`, `--remote-repo` and `--opam-repo` options to the default command,
  they used to be only available for the `opam` subcommand (tarides/dune-release#363, @NathanReb)
- Add a `--token` option to `dune-release publish` and `dune-release opam` commands
  to specify a github token. This allows dune-release to be called through a Github
  Actions workflow and use the github token through an environment variable.
  (tarides/dune-release#284 tarides/dune-release#368, @gpetiot @NathanReb)
- Log curl calls on verbose/debug mode (tarides/dune-release#281, @gpetiot)
- Try to publish the release asset again after it failed (tarides/dune-release#272, @gpetiot)
- Improve error reporting of failing git comands (tarides/dune-release#257, @gpetiot)
- Suggest a solution for users without ssh setup (tarides/dune-release#304, @pitag-ha)
- Allow including git submodules to the distrib tarball by passing the
  `--include-submodules` flag to `dune-release`, `dune-release bistro` or
  `dune-release distrib` (tarides/dune-release#300, @NathanReb)
- Support 'git://' scheme for dev-repo uri (tarides/dune-release#331, @gpetiot)
- Support creation of draft releases and draft PRs. Define a new option
  `--draft` for `dune-release publish` and `dune-release opam submit` commands.
  (tarides/dune-release#248, @gpetiot)
- Add a new command `check` to check the prerequisites of dune-release and
  avoid starting a release process that couldn't be finished (tarides/dune-release#318, tarides/dune-release#351, @pitag-ha)
- When preparing the opam-repository PR and pushing the local branch to
  the user's remote opam-repository fork, use `--set-upstream` to ease any further
  update of the PR (tarides/dune-release#350, @gpetiot)

### Changed

- Entirely rely on the remote fork of opam-repository URL in `opam submit` instead of
  reading the user separately. The information was redundant and could only lead to bugs
  when unproperly set. (tarides/dune-release#372, @NathanReb)
- Use pure token authentication for Github API requests rather than "token as passwords"
  authentication (tarides/dune-release#369, @NathanReb)
- Require tokens earlier in the execution of commands that use the github API. If the token
  isn't saved to the user's configuration, the prompt for creating one will show up at the
  command startup rather than on sending the first request (tarides/dune-release#368, @NathanReb)
- Attach the changelog to the annotated tag message (tarides/dune-release#283, @gpetiot)
- Do not remove versioned files from the tarball anymore. We used to exclude
  `.gitignore`, `.gitattributes` and other such files from the archive.
  (tarides/dune-release#299, @NathanReb)
- Don't try to push the tag if it is already present and point to the same ref on the remote.
  `dune-release` must guess which URI to pass to `git push` and may guess it wrong.
  This change allows users to push the tag manually to avoid using that code. (tarides/dune-release#219, @Julow)
- Don't try to create the release if it is already present and points to the same tag (tarides/dune-release#277, @kit-ty-kate)
- Recursively exclude all `.git`/`.hg` files and folders from the distrib
  tarball (tarides/dune-release#300, @NathanReb)
- Make the automatic dune-release workflow to stop if a step exits with a non-zero code (tarides/dune-release#332, @gpetiot)
- Make git-related mdx tests more robust in unusual environments (tarides/dune-release#334, @sternenseemann)
- Set the default tag message to "Release <tag>" instead of "Distribution <tag>"
- Opam file linter: check for `synopsis` instead of `description` (tarides/dune-release#291, @kit-ty-kate)
- Upgrade the use of the opam libraries to opam 2.1 (tarides/dune-release#343, @kit-ty-kate)

### Deprecated

- Deprecate the `--user` CLI options and configuration field, they were redundant with
  the remote-repo option and field and could be set unproperly, leading to bugs (tarides/dune-release#372, @NathanReb)
- Deprecate the use of delegates in `dune-release publish` (tarides/dune-release#276, tarides/dune-release#302, @pitag-ha)
- Deprecate the use of opam file format 1.x (tarides/dune-release#352, @NathanReb)

### Removed

- Option --name is removed from all commands. When used with
  `dune-release distrib`, it was previously effectively ignored. Now
  it is required to add a `(name <name>)` stanza to
  `dune-project`. (tarides/dune-release#327, @lehy)

### Fixed

- Fix a bug where `opam submit` would look up a config file, even though all the required
  information was provided on the command line. This would lead to starting the interactive
  config creation quizz if that file did not exist which made it impossible to use it in a CI
  for instance. (tarides/dune-release#373, @NathanReb)
- Fix a bug where `opam submit` would fail on non-github repositories if the user had no
  configuration file (tarides/dune-release#372, @NathanReb)
- Fix a bug where subcommands wouldn't properly read the token files, leading to authentication
  failures on API requests (tarides/dune-release#368, @NathanReb)
- Fix a bug in `opam submit` preventing non-github users to create the opam-repo PR
  via dune-release. (tarides/dune-release#359, @NathanReb)
- Fix a bug where `opam submit` would try to parse the custom URI provided through
  `--distrib-uri` as a github repo URI instead of using the dev-repo (tarides/dune-release#358, @NathanReb)
- Fix the priority of the `--distrib-uri` option in `dune-release opam pkg`.
  It used to have lower precendence than the url file written by `dune-release publish`
  and therefore made it impossible to overwrite it if needed. (tarides/dune-release#255, @NathanReb)
- Fix a bug with --distrib-file in `dune-release opam pkg` where you would need
  the regular dune-release generated archive to be around even though you specified
  a custom distrib archive file. (tarides/dune-release#255, @NathanReb)
- Use int64 for timestamps. (tarides/dune-release#261, @gpetiot)
- Define the order of packages (tarides/dune-release#263, @gpetiot)
- Allow the dry-run mode to continue even after some API call's response were expected by using placeholder values (tarides/dune-release#262, @gpetiot)
- Build and run tests for all selected packages when checking distribution tarball
  (tarides/dune-release#266, @NathanReb)
- Improve trimming of the changelog to preserve the indentation of the list of changes. (tarides/dune-release#268, @gpetiot)
- Trim the data of the `url` file before filling the `url.src` field. This fixes an issue that caused the `url.src` field to be a multi-line string instead of single line. (tarides/dune-release#270, @gpetiot)
- Fix a bug causing dune-release to exclude all hidden files and folders (starting with `.`) at the
  repository from the distrib archive (tarides/dune-release#298, @NathanReb)
- Better report GitHub API errors, all of the error messages reported by the GitHub API are now checked and reported to the user. (tarides/dune-release#290, @gpetiot)
- Fix error message when `dune-release tag` cannot guess the project name (tarides/dune-release#319, @lehy)
- Always warn about uncommitted changes at the start of `dune-release
  distrib` (tarides/dune-release#325, @lehy).  Otherwise uncommitted changes to
  dune-project would be silently ignored by `dune-release distrib`.
- Fix rewriting of github references in changelog (tarides/dune-release#330, @gpetiot)
- Fixes a bug under cygwin where dune-release was unable to find the commit hash corresponding to the release tag (tarides/dune-release#329, @gpetiot)
- Fixes release names by explicitly setting it to match the released version (tarides/dune-release#338, @NathanReb)
- Fix a bug that prevented release of a package whose version number contains invalid characters for a git branch. The git branch names are now sanitized. (tarides/dune-release#271, @gpetiot)
- `publish`: Fix the process of inferring user name and repo from the dev repo uri (tarides/dune-release#348, @pitag-ha)
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.

3 participants