diff mbox series

ci: dont use hardcoded project name

Message ID 20200611140557.6359-1-william.c.roberts@intel.com (mailing list archive)
State Superseded
Headers show
Series ci: dont use hardcoded project name | expand

Commit Message

William Roberts June 11, 2020, 2:05 p.m. UTC
From: William Roberts <william.c.roberts@intel.com>

Not everyone's github project is "selinux" so use the projects
name, as derived from TRAVIS_BUILD_DIR. TRAVIS_BUILD_DIR is
the absolute path to the project checkout on disk, so the
basename should be sufficient.

Tested on Travis CI here:
  - https://travis-ci.org/github/williamcroberts/selinux/jobs/697201376

Signed-off-by: William Roberts <william.c.roberts@intel.com>
---
 scripts/ci/travis-kvm-setup.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Petr Lautrbach June 11, 2020, 3:34 p.m. UTC | #1
On Thu, Jun 11, 2020 at 09:05:57AM -0500, bill.c.roberts@gmail.com wrote:
> From: William Roberts <william.c.roberts@intel.com>
> 
> Not everyone's github project is "selinux" so use the projects
> name, as derived from TRAVIS_BUILD_DIR. TRAVIS_BUILD_DIR is
> the absolute path to the project checkout on disk, so the
> basename should be sufficient.
> 
> Tested on Travis CI here:
>   - https://travis-ci.org/github/williamcroberts/selinux/jobs/697201376
> 
> Signed-off-by: William Roberts <william.c.roberts@intel.com>
> ---
>  scripts/ci/travis-kvm-setup.sh | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/ci/travis-kvm-setup.sh b/scripts/ci/travis-kvm-setup.sh
> index 864dbac96a46..ceedaa6f4e27 100755
> --- a/scripts/ci/travis-kvm-setup.sh
> +++ b/scripts/ci/travis-kvm-setup.sh
> @@ -120,6 +120,7 @@ fi
>  # we don't get blocked on asking to add the servers key to
>  # our known_hosts.
>  #
> -ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/selinux/$TEST_RUNNER"
> +project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> +ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/$project_dir/$TEST_RUNNER"
>  
>  exit 0
> -- 
> 2.17.1
> 

Thanks!

I'm running a new job again with this fix. But I guess you need to change
fedora-test-runner.sh as well. There's also hardcoded "selinux": 

~~~
# Move to selinux code and build
#
cd "$HOME/selinux"
~~~
Petr Lautrbach June 11, 2020, 3:55 p.m. UTC | #2
On Thu, Jun 11, 2020 at 05:34:34PM +0200, Petr Lautrbach wrote:
> On Thu, Jun 11, 2020 at 09:05:57AM -0500, bill.c.roberts@gmail.com wrote:
> > From: William Roberts <william.c.roberts@intel.com>
> > 
> > Not everyone's github project is "selinux" so use the projects
> > name, as derived from TRAVIS_BUILD_DIR. TRAVIS_BUILD_DIR is
> > the absolute path to the project checkout on disk, so the
> > basename should be sufficient.
> > 
> > Tested on Travis CI here:
> >   - https://travis-ci.org/github/williamcroberts/selinux/jobs/697201376
> > 
> > Signed-off-by: William Roberts <william.c.roberts@intel.com>
> > ---
> >  scripts/ci/travis-kvm-setup.sh | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/scripts/ci/travis-kvm-setup.sh b/scripts/ci/travis-kvm-setup.sh
> > index 864dbac96a46..ceedaa6f4e27 100755
> > --- a/scripts/ci/travis-kvm-setup.sh
> > +++ b/scripts/ci/travis-kvm-setup.sh
> > @@ -120,6 +120,7 @@ fi
> >  # we don't get blocked on asking to add the servers key to
> >  # our known_hosts.
> >  #
> > -ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/selinux/$TEST_RUNNER"
> > +project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> > +ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/$project_dir/$TEST_RUNNER"
> >  
> >  exit 0
> > -- 
> > 2.17.1
> > 
> 
> Thanks!
> 
> I'm running a new job again with this fix. But I guess you need to change
> fedora-test-runner.sh as well. There's also hardcoded "selinux": 
> 
> ~~~
> # Move to selinux code and build
> #
> cd "$HOME/selinux"
> ~~~
> 

https://travis-ci.org/github/bachradsusi/SELinuxProject-selinux/jobs/697271776

