Trellis and Continuous Integration via Travis-CI Composer Private Repositories and ACF

So I started with a super minimal .travis.yml configuration file:

sudo: false
language: php
php:
  - '7.1'

How could that fail, right? Not. Travis needs something to do, so it defaults to running phpunit and if you run phpunit without any tests in place you get an error. So there needs to be some kind of script.

Potentially the entire script could be:

script:
    - cd $TRAVIS_BUILD_DIR

Which would override the default phpunit call.

We’re also including some private repositories as composer dependencies. In order to do that you need to configure the github auth token which I found a tutorial on.

Advanced Custom Fields Pro is installed via the PhilippBaschke acf-pro-installer, which requires including a travis encrypted environment variable.

There’s a bug with yarn run build:production so for now I just removed it. Here’s the yaml file:

language: php
sudo: false
dist: trusty
php:
  - 7.1
  - nightly

matrix:
    - fast_finish: true
    - allow_failures:
      - php: nightly

install:
  - git clone --depth=0 https://github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_REPO_SLUG
  - cd $TRAVIS_REPO_SLUG
  - git checkout -qf $TRAVIS_COMMIT

env:
  global:
    - THEME_DIR=./site/web/app/themes/intensity-club-theme/
    - SITE_DIR=./site/
    - TRAVIS_NODE_VERSION="9"
  matrix:
    - secure: sgwIUeoGJoPSVzVCpwjdS0bqc9zMJGbfSFQk+JZOguX8sJe7JQgyE3KQ2j9zi0njQhdzU0ilJGyXQA4Hqk7xVWtJWJp2NDeGSFJG7yY4DJB/1k1tq2+cLLBiQC6X41MjnABcee9J+SVuM6aD4nqp2F22UKAnZsqHpBR90+bpoxjg0nSNyXkLkdWR7KB1wstrt+2un4epcJxJ6+4kUJGKnxIa+rbK9g3zA4RTub7JPvqOo45gO7yPGbJdgAVSJAY2gyufhcs3hLz8uQW5bFAW1wD/kwldoqUJXRmCtWuAIbazsK036rgff2BI0qlXI7i5BPiV8cBR3btLSDPkbaSUszmdxwGCraku6XYGHaTPm/4aJoO6DGipBL8SEQaudwDry6c/lY0QVgcfQHVueaXM2wnSzCYJPViQWdW9JopCn8SZOOI1lFF/5fF3vrV9yMhgZZDt4UXYcoQprKdSR1mgRdEcgwWrMSDCbR9Gy0zFtTLIeuoMLZhsfCJXJG4zqTzL9+JoNJugs2HCFRVKg1nOCKd25daK/7AyxcKiCktuDFq7LsgtQYozWQj9GNLbGw3jwbmQ/X/dypcDwTHXhL/I3Mq3mK6ulKJpbzsDoUr/yStbQGq2gfCAYioE3okGfGweAOzzRIjAUdSsv4rBRvOYzOSuGCEvz0lNOE1kJ/Dg5Nc=

cache:
  apt: true
  directories:
    - $SITE_DIR/.composer/cache
    - $THEME_DIR/.yarn-cache
    - vendor

before_install:
  - composer self-update
  - source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION && nvm use $TRAVIS_NODE_VERSION
  - export PATH=$HOME/.yarn/bin:$PATH && travis_retry curl -o- -L https://yarnpkg.com/install.sh | bash


install:
  - cd $SITE_DIR
  - composer config github-oauth.github.com ${GITHUB_TOKEN}
  - composer validate --no-check-all --ansi
  - composer install --no-dev --no-scripts --quiet --optimize-autoloader
  - cd $TRAVIS_BUILD_DIR
  - cd $THEME_DIR
  - node -v && yarn -V
  - travis_retry yarn

script:
  - yarn run test
  - yarn run build
  - yarn run rmdist


Leave a Reply

Your email address will not be published. Required fields are marked *