Skip to content

Commit 8f03259

Browse files
committed
ARROW-17353: [Release][R] Validate binaries version (#14396)
We generate version in Crossbow not CI job. We can use file name validation feature by using version generated by Crossbow. We use "X.Y.Z" version for RC version such as "10.0.0" for "10.0.0-rc1". Authored-by: Sutou Kouhei <kou@clear-code.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent a735316 commit 8f03259

File tree

8 files changed

+72
-28
lines changed

8 files changed

+72
-28
lines changed

dev/archery/archery/crossbow/core.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,14 +738,16 @@ class Target(Serializable):
738738
(currently only an email address where the notification should be sent).
739739
"""
740740

741-
def __init__(self, head, branch, remote, version, email=None):
741+
def __init__(self, head, branch, remote, version, r_version, email=None):
742742
self.head = head
743743
self.email = email
744744
self.branch = branch
745745
self.remote = remote
746746
self.github_repo = "/".join(_parse_github_user_repo(remote))
747747
self.version = version
748+
self.r_version = r_version
748749
self.no_rc_version = re.sub(r'-rc\d+\Z', '', version)
750+
self.no_rc_r_version = re.sub(r'-rc\d+\Z', '', r_version)
749751
# TODO(ARROW-17552): Remove "master" from default_branch after
750752
# migration to "main".
751753
self.default_branch = ['main', 'master']
@@ -791,8 +793,39 @@ def from_repo(cls, repo, head=None, branch=None, remote=None, version=None,
791793
if email is None:
792794
email = repo.user_email
793795

796+
version_dev_match = re.match(r".*\.dev(\d+)$", version)
797+
if version_dev_match:
798+
with open(f"{repo.path}/r/DESCRIPTION") as description_file:
799+
description = description_file.read()
800+
r_version_pattern = re.compile(r"^Version:\s*(.*)$",
801+
re.MULTILINE)
802+
r_version = re.findall(r_version_pattern, description)[0]
803+
if r_version:
804+
version_dev = int(version_dev_match[1])
805+
# "1_0000_00_00 +" is for generating a greater version
806+
# than YYYYMMDD. For example, 1_0000_00_01
807+
# (version_dev == 1 case) is greater than 2022_10_16.
808+
#
809+
# Why do we need a greater version than YYYYMMDD? It's
810+
# for keeping backward compatibility. We used
811+
# MAJOR.MINOR.PATCH.YYYYMMDD as our nightly package
812+
# version. (See also ARROW-16403). If we use "9000 +
813+
# version_dev" here, a developer that used
814+
# 9.0.0.20221016 can't upgrade to the later nightly
815+
# package unless we release 10.0.0. Because 9.0.0.9234
816+
# or something is less than 9.0.0.20221016.
817+
r_version_dev = 1_0000_00_00 + version_dev
818+
# version: 10.0.0.dev234
819+
# r_version: 9.0.0.9000
820+
# -> 9.0.0.100000234
821+
r_version = re.sub(r"\.9000\Z", f".{r_version_dev}", r_version)
822+
else:
823+
r_version = version
824+
else:
825+
r_version = version
826+
794827
return cls(head=head, email=email, branch=branch, remote=remote,
795-
version=version)
828+
version=version, r_version=r_version)
796829

797830
def is_default_branch(self):
798831
# TODO(ARROW-17552): Switch the condition to "is" instead of "in"
@@ -1105,7 +1138,10 @@ def from_config(cls, config, target, tasks=None, groups=None, params=None):
11051138
'version': target.version,
11061139
'no_rc_version': target.no_rc_version,
11071140
'no_rc_semver_version': target.no_rc_semver_version,
1108-
'no_rc_snapshot_version': target.no_rc_snapshot_version}
1141+
'no_rc_snapshot_version': target.no_rc_snapshot_version,
1142+
'r_version': target.r_version,
1143+
'no_rc_r_version': target.no_rc_r_version,
1144+
}
11091145
for task_name, task in task_definitions.items():
11101146
task = task.copy()
11111147
artifacts = task.pop('artifacts', None) or [] # because of yaml
@@ -1260,6 +1296,7 @@ def validate(self):
12601296
branch='master',
12611297
remote='https://github.com/apache/arrow',
12621298
version='1.0.0dev123',
1299+
r_version='0.13.0.100000123',
12631300
email='dummy@example.ltd'
12641301
)
12651302
job = Job.from_config(config=self,

dev/archery/archery/crossbow/tests/fixtures/crossbow-job-no-failure.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ target: !Target
55
branch: refs/pull/4435/merge
66
remote: https://github.com/apache/arrow
77
version: 0.13.0.dev306
8+
r_version: 0.12.0.100000306
89
no_rc_version: 0.13.0.dev306
10+
no_rc_r_version: 0.12.0.100000306
911
tasks:
1012
docker-cpp-cmake32: !Task
1113
ci: circle
@@ -64,4 +66,4 @@ branch: ursabot-1
6466
_queue: !Queue
6567
path: the_path
6668
github_token: xxxxxxxxx
67-
_remote_url: https://github.com/apache/crossbow
69+
_remote_url: https://github.com/apache/crossbow

dev/archery/archery/crossbow/tests/fixtures/crossbow-job.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ target: !Target
55
branch: refs/pull/4435/merge
66
remote: https://github.com/apache/arrow
77
version: 0.13.0.dev306
8+
r_version: 0.12.0.100000306
89
no_rc_version: 0.13.0.dev306
10+
no_rc_r_version: 0.12.0.100000306
911
tasks:
1012
docker-cpp-cmake32: !Task
1113
ci: circle
@@ -64,4 +66,4 @@ branch: ursabot-1
6466
_queue: !Queue
6567
path: the_path
6668
github_token: xxxxxxxxx
67-
_remote_url: https://github.com/apache/crossbow
69+
_remote_url: https://github.com/apache/crossbow

dev/tasks/macros.jinja

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ on:
269269
rm -f apache-arrow*.rb.bak
270270
{% endmacro %}
271271

272-
{%- macro github_change_r_pkg_version(is_fork, version = '\\2.\'\"$(date +%Y%m%d)\"\'' ) -%}
272+
{%- macro github_change_r_pkg_version(is_fork, version) -%}
273273
- name: Modify version
274274
shell: bash
275275
run: |
@@ -339,12 +339,16 @@ on:
339339
# tree not available in git-bash on windows
340340
run: |
341341
ls -R repo
342-
- name: Add dev repo to .Rprofile
342+
- name: Add repos to .Rprofile
343343
shell: Rscript {0}
344344
run: |
345-
str <- paste0("options(arrow.dev_repo ='file://", getwd(), "/repo' )")
346-
print(str)
347345
profile_path <- file.path(getwd(), ".Rprofile")
346+
repo <- paste0("file://", getwd(), "/repo")
347+
str <- paste0("options(arrow.repo = '", repo, "' )")
348+
print(str)
349+
write(str, file = profile_path, append = TRUE)
350+
str <- paste0("options(arrow.dev_repo = '", repo, "' )")
351+
print(str)
348352
write(str, file = profile_path, append = TRUE)
349353
# Set envvar for later steps by appending to $GITHUB_ENV
350354
write(paste0("R_PROFILE_USER=", profile_path), file = Sys.getenv("GITHUB_ENV"), append = TRUE)

dev/tasks/r/github.packages.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
{% import 'macros.jinja' as macros with context %}
1919

20-
# This allows us to set a custom version via param:
21-
# crossbow submit --param custom_version=8.5.3 r-binary-packages
22-
# if the param is unset defaults to the usual Ymd naming scheme
23-
{% set package_version = custom_version|replace("Unset", "\\2.\'\"$(date +%Y%m%d)\"\'") %}
2420
{% set is_fork = macros.is_fork %}
2521

2622
{{ macros.github_header() }}
@@ -35,7 +31,7 @@ jobs:
3531
pkg_version: {{ '${{ steps.save-version.outputs.pkg_version }}' }}
3632
steps:
3733
{{ macros.github_checkout_arrow()|indent }}
38-
{{ macros.github_change_r_pkg_version(is_fork, package_version)|indent }}
34+
{{ macros.github_change_r_pkg_version(is_fork, arrow.no_rc_r_version)|indent }}
3935
- name: Save Version
4036
id: save-version
4137
shell: bash
@@ -281,7 +277,7 @@ jobs:
281277
{{ macros.github_test_r_src_pkg()|indent(8) }}
282278
'
283279
- name: Upload binary artifact
284-
if: matrix.config.devtoolset
280+
if: matrix.config.devtoolset
285281
uses: actions/upload-artifact@v3
286282
with:
287283
name: r-pkg_centos7

dev/tasks/tasks.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -957,17 +957,17 @@ tasks:
957957
params:
958958
custom_version: Unset
959959
artifacts:
960-
- r-lib__libarrow__bin__windows__arrow-[0-9\.]+\.zip
961-
- r-lib__libarrow__bin__centos-7__arrow-[0-9\.]+\.zip
962-
- r-lib__libarrow__bin__ubuntu-18.04__arrow-[0-9\.]+\.zip
963-
- r-lib__libarrow__bin__ubuntu-22.04__arrow-[0-9\.]+\.zip
964-
- r-pkg__bin__windows__contrib__4.1__arrow_[0-9\.]+\.zip
965-
- r-pkg__bin__windows__contrib__4.2__arrow_[0-9\.]+\.zip
966-
- r-pkg__bin__macosx__contrib__4.1__arrow_[0-9\.]+\.tgz
967-
- r-pkg__bin__macosx__contrib__4.2__arrow_[0-9\.]+\.tgz
968-
- r-pkg__bin__macosx__big-sur-arm64__contrib__4.1__arrow_[0-9\.]+\.tgz
969-
- r-pkg__bin__macosx__big-sur-arm64__contrib__4.2__arrow_[0-9\.]+\.tgz
970-
- r-pkg__src__contrib__arrow_[0-9\.]+\.tar\.gz
960+
- r-lib__libarrow__bin__windows__arrow-{no_rc_r_version}\.zip
961+
- r-lib__libarrow__bin__centos-7__arrow-{no_rc_r_version}\.zip
962+
- r-lib__libarrow__bin__ubuntu-18.04__arrow-{no_rc_r_version}\.zip
963+
- r-lib__libarrow__bin__ubuntu-22.04__arrow-{no_rc_r_version}\.zip
964+
- r-pkg__bin__windows__contrib__4.1__arrow_{no_rc_r_version}\.zip
965+
- r-pkg__bin__windows__contrib__4.2__arrow_{no_rc_r_version}\.zip
966+
- r-pkg__bin__macosx__contrib__4.1__arrow_{no_rc_r_version}\.tgz
967+
- r-pkg__bin__macosx__contrib__4.2__arrow_{no_rc_r_version}\.tgz
968+
- r-pkg__bin__macosx__big-sur-arm64__contrib__4.1__arrow_{no_rc_r_version}\.tgz
969+
- r-pkg__bin__macosx__big-sur-arm64__contrib__4.2__arrow_{no_rc_r_version}\.tgz
970+
- r-pkg__src__contrib__arrow_{no_rc_r_version}\.tar\.gz
971971

972972

973973
########################### Release verification ############################

r/tools/nixlibs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dev_version <- package_version(VERSION)[1, 4]
3232
# Small dev versions are added for R-only changes during CRAN submission.
3333
if (is.na(dev_version) || dev_version < 100) {
3434
VERSION <- package_version(VERSION)[1, 1:3]
35-
arrow_repo <- sprintf("https://apache.jfrog.io/artifactory/arrow/r/%s/libarrow/", VERSION)
35+
arrow_repo <- paste0(getOption("arrow.repo", sprintf("https://apache.jfrog.io/artifactory/arrow/r/%s", VERSION)), "/libarrow/")
3636
} else {
3737
arrow_repo <- paste0(getOption("arrow.dev_repo", "https://nightlies.apache.org/arrow/r"), "/libarrow/")
3838
}

r/tools/winlibs.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ if (!file.exists(sprintf("windows/arrow-%s/include/arrow/api.h", VERSION))) {
4444
"/libarrow/bin/windows/arrow-%s.zip"
4545
)
4646
# %1$s uses the first variable for both substitutions
47-
artifactory <- "https://apache.jfrog.io/artifactory/arrow/r/%1$s/libarrow/bin/windows/arrow-%1$s.zip"
47+
artifactory <- paste0(
48+
getOption("arrow.repo", "https://apache.jfrog.io/artifactory/arrow/r/%1$s"),
49+
"/libarrow/bin/windows/arrow-%1$s.zip"
50+
)
4851
rwinlib <- "https://github.com/rwinlib/arrow/archive/v%s.zip"
4952

5053
dev_version <- package_version(VERSION)[1, 4]

0 commit comments

Comments
 (0)