~~~
# Move to selinux code and build
#
cd "$HOME/selinux"
/root/SELinuxProject-selinux/scripts/ci/fedora-test-runner.sh: line 61: cd: /root/selinux: No such file or directory
The command "scripts/ci/travis-kvm-setup.sh" exited with 1.

Done. Your build exited with 1.
~~~
William Roberts June 11, 2020, 4:19 p.m. UTC | #3
On Thu, Jun 11, 2020 at 10:55 AM Petr Lautrbach <plautrba@redhat.com> wrote:
>
> On Thu, Jun 11, 2020 at 05:34:34PM +0200, Petr Lautrbach wrote:
> > On Thu, Jun 11, 2020 at 09:05:57AM -0500, bill.c.roberts@gmail.com wrote:
> > > From: William Roberts <william.c.roberts@intel.com>
> > >
> > > Not everyone's github project is "selinux" so use the projects
> > > name, as derived from TRAVIS_BUILD_DIR. TRAVIS_BUILD_DIR is
> > > the absolute path to the project checkout on disk, so the
> > > basename should be sufficient.
> > >
> > > Tested on Travis CI here:
> > >   - https://travis-ci.org/github/williamcroberts/selinux/jobs/697201376
> > >
> > > Signed-off-by: William Roberts <william.c.roberts@intel.com>
> > > ---
> > >  scripts/ci/travis-kvm-setup.sh | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/scripts/ci/travis-kvm-setup.sh b/scripts/ci/travis-kvm-setup.sh
> > > index 864dbac96a46..ceedaa6f4e27 100755
> > > --- a/scripts/ci/travis-kvm-setup.sh
> > > +++ b/scripts/ci/travis-kvm-setup.sh
> > > @@ -120,6 +120,7 @@ fi
> > >  # we don't get blocked on asking to add the servers key to
> > >  # our known_hosts.
> > >  #
> > > -ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/selinux/$TEST_RUNNER"
> > > +project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> > > +ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/$project_dir/$TEST_RUNNER"
> > >
> > >  exit 0
> > > --
> > > 2.17.1
> > >
> >
> > Thanks!
> >
> > I'm running a new job again with this fix. But I guess you need to change
> > fedora-test-runner.sh as well. There's also hardcoded "selinux":
> >
> > ~~~
> > # Move to selinux code and build
> > #
> > cd "$HOME/selinux"
> > ~~~
> >
>
> https://travis-ci.org/github/bachradsusi/SELinuxProject-selinux/jobs/697271776
>
> ~~~
> # Move to selinux code and build
> #
> cd "$HOME/selinux"
> /root/SELinuxProject-selinux/scripts/ci/fedora-test-runner.sh: line 61: cd: /root/selinux: No such file or directory
> The command "scripts/ci/travis-kvm-setup.sh" exited with 1.
>
> Done. Your build exited with 1.
> ~~~

You can add this diff for now, ill post a v2 patch after I confirm
travis still runs.

diff --git a/scripts/ci/fedora-test-runner.sh b/scripts/ci/fedora-test-runner.sh
index 0927ed5dad8f..067d7bd65906 100755
--- a/scripts/ci/fedora-test-runner.sh
+++ b/scripts/ci/fedora-test-runner.sh
@@ -58,7 +58,8 @@ dnf install -y \
 #
 # Move to selinux code and build
 #
-cd "$HOME/selinux"
+project_dir="$(basename "$TRAVIS_BUILD_DIR")"
+cd "$HOME/$project_dir"

 # Show HEAD commit for sanity checking
 git log -1
@@ -71,7 +72,7 @@ make -j"$(nproc)" LIBDIR=/usr/lib64 SHLIBDIR=/lib64
install-pywrap
 make -j"$(nproc)" LIBDIR=/usr/lib64 SHLIBDIR=/lib64 relabel

 #
-# Get the selinux testsuite, but don't clone it in $HOME/selinux, move to $HOME
+# Get the selinux testsuite, but don't clone it in
$HOME/$project_dir, move to $HOME
 # first.
 #
 cd "$HOME"
