[wp-trac] [WordPress Trac] #34694: Facilitate automated testing in context of pull requests and diffs
WordPress Trac
noreply at wordpress.org
Tue Nov 17 20:18:39 UTC 2015
#34694: Facilitate automated testing in context of pull requests and diffs
------------------------------+-----------------------------
Reporter: westonruter | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
------------------------------+-----------------------------
Comment (by jorbin):
I've started on a script to accomplish this in the short term with travis
and github. How it works:
1) Fetches the rss of changes to trac.
2) Finds all the uploaded patches.
3) Creates a new Branch for each patch
4) Applies that patch using grunt patch
5) pushes that branch to github
Right now it can fail due to patches not being generated from the root or
otherwise failing to apply. grunt patch will need to have an optional
argument added to fail if a patch can't be applied instead of prompting
the user to manually specificy a location (PR welcome if someone can get
to this before me). The script looks like this so far:
{{{
#!/bin/bash
# Set DIR based on the current Directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Get a list the 50 most recent changes
curl
"https://core.trac.wordpress.org/timeline?ticket_details=on&max=50&authors=&daysback=90&format=rss"
| \
# find the titles
grep --line-buffered "<title>\(.\)*</title>" | \
# Find the attachments
grep --line-buffered "attached" | \
# Remove the title tags
awk '{gsub("<[^>]*>", "")}1' | \
# Create a attachment url
awk -F ' ' '{print "https://core.trac.wordpress.org/raw-
attachment/ticket/" $5 "/" $1 }' | \
# Find only diff and patch files
grep --line-buffered "patch\|diff" | \
# remove the # from the ticket number in the url
awk '{gsub( "#", "")}1' > .tmp.urls
while IFS='' read -r line || [[ -n "$line" ]]; do
BRANCHNAME=$( cut -d '/' -f 6-7 <<< $line )
echo $BRANCHNAME
if grep $BRANCHNAME .patched ; then
echo "Yo"
else
echo "Applying $line"
cd $DIR
cd git-clone
git checkout master
git pull origin master
npm install
git checkout -b $BRANCHNAME
grunt patch:$line
git add -A
git commit -m "add change from $line"
cd $DIR
echo $BRANCHNAME >> .patched
fi
done < .tmp.urls
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34694#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list