Skip to content

Commit

Permalink
Add more useful error messages if versions are inconsistent
Browse files Browse the repository at this point in the history
  • Loading branch information
penelopeysm committed Aug 13, 2024
1 parent f8810cf commit 4177cb2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/version_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
- name: Check version consistency
shell: julia --color=yes --project=. {0}
continue-on-error: true
run: |
using Pkg
Pkg.activate(temp=true)
Expand Down Expand Up @@ -117,6 +118,8 @@ jobs:
manifest_version = VersionNumber(manifest_toml["deps"]["Turing"][1]["version"])
println("Manifest.toml version: ", manifest_version)
errors = []
if ENV["TARGET_IS_MASTER"] == "true"
# Fetch the latest version from GitHub and update files to match this version
# if necessary.
Expand All @@ -126,16 +129,20 @@ jobs:
println("Latest Turing.jl version: ", latest_version)
if !major_minor_match(latest_version, project_version)
push!(errors, "$(PROJECT_TOML_PATH) out of date")
println("$(PROJECT_TOML_PATH) is out of date; updating")
update_project_toml(PROJECT_TOML_PATH, latest_version)
end
if !major_minor_match(latest_version, quarto_version)
push!(errors, "$(QUARTO_YML_PATH) out of date")
n_errors += 1
println("$(QUARTO_YML_PATH) is out of date; updating")
update_quarto_yml(QUARTO_YML_PATH, latest_version)
end
if !major_minor_patch_match(latest_version, manifest_version)
push!(errors, "$(MANIFEST_TOML_PATH) out of date")
# Attempt to automatically update Manifest
println("$(MANIFEST_TOML_PATH) is out of date; updating")
old_env = Pkg.project().path
Expand All @@ -146,10 +153,14 @@ jobs:
manifest_toml = TOML.parsefile(MANIFEST_TOML_PATH)
manifest_version = VersionNumber(manifest_toml["deps"]["Turing"][1]["version"])
if !major_minor_patch_match(latest_version, manifest_version)
error("Failed to update Manifest.toml to match latest Turing.jl version")
push!(errors, "Failed to update $(MANIFEST_TOML_PATH) to match latest Turing.jl version")
end
end
if !isempty(errors)
error("The following errors occurred during version checking: \n", join(errors, "\n"))
end
else
# Don't attempt to fetch the latest version; just check for consistency
# and error if versions don't match.
Expand All @@ -174,7 +185,7 @@ jobs:
title: "Update Turing.jl version to match latest release"

- name: Comment on PR about suggested changes
if: ${{ github.event_name == 'pull_request' }} && ${{ steps.create_pr.outputs.pull-request-operation == 'created' }}
if: ${{ github.event_name == 'pull_request' && steps.create_pr.outputs.pull-request-operation == 'created' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Expand Down

0 comments on commit 4177cb2

Please sign in to comment.