Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple Laravel testing workflow for GitHub Actions
name: Tests (PHP)
on: [push]
jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
- name: Run composer install
run: composer install -n --prefer-dist
env:
APP_ENV: testing
- name: Prepare Laravel Application
run: |
cp .env.example .env
php artisan key:generate
- name: Cache yarn dependencies
uses: actions/cache@v1
with:
path: node_modules
key: yarn-${{ hashFiles('yarn.lock') }}
- name: Run yarn
run: yarn && yarn dev
- name: Run tests
run: ./vendor/bin/phpunit
env:
APP_ENV: testing
- name: Upload artifacts
uses: actions/upload-artifact@master
if: failure()
with:
name: Logs
path: ./storage/logs
@ziming

This comment has been minimized.

Copy link

@ziming ziming commented Jan 17, 2020

Think you are missing a yarn install before yarn cache.

@rubenvanassche

This comment has been minimized.

Copy link
Owner Author

@rubenvanassche rubenvanassche commented Jan 17, 2020

Normally yarn should do a yarn install so yarn && yarn dev does an install + asset generation

@ziming

This comment has been minimized.

Copy link

@ziming ziming commented Jan 17, 2020

Didn't happen for me. In Github action console I get

##[error]The template is not valid. hashFiles('/home/runner/work/project-name/project-name/yarn.lock') failed. Search pattern '/home/runner/work/project-name/project-name/yarn.lock' doesn't match any file under '/home/runner/work/project-name/project-name'

The error disappeared after I add a yarn install step before yarn cache

@rubenvanassche

This comment has been minimized.

Copy link
Owner Author

@rubenvanassche rubenvanassche commented Jan 17, 2020

What happens if you change yarn && yarn dev to yarn install && yarn dev, does it still crash?

@ziming

This comment has been minimized.

Copy link

@ziming ziming commented Jan 17, 2020

Your yarn cache step is before (yarn && yarn dev) in your .yml file.

So changing it to yarn install && yarn dev didn't make a difference

Putting yarn && yarn dev step before the yarn cache step does make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.