ataylorme / Advanced-WordPress-on-Pantheon

MIT License
65 stars 32 forks source link

terminus auth:whoami does not return a non-zero exit code #33

Closed tobeycodes closed 7 years ago

tobeycodes commented 7 years ago

This last command exit code condition will never pass

https://github.com/ataylorme/Advanced-WordPress-on-Pantheon/blob/master/bin/behat-cleanup.sh#L12

tobeycodes commented 7 years ago

Suggested fix

    USER_ID=$(terminus auth:whoami --field=id 2>&1)
    if [[ ! $USER_ID =~ ^[A-Za-z0-9-]+$ ]]; then
        echo "Terminus unauthenticated; assuming unauthenticated build"
        exit 0
    fi
tobeycodes commented 7 years ago

I think long term we could create a teminus_helper.sh. It can be sourced by any file we need it so we can be all DRY 👍

ataylorme commented 7 years ago

Better yet we can login during dependencies: pre: in circle.yml instead of sourcing a function in other scripts.

See https://github.com/ataylorme/Advanced-WordPress-on-Pantheon/pull/36/files#diff-29944324a3cbf9f4bd0162dfe3975d88R89

tobeycodes commented 7 years ago

Awesome! :)

I also moved installing terminus to here without the .sh file for 2.0. Will look at a PR for all this bigger stuff when I have a bit of time to tidy it up


version: 2
jobs:
  build:
    docker:
      - image: php:7.0-apache
        environment:
          PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:~/.composer/vendor/bin
    working_directory: /var/www/html
    steps:
      - run:
          name: Updating and installing packages
          command: apt-get update && apt-get -y install git unzip jq
      - run:
          name: Install Composer
          command: |
            php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
            php -r "copy('https://composer.github.io/installer.sig', 'composer-setup.sig');" && \
            php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('composer-setup.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
            php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
            php -r "unlink('composer-setup.php');" && \
            php -r "unlink('composer-setup.sig');"
      - run:
          name: Install Terminus
          command: composer global require pantheon-systems/terminus:1.3.0
      - checkout
      - run:
          name: Running Build
          command: ./bin/build
      - deploy:
          name: Running Deploy
          command: ./bin/deploy```