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

[Breaking] Remove the "pre-commit hooks" and "update manifests" features #288

Merged
merged 1 commit into from
Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "1"
version = "2"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
Expand Down
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*.jl.*.cov
*.jl.cov
*.jl.mem
.DS_Store
/docs/build/
Manifest.toml
*.jl.*.cov
*.jl.cov
*.jl.mem
.DS_Store
/docs/build/
Manifest.toml
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
authors = ["Dilum Aluthge", "Brown Center for Biomedical Informatics", "contributors"]
version = "1.18.6"
version = "2.0.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
50 changes: 0 additions & 50 deletions docs/src/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,56 +26,6 @@ my_registries = [Pkg.RegistrySpec(name = "General",
CompatHelper.main(; registries = my_registries)
```

## Custom pre-commit hooks

CompatHelper supports running a custom function (called a "precommit hook") just before commiting changes. To provide a precommit hook, simple pass a zero-argument function as the first argument to `CompatHelper.main`.

## Default precommit hook

If you do not specify a precommit hook, CompatHelper will run the default precommit hook (`CompatHelper.update_manifests`), which updates all `Manifest.toml` files in your repository.

## Examples

### Example 1: Disable all precommit hooks

If you want to disable all precommit hooks, simply pass a dummy function that does nothing:

```yaml
run: julia -e '
using CompatHelper;
CompatHelper.main( () -> () );'
```

### Example 2: Print a logging message

You can add functionality by passing your own zero-argument function to `CompatHelper.main`, like so:

```yaml
run: julia -e '
using CompatHelper;
CompatHelper.main() do;
CompatHelper.update_manifests();
println("I did it!");
end;'
```

This snippet uses `;` to specify the ends of lines, because according to YAML, the entire block of Julia code is a single line.
Also to note is that you cannot use `'` inside of your Julia command, since it's used to quote the Julia code.

A full example is available [here](https://github.com/tkf/Kaleido.jl/blob/42f8125f42413ef21160575d870819bba33296d5/.github/workflows/CompatHelper.yml).

### Example 3: Only update the `Manifest.toml` in the root of the repository

The following snippet tells CompatHelper to update the `Manifest.toml` file in the root of the repository but not any of the other `Manifest.toml` files. So, for example, `/Manifest.toml` will be updated, but `/docs/Manifest.toml`, `/examples/Manifest.toml`, and `/test/Manifest.toml` will not be updated.

```yaml
run: julia -e 'using CompatHelper; CompatHelper.main( (; registries) -> CompatHelper._update_manifests(String[pwd()]; registries = registries, delete_old_manifest = true) )'
```

If the keyword argument `delete_old_manifest` is set to true, as in the above example, then CompatHelper
updates the Manifest.toml file by deleting the Manifest and running `Pkg.update()` in order to generate a new
one. If `delete_old_manifest=false`, then CompatHelper runs `Pkg.update()` without first deleting the Manifest.

## Overriding the default branch

By default, CompatHelper will open pull requests against your repository's default branch. If you would like to override this behavior, set the `master_branch` keyword argument. For example:
Expand Down
17 changes: 9 additions & 8 deletions docs/src/other-environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ ENV["GITHUB_REPOSITORY"] = "org/repo"
username = "github user name that matches the access token"
email = "email address"

CompatHelper.main(CompatHelper.update_manifests,
ENV,
CompatHelper.GitHubActions(username, email);
hostname_for_api = "https://github.saobby.my.eu.orgpany.com/api/v3",
hostname_for_clone = "github.company.com")
CompatHelper.main(
ENV,
CompatHelper.GitHubActions(username, email);
hostname_for_api = "https://github.saobby.my.eu.orgpany.com/api/v3",
hostname_for_clone = "github.company.com",
)
```

To run it on TeamCity instead of GitHub Actions, you need to specify the `ci_cfg` parameter, e.g. like this.
```julia
using CompatHelper
CompatHelper.main(CompatHelper.update_manifests,
CompatHelper.main(
ENV,
CompatHelper.TeamCity(<your bot github account username>, <your bot github email>)
)
CompatHelper.TeamCity("<your bot github account username>", "<your bot github email>"),
)
```
Because of high configurability of TeamCity it's advised to pass the TeamCity structure explicitly without usage of the
`auto_detect_ci_service` function, which is suitable for some simpler setups.
1 change: 0 additions & 1 deletion src/CompatHelper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ include("pull_requests.jl")
include("ssh_keys.jl")
include("stdlib.jl")
include("timestamps.jl")
include("update_manifests.jl")
include("utils.jl")
include("version_numbers.jl")

Expand Down
4 changes: 1 addition & 3 deletions src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ const default_registries = Pkg.RegistrySpec[Pkg.RegistrySpec(name = "General",
uuid = "23338594-aafe-5451-b93e-139f81909106",
url = "https://github.com/JuliaRegistries/General.git")]

function main(precommit_hook::Function = update_manifests,
env::AbstractDict = ENV,
function main(env::AbstractDict = ENV,
ci_cfg::CIService = auto_detect_ci_service(; env = env);
registries::Vector{Pkg.RegistrySpec} = default_registries,
keep_existing_compat::Bool = true,
Expand Down Expand Up @@ -57,7 +56,6 @@ function main(precommit_hook::Function = update_manifests,

make_pr_for_new_version(api,
clone_hostname,
precommit_hook,
repo,
dep_to_current_compat_entry,
dep_to_current_compat_entry_verbatim,
Expand Down
16 changes: 0 additions & 16 deletions src/new_versions.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
function make_pr_for_new_version(api::GitHub.GitHubAPI,
clone_hostname::HostnameForClones,
precommit_hook::Function,
repo::GitHub.Repo,
dep_to_current_compat_entry::Dict{Package, Union{Pkg.Types.VersionSpec, Nothing}},
dep_to_current_compat_entry_verbatim::Dict{Package, Union{String, Nothing}},
Expand All @@ -23,7 +22,6 @@ function make_pr_for_new_version(api::GitHub.GitHubAPI,
for dep in keys(dep_to_current_compat_entry)
make_pr_for_new_version(api,
clone_hostname,
precommit_hook,
repo,
dep,
dep_to_current_compat_entry,
Expand All @@ -48,7 +46,6 @@ end

function make_pr_for_new_version(api::GitHub.GitHubAPI,
clone_hostname::HostnameForClones,
precommit_hook::Function,
repo::GitHub.Repo,
dep::Package,
dep_to_current_compat_entry::Dict{Package, Union{Pkg.Types.VersionSpec, Nothing}},
Expand Down Expand Up @@ -104,7 +101,6 @@ function make_pr_for_new_version(api::GitHub.GitHubAPI,
:brandnewentry)
make_pr_for_new_version(api,
clone_hostname,
precommit_hook,
compat_entry_for_latest_version,
brand_new_compat,
repo,
Expand All @@ -130,7 +126,6 @@ function make_pr_for_new_version(api::GitHub.GitHubAPI,
:drop)
make_pr_for_new_version(api,
clone_hostname,
precommit_hook,
compat_entry_for_latest_version,
drop_compat,
repo,
Expand All @@ -156,7 +151,6 @@ function make_pr_for_new_version(api::GitHub.GitHubAPI,
:keep)
make_pr_for_new_version(api,
clone_hostname,
precommit_hook,
compat_entry_for_latest_version,
keep_compat,
repo,
Expand Down Expand Up @@ -202,7 +196,6 @@ end

function make_pr_for_new_version(api::GitHub.GitHubAPI,
clone_hostname::HostnameForClones,
precommit_hook::Function,
compat_entry_for_latest_version::String,
new_compat_entry::String,
repo::GitHub.Repo,
Expand Down Expand Up @@ -325,15 +318,6 @@ function make_pr_for_new_version(api::GitHub.GitHubAPI,
run(`git add -A`)
catch
end
if hasmethod(precommit_hook, Tuple{}, (:registries,)) || hasmethod(precommit_hook, Tuple{AbstractString}, (:registries,))
precommit_hook(; registries = registries)
else
precommit_hook()
end
try
run(`git add -A`)
catch
end
@info("Attempting to commit...")
commit_was_success = git_make_commit(; commit_message = new_pr_title)
if commit_was_success
Expand Down
78 changes: 0 additions & 78 deletions src/update_manifests.jl

This file was deleted.

Loading