 [ ← blog / drupal ](/) Apr 19, 2021  ·  \#drupal  ·  2 min read 

# GitHub Action for setting up Drupal for testing



I have written my first GitHub Action – [bluehorndigital/setup-drupal](https://github.com/marketplace/actions/setup-drupal-action). In my phpstan-drupal and drupal-check projects I have various GitHub Actions workflows that build a Drupal project via Composer.

 [Setup Drupal action - GitHub Marketplace

GitHub Action to setup Drupal for testing an extension

https://github.com/marketplace/actions/setup-drupal-action

 

 ![Setup Drupal action - GitHub Marketplace](https://avatars.githubusercontent.com/u/11205265?s=400&v=4) 

 

 

 ](https://github.com/marketplace/actions/setup-drupal-action) 

There are actually a few quirks with changes in Drupal 9, so I made an action to simplify setting up a Drupal project.

As of 9.1.0, the `<a href="https://packagist.org/packages/drupal/recommended-project">drupal/recommended-project</a>` template [now specifies a minimum stability of "stable](https://www.drupal.org/node/3174472)". Why does this matter? With this setting the following versions would not be installable:

- `^1.0@rc`
- `^1.0@beta`
- `^1.0@alpha`
- `1.0.x-dev`

So, if you are testing a package in your GitHub Action workflow – it will be rejected! It is a development release, technically.

There is another quirk, as well. If you use `<a href="https://packagist.org/packages/drupal/core-dev">drupal/core-dev</a>` vs `<a href="https://packagist.org/packages/drupal/core-dev-pinned">drupal/core-dev-pinned</a>` to install development dependencies (ie: PHPUnit) you will get PHPUnit 9. This requires the `<a href="https://packagist.org/packages/phpspec/prophecy-phpunit">phpspec/prophecy-phpunit</a>` package or else you will receive a fatal error. It is documented in a [change record](https://www.drupal.org/node/3176567), but it wasn't easily searchable when I first encountered it.

The setup-drupal action checks if you are installing Drupal 9 and includes this dependency for you.

I just updated phpstan-drupal to use this action: <https://github.com/mglaman/phpstan-drupal/pull/171>

I plan to provide an example of testing a Drupal module via Github Actions with this module with the CiviCRM Webform or CiviCRM Entity modules.

 

  ![](/themes/custom/mglaman/images/headshot.webp)Thanks for reading

I write about Drupal, PHP, and the quiet infrastructure behind large sites — caching, config, and testing. New posts land every week or two.

 [Subscribe via RSS →](/rss.xml) [About me →](/about-me) 

 



 

  [← Older

Watch: Nightwatch testing training to help get Olivero stable for Drupal 9.2!

 ](/blog/watch-nightwatch-testing-training-help-get-olivero-stable-drupal-92) [Newer →

Migrating to TailwindCSS, iteratively, in your Drupal theme

 ](/blog/migrating-tailwindcss-iteratively-your-drupal-theme)