From 8968cf679f391b4ce781b917c3ae038d4fcb3958 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Nov 18 2020 14:03:53 +0000 Subject: CI: install new deps after merging the PR under test Signed-off-by: Aurélien Bompard --- diff --git a/dev/containers/centos7-rpms-py2 b/dev/containers/centos7-rpms-py2 index e5377b9..05d4ca5 100644 --- a/dev/containers/centos7-rpms-py2 +++ b/dev/containers/centos7-rpms-py2 @@ -32,31 +32,10 @@ RUN yum -y install \ # repoSpanner-bridge RUN cd / \ - && GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone -b $BRANCH $REPO \ - && chmod +x /pagure/dev/containers/runtests_py2.sh - -# Install all the requirements from the spec file and replace the macro -# %{python_pkgversion} by empty string which thus installs all the py2 -# version of the dependencies. -RUN cd /pagure && \ - yum install --enablerepo=epel-testing -y \ - `rpmspec -q --requires /pagure/files/pagure.spec | \ - sed -e "s|%{python_pkgversion}||"` && \ - yum clean all && \ - localedef -i en_US -f UTF-8 en_US.UTF-8 - -# The old version of setuptools in CentOS7 does not support restrictions on -# the requirements file, so drop them -RUN \ - sed -i -e "s|;python_version<\"3.4\"||" /pagure/requirements.txt && \ - sed -i -e "s|;python_version<=\"2.7\"||" /pagure/requirements.txt && \ - sed -i -e "s|python3-openid;python_version>=\"3.0\"||" \ - /pagure/requirements.txt && \ - sed -i "/^email_validator.*/d" /pagure/requirements.txt && \ - sed -i -e 's|"alembic-3"|"alembic"|' /pagure/tests/test_alembic.py && \ - cd /pagure && python setup.py build + && GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone -b $BRANCH $REPO +RUN localedef -i en_US -f UTF-8 en_US.UTF-8 WORKDIR /pagure -ENTRYPOINT ["/pagure/dev/containers/runtests_py2.sh"] +ENTRYPOINT ["/pagure/dev/containers/checkout-and-run.sh"] CMD [] diff --git a/dev/containers/checkout-and-run.sh b/dev/containers/checkout-and-run.sh new file mode 100755 index 0000000..74ac7c2 --- /dev/null +++ b/dev/containers/checkout-and-run.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -e + +ls -l / + +echo "============== ENVIRONMENT =============" +/usr/bin/env +echo "============== END ENVIRONMENT =============" + +set -x + +if [ -n "$REPO" -a -n "$BRANCH" ]; then +git remote rm proposed || true +git gc --auto +git remote add proposed "$REPO" +GIT_TRACE=1 GIT_CURL_VERBOSE=1 git fetch proposed +git checkout origin/master +git config --global user.email "you@example.com" +git config --global user.name "Your Name" +git merge --no-ff "proposed/$BRANCH" -m "Merge PR" + +echo "Running tests for branch $BRANCH of repo $REPO" +echo "Last commits:" +git --no-pager log -2 + +fi + +# Run the tests +dev/containers/runtests.sh diff --git a/dev/containers/fedora-rpms-py3 b/dev/containers/fedora-rpms-py3 index a3fe0d3..6927744 100644 --- a/dev/containers/fedora-rpms-py3 +++ b/dev/containers/fedora-rpms-py3 @@ -21,20 +21,9 @@ RUN dnf -y --enablerepo=updates-testing install \ git RUN cd / \ - && GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone -b $BRANCH $REPO \ - && chmod +x /pagure/dev/containers/runtests_py3.sh + && GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone -b $BRANCH $REPO -# Install all the requirements from the spec file and replace the macro -# %{python_pkgversion} by '3' which thus installs all the py3 version of -# the dependencies. -RUN sed -i "/Requires: python%{python_pkgversion}-enum34/d" /pagure/files/pagure.spec && \ - dnf install -y --enablerepo=updates-testing `grep "Requires:" /pagure/files/pagure.spec | \ - awk '{split($0, a, " "); print a[2]}' |grep -v "%{name}" | \ - sed -e "s|%{python_pkgversion}|3|"` && \ - dnf clean all && \ - cd /pagure && \ - python3 setup.py build WORKDIR /pagure -ENTRYPOINT ["/pagure/dev/containers/runtests_py3.sh"] +ENTRYPOINT ["/pagure/dev/containers/checkout-and-run.sh"] CMD [] diff --git a/dev/containers/runtests.sh b/dev/containers/runtests.sh new file mode 100755 index 0000000..f1e58d2 --- /dev/null +++ b/dev/containers/runtests.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +SPECFILE=files/pagure.spec + +export LANG="en_US.UTF-8" +. /etc/os-release + + +# +# Dependenties detection +# + +# Fedora: replace the macro %{python_pkgversion} by '3' which thus installs all +# the py3 version of the dependencies. +deps_fedora() { + grep "Requires:" ${SPECFILE} | \ + awk '{split($0, a, " "); print a[2]}' | grep -v "%{name}" | \ + sed -e "s|%{python_pkgversion}|3|" | \ + grep -v python3-enum34 +} + +# CentOS7: replace the macro %{python_pkgversion} by empty string which thus +# installs all the py2 version of the dependencies. +deps_centos7() { + grep "Requires:" ${SPECFILE} | \ + awk '{split($0, a, " "); print a[2]}' | grep -v "%{name}" | \ + sed -e "s|%{python_pkgversion}||" +} + + +# CentOS7: the old version of setuptools does not support restrictions on +# the requirements file, so drop them +remove_req_restrictions() { + sed -i -e "s|;python_version<\"3.4\"||" requirements.txt + sed -i -e "s|;python_version<=\"2.7\"||" requirements.txt + sed -i -e "s|python3-openid;python_version>=\"3.0\"||" requirements.txt + sed -i "/^email_validator.*/d" requirements.txt + sed -i -e 's|"alembic-3"|"alembic"|' tests/test_alembic.py +} + +# +# Install the dependencies and run the tests +# + +set -x + +if [ "$ID" == "centos" -a "$VERSION_ID" == "7" ]; then + yum install -y --enablerepo=epel-testing $(deps_centos7) + yum clean all + #remove_req_restrictions + #python setup.py build + py.test -n auto ${TESTCASE:-tests/} +else + dnf install -y --enablerepo=updates-testing $(deps_fedora) + dnf clean all + #python setup.py build + pytest-3 -n auto ${TESTCASE:-tests/} +fi diff --git a/dev/containers/runtests_py2.sh b/dev/containers/runtests_py2.sh deleted file mode 100644 index 850cb38..0000000 --- a/dev/containers/runtests_py2.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - - -ls -l / - -echo "============== ENVIRONMENT =============" -/usr/bin/env -echo "============== END ENVIRONMENT =============" - -if [ -n "$REPO" -a -n "$BRANCH" ]; then -git remote rm proposed || true -git gc --auto -git remote add proposed "$REPO" -GIT_TRACE=1 GIT_CURL_VERBOSE=1 git fetch proposed -git checkout origin/master -git config --global user.email "you@example.com" -git config --global user.name "Your Name" -git merge --no-ff "proposed/$BRANCH" -m "Merge PR" - -echo "Running tests for branch $BRANCH of repo $REPO" -echo "Last commits:" -git --no-pager log -2 -fi - -export LANG="en_US.UTF-8" -py.test -n auto ${TESTCASE:-tests/} diff --git a/dev/containers/runtests_py3.sh b/dev/containers/runtests_py3.sh deleted file mode 100644 index e1fa1aa..0000000 --- a/dev/containers/runtests_py3.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - - -ls -l / - -echo "============== ENVIRONMENT =============" -/usr/bin/env -echo "============== END ENVIRONMENT =============" - -if [ -n "$REPO" -a -n "$BRANCH" ]; then -git remote rm proposed || true -git gc --auto -git remote add proposed "$REPO" -GIT_TRACE=1 GIT_CURL_VERBOSE=1 git fetch proposed -git checkout origin/master -git config --global user.email "you@example.com" -git config --global user.name "Your Name" -git merge --no-ff "proposed/$BRANCH" -m "Merge PR" - -echo "Running tests for branch $BRANCH of repo $REPO" -echo "Last commits:" -git --no-pager log -2 -fi - -pytest-3 -n auto ${TESTCASE:-tests/}