Coder Social home page Coder Social logo

changed-cy-tests's Introduction

changed-cy-tests ci status

Example GitHub Action running changed Cypress specs against master first, then all the tests

Inspired by Jest and the --changedSince flag in GitHub Actions CI

Example pull request #2 with just changed file spec-b.js. The GitHub workflow .github/workflows/ci.yml determines that this file has changed against the master branch and first runs just this spec. If that passes, then it runs ALL specs.

We determine the changed Cypress specs using the following git command (after checking out both head and base branches)

git diff --name-only \
  origin/${{ github.base_ref }} origin/${{ github.head_ref }} -- cypress/integration

Changed Cypress specs

Then if this returns something we can use cypress run --spec ... to run the changed specs first.

CHANGED_SPECS=$(git diff --name-only origin/${{ github.base_ref }} origin/${{ github.head_ref }} -- cypress/integration)
if [ -n "$CHANGED_SPECS" ]; then
  echo "Running the following changed specs"
  echo $CHANGED_SPECS
  npx cypress run --spec $CHANGED_SPECS
fi

Running changed specs

And after that we can run all specs using Cypress GitHub Action

The combination of fail fast on the changed specs + run all specs afterwards feels good.

Cypress Dashboard

Cypress dashboard run

changed-cy-tests's People

Contributors

bahmutov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

changed-cy-tests's Issues

Unnecessary checkout

I don't think these lines

# get the actual source for two branches
git checkout origin/${{ github.base_ref }}
git checkout origin/${{ github.head_ref }}
# get back to the merge commit
git checkout ${{ github.sha }}
are needed, the git fetch lines are enough to then be able to do perform the diff and to get the changed files which are all that's needed further down.

Happy to raise a PR if there isn't something I'm missing here?

Thanks for these and the accompanying blog post - really really useful!

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.