#5031 CI: install new deps after merging the PR under test
Opened 2 years ago by abompard. Modified 2 years ago
abompard/pagure ci-deps  into  master

@@ -32,31 +32,10 @@ 

  #    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 []

dev/containers/checkout-and-run.sh dev/containers/runtests_py3.sh
file renamed
+6 -1
@@ -1,5 +1,6 @@ 

  #!/bin/bash

  

+ set -e

  

  ls -l /

  
@@ -7,6 +8,8 @@ 

  /usr/bin/env

  echo "============== END ENVIRONMENT ============="

  

+ set -x

+ 

  if [ -n "$REPO" -a -n "$BRANCH" ]; then

  git remote rm proposed || true

  git gc --auto
@@ -20,6 +23,8 @@ 

  echo "Running tests for branch $BRANCH of repo $REPO"

  echo "Last commits:"

  git --no-pager log -2

+ 

  fi

  

- pytest-3 -n auto ${TESTCASE:-tests/}

+ # Run the tests

+ dev/containers/runtests.sh

@@ -21,20 +21,9 @@ 

      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 []

@@ -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

I've commented this out because I don't think building the binary is necessary to run the tests. If I'm wrong on that I'll uncomment it.

+     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

@@ -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/}

This PR reorganises the way tests are run in CI to checkout the correct git branch as early as possible, before dependencies are parsed and installed.
This way if a PR introduces new dependencies, they will be installed in CI and not cause a failure.

I've commented this out because I don't think building the binary is necessary to run the tests. If I'm wrong on that I'll uncomment it.

rebased onto 8968cf6

2 years ago

pretty please pagure-ci rebuild

2 years ago