Unverified Commit 5538eb8d authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] [ci] Reduce manual effort for version updates (#3335)



* [R-package] [ci] Reduce manual effort for version updates

* fix configure

* remove useless comment

* Update build_r.R
Co-authored-by: default avatarGuolin Ke <guolin.ke@outlook.com>

* fix recreate-configure check in CI
Co-authored-by: default avatarGuolin Ke <guolin.ke@outlook.com>
parent 9503d3f9
...@@ -134,12 +134,7 @@ elif [[ $R_BUILD_TYPE == "cran" ]]; then ...@@ -134,12 +134,7 @@ elif [[ $R_BUILD_TYPE == "cran" ]]; then
# on Linux, we recreate configure in CI to test if # on Linux, we recreate configure in CI to test if
# a change in a PR has changed configure.ac # a change in a PR has changed configure.ac
if [[ $OS_NAME == "linux" ]]; then if [[ $OS_NAME == "linux" ]]; then
cd ${BUILD_DIRECTORY}/R-package ${BUILD_DIRECTORY}/R-package/recreate-configure.sh
autoconf \
--output configure \
configure.ac \
|| exit -1
cd ${BUILD_DIRECTORY}
num_files_changed=$( num_files_changed=$(
git diff --name-only | wc -l git diff --name-only | wc -l
......
Package: lightgbm Package: lightgbm
Type: Package Type: Package
Title: Light Gradient Boosting Machine Title: Light Gradient Boosting Machine
Version: 3.0.0-1 Version: ~~VERSION~~
Date: 2020-08-06 Date: ~~DATE~~
Authors@R: c( Authors@R: c(
person("Guolin", "Ke", email = "guolin.ke@microsoft.com", role = c("aut", "cre")), person("Guolin", "Ke", email = "guolin.ke@microsoft.com", role = c("aut", "cre")),
person("Damien", "Soukhavong", email = "damien.soukhavong@skema.edu", role = c("aut")), person("Damien", "Soukhavong", email = "damien.soukhavong@skema.edu", role = c("aut")),
......
...@@ -250,7 +250,7 @@ At build time, `configure` will be run and used to create a file `Makevars`, usi ...@@ -250,7 +250,7 @@ At build time, `configure` will be run and used to create a file `Makevars`, usi
./R-package/recreate-configure.sh ./R-package/recreate-configure.sh
``` ```
If you do not have easy access to an Ubuntu 18.04 environment, the `configure` script can be generated using Docker. If you do not have easy access to an Ubuntu 18.04 environment, the `configure` script can be generated using Docker by running the code below from the root of this repo.
```shell ```shell
docker run \ docker run \
......
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for lightgbm 3.0.0-1. # Generated by GNU Autoconf 2.69 for lightgbm 3.0.0.
# #
# #
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
...@@ -576,8 +576,8 @@ MAKEFLAGS= ...@@ -576,8 +576,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='lightgbm' PACKAGE_NAME='lightgbm'
PACKAGE_TARNAME='lightgbm' PACKAGE_TARNAME='lightgbm'
PACKAGE_VERSION='3.0.0-1' PACKAGE_VERSION='3.0.0'
PACKAGE_STRING='lightgbm 3.0.0-1' PACKAGE_STRING='lightgbm 3.0.0'
PACKAGE_BUGREPORT='' PACKAGE_BUGREPORT=''
PACKAGE_URL='' PACKAGE_URL=''
...@@ -1182,7 +1182,7 @@ if test "$ac_init_help" = "long"; then ...@@ -1182,7 +1182,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures lightgbm 3.0.0-1 to adapt to many kinds of systems. \`configure' configures lightgbm 3.0.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
...@@ -1244,7 +1244,7 @@ fi ...@@ -1244,7 +1244,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of lightgbm 3.0.0-1:";; short | recursive ) echo "Configuration of lightgbm 3.0.0:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
...@@ -1311,7 +1311,7 @@ fi ...@@ -1311,7 +1311,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
lightgbm configure 3.0.0-1 lightgbm configure 3.0.0
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
...@@ -1328,7 +1328,7 @@ cat >config.log <<_ACEOF ...@@ -1328,7 +1328,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by lightgbm $as_me 3.0.0-1, which was It was created by lightgbm $as_me 3.0.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
...@@ -2377,7 +2377,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ...@@ -2377,7 +2377,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by lightgbm $as_me 3.0.0-1, which was This file was extended by lightgbm $as_me 3.0.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
...@@ -2430,7 +2430,7 @@ _ACEOF ...@@ -2430,7 +2430,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
lightgbm config.status 3.0.0-1 lightgbm config.status 3.0.0
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# * https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Configure-and-cleanup # * https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Configure-and-cleanup
AC_PREREQ(2.69) AC_PREREQ(2.69)
AC_INIT([lightgbm], [3.0.0-1], [], [lightgbm], []) AC_INIT([lightgbm], [~~VERSION~~], [], [lightgbm], [])
########################### ###########################
# find compiler and flags # # find compiler and flags #
......
...@@ -4,6 +4,14 @@ ...@@ -4,6 +4,14 @@
# this script should run on Ubuntu 18.04 # this script should run on Ubuntu 18.04
AUTOCONF_VERSION=$(cat R-package/AUTOCONF_UBUNTU_VERSION) AUTOCONF_VERSION=$(cat R-package/AUTOCONF_UBUNTU_VERSION)
# R packages cannot have versions like 3.0.0rc1, but
# 3.0.0-1 is acceptable
LGB_VERSION=$(cat VERSION.txt | sed "s/rc/-/g")
# this script changes configure.ac. Copying to a temporary file
# so changes to configure.ac don't get committed in git
TMP_CONFIGURE_AC=".configure.ac"
echo "Creating 'configure' script with Autoconf ${AUTOCONF_VERSION}" echo "Creating 'configure' script with Autoconf ${AUTOCONF_VERSION}"
apt update apt update
...@@ -13,11 +21,17 @@ apt-get install \ ...@@ -13,11 +21,17 @@ apt-get install \
autoconf=${AUTOCONF_VERSION} autoconf=${AUTOCONF_VERSION}
cd R-package cd R-package
cp configure.ac ${TMP_CONFIGURE_AC}
sed -i.bak -e "s/~~VERSION~~/${LGB_VERSION}/" ${TMP_CONFIGURE_AC}
autoconf \ autoconf \
--output configure \ --output configure \
configure.ac \ ${TMP_CONFIGURE_AC} \
|| exit -1 || exit -1
rm ${TMP_CONFIGURE_AC}
rm -r autom4te.cache || echo "no autoconf cache found" rm -r autom4te.cache || echo "no autoconf cache found"
echo "done creating 'configure' script" echo "done creating 'configure' script"
...@@ -17,6 +17,12 @@ if test -d ${TEMP_R_DIR}; then ...@@ -17,6 +17,12 @@ if test -d ${TEMP_R_DIR}; then
fi fi
mkdir -p ${TEMP_R_DIR} mkdir -p ${TEMP_R_DIR}
CURRENT_DATE=$(date +'%Y-%m-%d')
# R packages cannot have versions like 3.0.0rc1, but
# 3.0.0-1 is acceptable
LGB_VERSION=$(cat VERSION.txt | sed "s/rc/-/g")
# move relevant files # move relevant files
cp -R R-package/* ${TEMP_R_DIR} cp -R R-package/* ${TEMP_R_DIR}
cp -R include ${TEMP_R_DIR}/src/ cp -R include ${TEMP_R_DIR}/src/
...@@ -38,6 +44,12 @@ cd ${TEMP_R_DIR} ...@@ -38,6 +44,12 @@ cd ${TEMP_R_DIR}
# for the R package # for the R package
rm src/main.cpp rm src/main.cpp
# configure.ac and DESCRIPTION have placeholders for version
# and date so they don't have to be updated manually
sed -i.bak -e "s/~~VERSION~~/${LGB_VERSION}/" configure.ac
sed -i.bak -e "s/~~VERSION~~/${LGB_VERSION}/" DESCRIPTION
sed -i.bak -e "s/~~DATE~~/${CURRENT_DATE}/" DESCRIPTION
# Remove 'region' and 'endregion' pragmas. This won't change # Remove 'region' and 'endregion' pragmas. This won't change
# the correctness of the code. CRAN does not allow you # the correctness of the code. CRAN does not allow you
# to use compiler flag '-Wno-unknown-pragmas' or # to use compiler flag '-Wno-unknown-pragmas' or
......
...@@ -155,6 +155,31 @@ result <- file.copy( ...@@ -155,6 +155,31 @@ result <- file.copy(
) )
.handle_result(result) .handle_result(result)
# R packages cannot have versions like 3.0.0rc1, but
# 3.0.0-1 is acceptable
LGB_VERSION <- readLines("VERSION.txt")[1L]
LGB_VERSION <- gsub(
pattern = "rc"
, replacement = "-"
, x = LGB_VERSION
)
# DESCRIPTION has placeholders for version
# and date so it doesn't have to be updated manually
DESCRIPTION_FILE <- file.path(TEMP_R_DIR, "DESCRIPTION")
description_contents <- readLines(DESCRIPTION_FILE)
description_contents <- gsub(
pattern = "~~VERSION~~"
, replacement = LGB_VERSION
, x = description_contents
)
description_contents <- gsub(
pattern = "~~DATE~~"
, replacement = as.character(Sys.Date())
, x = description_contents
)
writeLines(description_contents, DESCRIPTION_FILE)
# NOTE: --keep-empty-dirs is necessary to keep the deep paths expected # NOTE: --keep-empty-dirs is necessary to keep the deep paths expected
# by CMake while also meeting the CRAN req to create object files # by CMake while also meeting the CRAN req to create object files
# on demand # on demand
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment