Skip to content

Commit 40e6e13

Browse files
committed
Expand version check script
The action now: - runs on all PRs to main / backport branches - runs on pushes to main / backport branches It always checks that the version of Turing in Project.toml matches that in _quarto.yml. Additionally, if the PR is targeted at main / the push is to the main branch, it also checks that the version of Turing matches the latest release on GitHub.
1 parent 8c4eae7 commit 40e6e13

File tree

2 files changed

+71
-43
lines changed

2 files changed

+71
-43
lines changed

.github/workflows/vcheck.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/version_check.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Check Turing.jl version
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- backport-*
7+
pull_request:
8+
branches:
9+
- master
10+
- backport-*
11+
workflow_dispatch:
12+
13+
jobs:
14+
check-version:
15+
runs-on: ubuntu-latest
16+
17+
# Determine whether the target branch is master. If so, also make sure to check that the
18+
# version matches the latest release of Turing.jl.
19+
env:
20+
TARGET_IS_MASTER: ${{ (github.event_name == 'push' && github.ref_name == 'master') || (github.event_name == 'pull_request' && github.base_ref == 'master') }}
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Julia
27+
uses: julia-actions/setup-julia@v2
28+
29+
- name: Log GitHub context variables
30+
run: |
31+
echo github.event_name: ${{ github.event_name }}
32+
echo github.ref_name: ${{ github.ref_name }}
33+
echo github.base_ref: ${{ github.base_ref }}
34+
echo TARGET_IS_MASTER: ${{ env.TARGET_IS_MASTER }}
35+
36+
- name: Check version consistency between Project.toml / _quarto.yml ${{ env.TARGET_IS_MASTER && ' / latest release' || '' }}
37+
shell: julia --color=yes --project=. {0}
38+
run: |
39+
using Pkg
40+
Pkg.activate(temp=true)
41+
Pkg.add(["YAML", "TOML", "JSON", "HTTP"])
42+
import YAML
43+
import TOML
44+
import JSON
45+
import HTTP
46+
47+
function major_minor_match(v1::VersionNumber, v2::VersionNumber)
48+
return v1.:major == v2.:major && v1.:minor == v2.:minor
49+
end
50+
51+
quarto_yaml = YAML.load_file("_quarto.yml")
52+
quarto_version = VersionNumber(quarto_yaml["website"]["navbar"]["right"][1]["text"])
53+
println("_quarto.yml version: ", quarto_version)
54+
55+
project_toml = TOML.parsefile("Project.toml")
56+
project_version = VersionNumber(project_toml["compat"]["Turing"])
57+
println("Project.toml version: ", project_version)
58+
59+
if ENV["TARGET_IS_MASTER"] == "true"
60+
resp = HTTP.get("https://github.com/api/repos/TuringLang/Turing.jl/releases/latest")
61+
latest_version = VersionNumber(JSON.parse(String(resp.body))["tag_name"])
62+
println("Latest Turing.jl version: ", latest_version)
63+
if !major_minor_match(latest_version, project_version) || !major_minor_match(latest_version, quarto_version)
64+
error("The latest version of Turing.jl (as determined from GitHub releases) is $latest_version.
65+
* Please update Project.toml and/or _quarto.yml to match this version.")
66+
end
67+
else
68+
if !major_minor_match(quarto_version, project_version)
69+
error("The versions of Turing.jl in _quarto.yml and Project.toml do not match.")
70+
end
71+
end

0 commit comments

Comments
 (0)