William Roberts June 11, 2020, 4:44 p.m. UTC | #4
On Thu, Jun 11, 2020 at 11:19 AM William Roberts
<bill.c.roberts@gmail.com> wrote:
>
> On Thu, Jun 11, 2020 at 10:55 AM Petr Lautrbach <plautrba@redhat.com> wrote:
> >
> > On Thu, Jun 11, 2020 at 05:34:34PM +0200, Petr Lautrbach wrote:
> > > On Thu, Jun 11, 2020 at 09:05:57AM -0500, bill.c.roberts@gmail.com wrote:
> > > > From: William Roberts <william.c.roberts@intel.com>
> > > >
> > > > Not everyone's github project is "selinux" so use the projects
> > > > name, as derived from TRAVIS_BUILD_DIR. TRAVIS_BUILD_DIR is
> > > > the absolute path to the project checkout on disk, so the
> > > > basename should be sufficient.
> > > >
> > > > Tested on Travis CI here:
> > > >   - https://travis-ci.org/github/williamcroberts/selinux/jobs/697201376
> > > >
> > > > Signed-off-by: William Roberts <william.c.roberts@intel.com>
> > > > ---
> > > >  scripts/ci/travis-kvm-setup.sh | 3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/scripts/ci/travis-kvm-setup.sh b/scripts/ci/travis-kvm-setup.sh
> > > > index 864dbac96a46..ceedaa6f4e27 100755
> > > > --- a/scripts/ci/travis-kvm-setup.sh
> > > > +++ b/scripts/ci/travis-kvm-setup.sh
> > > > @@ -120,6 +120,7 @@ fi
> > > >  # we don't get blocked on asking to add the servers key to
> > > >  # our known_hosts.
> > > >  #
> > > > -ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/selinux/$TEST_RUNNER"
> > > > +project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> > > > +ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/$project_dir/$TEST_RUNNER"
> > > >
> > > >  exit 0
> > > > --
> > > > 2.17.1
> > > >
> > >
> > > Thanks!
> > >
> > > I'm running a new job again with this fix. But I guess you need to change
> > > fedora-test-runner.sh as well. There's also hardcoded "selinux":
> > >
> > > ~~~
> > > # Move to selinux code and build
> > > #
> > > cd "$HOME/selinux"
> > > ~~~
> > >
> >
> > https://travis-ci.org/github/bachradsusi/SELinuxProject-selinux/jobs/697271776
> >
> > ~~~
> > # Move to selinux code and build
> > #
> > cd "$HOME/selinux"
> > /root/SELinuxProject-selinux/scripts/ci/fedora-test-runner.sh: line 61: cd: /root/selinux: No such file or directory
> > The command "scripts/ci/travis-kvm-setup.sh" exited with 1.
> >
> > Done. Your build exited with 1.
> > ~~~
>
> You can add this diff for now, ill post a v2 patch after I confirm
> travis still runs.
>
> diff --git a/scripts/ci/fedora-test-runner.sh b/scripts/ci/fedora-test-runner.sh
> index 0927ed5dad8f..067d7bd65906 100755
> --- a/scripts/ci/fedora-test-runner.sh
> +++ b/scripts/ci/fedora-test-runner.sh
> @@ -58,7 +58,8 @@ dnf install -y \
>  #
>  # Move to selinux code and build
>  #
> -cd "$HOME/selinux"
> +project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> +cd "$HOME/$project_dir"
>
>  # Show HEAD commit for sanity checking
>  git log -1
> @@ -71,7 +72,7 @@ make -j"$(nproc)" LIBDIR=/usr/lib64 SHLIBDIR=/lib64
> install-pywrap
>  make -j"$(nproc)" LIBDIR=/usr/lib64 SHLIBDIR=/lib64 relabel
>
>  #
> -# Get the selinux testsuite, but don't clone it in $HOME/selinux, move to $HOME
> +# Get the selinux testsuite, but don't clone it in
> $HOME/$project_dir, move to $HOME
>  # first.
>  #
>  cd "$HOME"

Oh darn that won't work, as the travis env variables are not
propagated into the environment... let me
see if I can do that.
diff mbox series

Patch

diff --git a/scripts/ci/travis-kvm-setup.sh b/scripts/ci/travis-kvm-setup.sh
index 864dbac96a46..ceedaa6f4e27 100755
--- a/scripts/ci/travis-kvm-setup.sh
+++ b/scripts/ci/travis-kvm-setup.sh
@@ -120,6 +120,7 @@  fi
 # we don't get blocked on asking to add the servers key to
 # our known_hosts.
 #
-ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/selinux/$TEST_RUNNER"
+project_dir="$(basename "$TRAVIS_BUILD_DIR")"
+ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" "/root/$project_dir/$TEST_RUNNER"
 
 exit 0