Giter Site home page Giter Site logo

drainpipe's Introduction

Drainpipe

Drainpipe is a composer package which provides a number of build tool helpers for a Drupal site, including:

  • Site and database updates
  • Artifact packaging for deployment to a hosting provider
  • Automated testing setup with support for PHPUnit and Nightwatch tests

Installation

composer require lullabot/drainpipe
# Includes development dependencies, but only in the `require-dev` section. This step is required for Drainpipe to provide test helpers.
composer require lullabot/drainpipe-dev --dev
# To compile Sass and Javascript via their respective tasks, add these node packages.
PACKAGES="
@lullabot/drainpipe-sass
@lullabot/drainpipe-javascript
"
if [ -f yarn.lock ]; then
  yarn add $PACKAGES
else
  npm install $PACKAGES
fi

Drainpipe integrates with DDEV, but will only add the relevant files when DDEV is detected in the repository. Either set DDEV up first before requiring this project, or run composer update if DDEV is added later.

composer create-project drupal/recommended-project drupal
cd drupal
ddev config
ddev start
ddev composer require lullabot/drainpipe
ddev composer require lullabot/drainpipe-dev --dev
# Restart is required to enable the provided Selenium containers
ddev restart

Usage

Build tasks are provided as Taskfiles. A full list of available tasks can be shown by running ./vendor/bin/task --list (or ddev task --list if you're using DDEV).

Running Tests

See https://github.com/Lullabot/drainpipe-dev

Defining Browser compatibility

The best way to specify the browsers to target in the project is a .browserslistrc file in the project root. See https://github.com/postcss/autoprefixer for more info.

CSS & JS asset automation

Drainpipe provides tasks to automate Sass & JavaScript compilation.

To enable this, first define the project variables DRAINPIPE_SASS and/or DRAINPIPE_JAVASCRIPT in Taskfile.yml.

Then define the task:

assets:
  desc: Builds assets such as CSS & JS
  cmds:
    - if [ -f "yarn.lock" ]; then yarn; else npm install; fi
    - task: javascript:compile
    - task: sass:compile
assets:watch:
  desc: Builds assets such as CSS & JS, and watches them for changes
  deps: [sass:watch, javascript:watch]

You can then run the following tasks:

  • ddev task assets Default task to compile the CSS and JS once for production.
  • ddev task assets:watch Task to watch and build the changes while working on the theme.

CSS

The task provided to compile CSS assets uses Sass.

It includes SASS Glob to use glob imports to define a whole directory:

// Base
@use "sass/base/**/*";

Validation

Your Taskfile.yml can be validated with JSON Schema:

curl -O https://json.schemastore.org/taskfile.json
npx ajv-cli validate -s taskfile.json -d Taskfile.yml

See .github/workflows/validate-taskfile.yml for an example of this in use.

GitLab Integration

Add the following to composer.json for GitLab helpers:

"extra": {
  "drainpipe": {
    "gitlab": []
  }
}

This will import scaffold/gitlab/Common.gitlab-ci.yml, which provides helpers that can be used in GitLab CI with includes and references.

Pantheon

"extra": {
    "drainpipe": {
        "gitlab": ["Pantheon", "Pantheon Review Apps"]
    }
}

This will setup Merge Request deployment to Pantheon Multidev environments. See [scaffold/gitlab/gitlab-ci.example.yml] for an example. You can also just include which will give you helpers that you can include and reference for tasks such as setting up Terminus. See scaffold/gitlab/Pantheon.gitlab-ci.yml.

Composer Lock Diff

"extra": {
    "drainpipe": {
        "gitlab": ["ComposerLockDiff"]
    }
}

Updates Merge Request descriptions with a markdown table of any changes detected in composer.lock using composer-lock-diff. Requires GITLAB_ACCESS_TOKEN variable to be set, which is an access token with api scope.

GitHub Actions Integration

Pantheon

  • Add the following the composer.json to enable deployment of Pantheon Review Apps
    "extra": {
        "drainpipe": {
            "github": ["PantheonReviewApps"]
        }
    }
  • Run composer install
  • Add your Pantheon site-name and site-id to the last job in the new workflow file at .github/workflows/PantheonReviewApps.yml
  • Add the following secrets to your repository:

drainpipe's People

Contributors

justafish avatar deviantintegral avatar hawkeyetwolf avatar geekygnr avatar ckrina avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.