User Story

As a WF engineer I want some codeception tests to run on git push only if the commit contains files executed by those tests so that ALL codeception tests aren't run every time

Inspiration

One time I broke a thing :( It was not immediately obvious from the UI how to execute these functionalities that I broke. I thought "wouldn't it be cool if on git push something yelled at me that I broke something way before I was going to deploy?" fast forward a few months- I am tasked with re-building this tool in React. I built the codeception tests for the functionality so the next poor sap wouldn't repeat the history of breaking those things....but I wouldn't want these to run for every deploy. How would the developer know these tests exist? He won't. This process will run the tests only if the engineer changes files that will break the functionality.

When setting up the Codeception tests the engineer will use annotations to list the files that could break functionality in the future (model, dao, controller, js files) like the @Codeception_Owner that Paul DelRe is rolling out. This will create the mapping (between source code and codeception tests) in the database.

instead of running git push the engineer will run git testNpush

What it does

sends a list of changed files to an endpoint and executes the tests returned by that endpoint then proceeds with normal push operations

Add this alias section in an engineer's .gitconfig file

testNpush = "!f(){ for file in $(curl --cookie "server=CCAPODILUPO" -sb -H "Accept:application/json" http://adminwayfaircom.csnzoo.com/v/codeception/codeception/get_class_locations_for_code_paths?paths=$(git diff --name-only)); do wf test codeception -c $file -e ccapodilupo; done; git push;}; f"

How I built it

2 datatables (http://rb.csnzoo.com/r/285288), an endpoint, a dao method, a collection method (http://rb.csnzoo.com/r/285289) and a Git alias

Challenges I ran into

shell scripting is hard!

Accomplishments that I'm proud of

meh

What I learned

shell scripting is hard!

What's next

clean up code and socialize this idea to move this out of the console and into a hook/pipeline on the php and resources repos

Built With

Share this project:
×

Updates