Skip to content
/ dais Public

Tool for holding test run until Platform.sh environment is ready

Notifications You must be signed in to change notification settings

xendk/dais

Repository files navigation

Dais

Build Status Code Climate Code Climate Codecov

Dais holds back CirclCI/Github Actions builds on GitHub pull requests until Platform.sh has brought up the corresponding environment.

It is meant as a helper utility for running browser based tests on CircleCI/Github Actions against a Platform.sh environment.

Prerequisites

Platform.sh must be setup with GitHub integration and --build-pull-requests=true.

If using CircleCI, it must be set up to only build pull requests. Otherwise it will build as soon as a branch is pushed, before the pull request is created, and thus the build environment doesn't get the pull request variables needed to find the corresponding Platform.sh environment.

If using Github Actions, the workflow should trigger on pull_request.

Some tests to run. The framework used is not important, as long as it has a configuration file with the URL to use.

Usage

Set up the DAIS_PLATFORMSH_KEY and DAIS_PLATFORMSH_ID env variables on in CI.

Add the phar file to the commands run on CI and give it the configuration file of the test framework as argument. The file should have a %site-url% placeholder that will be replaced with the URL of the Platform.sh environment, with any trailing slashes stripped.

If your Platform.sh project uses Routes you can refer to route URLs using the pattern %route-url:[route-index]%. %route-url:1% is the URL to the first route etc.

Working .circleci/config.yml:

version: 2

jobs:
  build:
    docker:
      - image: notnoopci/php:7.1.5-browsers
    working_directory: ~/build
    steps:
      - checkout
      # Set a timezone to avoid PHP notices/errors in date functions.
      - run: |
          echo "date.timezone = UTC" | sudo tee /usr/local/etc/php/conf.d/date.ini
          composer install
          wget https://github.com/xendk/dais/releases/download/0.9.0/dais-0.9.0.phar
          php dais-0.9.0.phar --sha $CIRCLE_SHA1 --pr-number $CI_PULL_REQUEST behat.yml
          ./vendor/bin/behat --format=junit --out=/tmp/test-reports/behat --format=pretty --out=std
      - store_test_results:
          path: /tmp/test-reports/

The equivalent command for Github Actions:

php dais-0.9.0.phar --sha ${{github.event.pull_request.head.sha}} --pr-number ${{github.event.pull_request.number}} behat.yml

About

Tool for holding test run until Platform.sh environment is ready

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages