Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eugenefvdm's avatar

Pest PHP Session validation test failing at GitHub Actions but works locally.

I have a Pest automated test that checks to see if the minimum characters are 8 when doing the stock Laravel password reset. I had to implement this because I discovered in legacy code that the code Fortify has for PasswordValidationRules is failing on some websites because it was never updated.

When I run this test locally, it works. When I push the code to GitHub where it triggers a workflow action, the test fails.

The error at GitHub is:

Session missing error: password

Is session validation testing possible using GitHub Actions? What might I be missing?

Here is the test:

Here is the GitHub Actions yml:

0 likes
2 replies
LaryAI's avatar
Level 58

The issue you're encountering is likely due to differences in the environment between your local machine and the GitHub Actions runner. Here are a few steps to troubleshoot and potentially resolve the issue:

  1. Ensure Database Migrations and Seeders are Run: Make sure that your database is properly set up before running the tests. This includes running migrations and possibly seeding the database.

  2. Check for Missing Environment Variables: Ensure that all necessary environment variables are set correctly in your GitHub Actions workflow.

  3. Session Configuration: Ensure that the session is properly configured and that the session driver is set to file or another appropriate driver that works in the GitHub Actions environment.

  4. Debugging: Add some debugging steps to your GitHub Actions workflow to output the state of the application and the database.

Here is an updated version of your GitHub Actions workflow with additional steps to ensure the database is set up correctly and to add some debugging information:

Explanation:

  1. Database Migrations and Seeders:

    • Added php artisan migrate --force and php artisan db:seed --force to ensure the database is properly set up before running the tests.
  2. Debugging:

    • Added a step to list the database tables to ensure the database is correctly set up and accessible.

Additional Tips:

  • Session Configuration: Ensure that your config/session.php is properly configured for the GitHub Actions environment. You might want to set the session driver to file for simplicity.

  • Environment Variables: Double-check that all necessary environment variables are set correctly in your .env.ci file.

By following these steps, you should be able to identify and resolve the issue causing the test to fail in the GitHub Actions environment.

eugenefvdm's avatar

Well I'm not going to lie when I say the AI advice made me think.

First of all, I never considered I might have to use a file driver.

Secondly, I thought it interesting to give me an updated ci file that does forced migrations and seeders. Although in retrospect then why should I use file in the first place? I have no other confirmed information that GitHub Actions needs a file driver. Anyway I tried that and it didn't work.

But the advice gave me a chance to review many other things, including if I should maybe publish the session.php file and play with it's defaults. This didn't help either.

In the end I spent maybe another hour of troubleshooting.

This was my solution in the end, just exclude the damn thing.

})->group('excluded-at-github-actions');

And then

      - name: Execute tests
        run: vendor/bin/pest --exclude-group=excluded-at-github-actions

Please or to participate in this conversation.