Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd7dc4f

Browse files
committed
Check in CI that HyperQueue and its Python binding have the same version
1 parent 20f7b68 commit dd7dc4f

9 files changed

Lines changed: 52 additions & 22 deletions

File tree

.github/workflows/nightly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ jobs:
110110
maturin-version: latest
111111
manylinux: 2014
112112
command: build
113-
args: --manifest-path crates/pyhq/Cargo.toml --release
113+
args: --manifest-path crates/pyhq/Cargo.toml --release --out wheels
114114
- name: Upload test artifacts
115115
uses: actions/upload-artifact@v2
116116
with:
117117
name: archive-pyhq
118-
path: target/wheels/hyperqueue-*.whl
118+
path: wheels/hyperqueue-*.whl
119119
create-tag:
120120
runs-on: ubuntu-latest
121121
needs: [ set-env, build-binaries-x64, build-binaries-powerpc, build-python-binding ]

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ on:
1313
tags:
1414
- 'v*'
1515
jobs:
16+
version-check:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check package versions
20+
run: python scripts/check_package_versions.py
1621
set-env:
22+
needs: [version-check]
1723
runs-on: ubuntu-latest
1824
outputs:
1925
sha: ${{ env.SHA }}

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ jobs:
4949
5050
- name: Build Python binding
5151
run: |
52-
maturin build --manifest-path crates/pyhq/Cargo.toml
53-
python -m pip install target/wheels/hyperqueue-*.whl
52+
maturin build --manifest-path crates/pyhq/Cargo.toml --out wheels
53+
python -m pip install wheels/hyperqueue-*.whl
5454
5555
- name: Test Python
5656
id: python_test
@@ -88,3 +88,6 @@ jobs:
8888
run: |
8989
python -m pip install -r docs/requirements.txt
9090
mkdocs build --strict
91+
92+
- name: Check package versions
93+
run: python scripts/check_package_versions.py

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pyhq/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyhq"
3-
version = "0.1.0"
3+
version = "0.7.0"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

scripts/check.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ cd `dirname $0`/..
88
cargo fmt --all
99

1010
# Format Python code
11-
isort --profile black tests benchmarks crates/pyhq/python
12-
black tests benchmarks crates/pyhq/python
11+
isort --profile black scripts tests benchmarks crates/pyhq/python
12+
black scripts tests benchmarks crates/pyhq/python
1313

1414
# Lint Python code
15-
flake8 tests benchmarks crates/pyhq/python
15+
flake8 scripts tests benchmarks crates/pyhq/python
1616

1717
# Test Rust code
1818
cargo test

scripts/check_package_versions.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import json
2+
import subprocess
3+
4+
if __name__ == "__main__":
5+
"""
6+
Checks that HyperQueue and its binding have the same version.
7+
"""
8+
output = (
9+
subprocess.check_output(["cargo", "metadata", "--no-deps", "-q"])
10+
.decode()
11+
.strip()
12+
)
13+
metadata = json.loads(output)
14+
packages = metadata["packages"]
15+
hq_version = [p["version"] for p in packages if p["name"] == "hyperqueue"][0]
16+
pyhq_version = [p["version"] for p in packages if p["name"] == "pyhq"][0]
17+
18+
if hq_version != pyhq_version:
19+
raise Exception(
20+
f"Hyperqueue has a different version ({hq_version}) "
21+
f"than its Python binding ({pyhq_version})"
22+
)

scripts/extract_changelog.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import sys
2-
from os.path import dirname, abspath, join
3-
2+
from os.path import abspath, dirname, join
43

54
CURRENT_DIR = dirname(abspath(__file__))
65
CHANGELOG_PATH = join(dirname(CURRENT_DIR), "CHANGELOG.md")
@@ -16,7 +15,7 @@ def get_matching_lines(text: str, tag: str):
1615
if line.startswith("# "):
1716
version = normalize(line.lstrip("# "))
1817
if version == tag:
19-
for matching_line in lines[index + 1:]:
18+
for matching_line in lines[index + 1 :]:
2019
if matching_line.startswith("# "):
2120
return
2221
yield matching_line

scripts/get_docs_version.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33

44

55
def latest_version():
6-
return {
7-
"type": "latest"
8-
}
6+
return {"type": "latest"}
97

108

119
def get_version(output: str):
1210
if not output:
1311
return latest_version()
1412
else:
15-
tags = [t.strip() for t in output.splitlines(keepends=False) if t.startswith("v")]
13+
tags = [
14+
t.strip() for t in output.splitlines(keepends=False) if t.startswith("v")
15+
]
1616
if not tags:
1717
return latest_version()
18-
return {
19-
"type": "stable",
20-
"version": sorted(tags, reverse=True)[0]
21-
}
18+
return {"type": "stable", "version": sorted(tags, reverse=True)[0]}
2219

2320

2421
if __name__ == "__main__":
2522
"""
26-
Calculates whether the current commit is a stable version (=there is some tag pointing to it) or an unstable one.
23+
Calculates whether the current commit is a stable version (=there is some tag pointing to it) or
24+
an unstable one.
2725
"""
28-
output = subprocess.check_output(["git", "tag", "--points-at", "HEAD"]).decode().strip()
26+
output = (
27+
subprocess.check_output(["git", "tag", "--points-at", "HEAD"]).decode().strip()
28+
)
2929
version = get_version(output)
3030
print(json.dumps(version))

0 commit comments

Comments
 (0)