Skip to content

Commit

Permalink
Issue webcompat#1145 - Used cross platform python modules instead of …
Browse files Browse the repository at this point in the history
…shell commands
  • Loading branch information
deepthivenkat committed Aug 9, 2016
2 parents 081b832 + e48404c commit 1e6f8c3
Show file tree
Hide file tree
Showing 73 changed files with 7,980 additions and 1,505 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ uploads/
config/secrets.py

# backup folder contains the issues.db backup file with issues dump
#for the previous version of schema
backup/*.db
# for the previous version of schema
backups/*.db

# these are our 'dist' files
# checking them into the repo is silly
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ git:
depth: 5

addons:
firefox: "44.0"
firefox: "47.0.1"

env:
global:
Expand All @@ -32,8 +32,8 @@ env:
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- "mkdir -p $HOME/.selenium && cd $HOME/.selenium && wget -nc http://selenium-release.storage.googleapis.com/2.52/selenium-server-standalone-2.52.0.jar"
- java -jar selenium-server-standalone-2.52.0.jar &> /dev/null &
- "mkdir -p $HOME/.selenium && cd $HOME/.selenium && wget -nc http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar"
- java -jar selenium-server-standalone-2.53.1.jar &> /dev/null &
- cd -

install:
Expand Down
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
## 2.7.1 - 2016-07-27

* Adds block for qiangpiaoruanjian [Pull #1142](https://github.com/webcompat/webcompat.com/pull/1142) [Issue #1141](https://github.com/webcompat/webcompat.com/issues/1141)
* Render all comments (not just 30) [Pull #1119](https://github.com/webcompat/webcompat.com/pull/1119) [Issue #1058](https://github.com/webcompat/webcompat.com/issues/1058)
* Add missing fixture files [Pull #1129](https://github.com/webcompat/webcompat.com/pull/1129) [Issue #1123](https://github.com/webcompat/webcompat.com/pull/1123)
* Add 301 redirect for /new endpoint [Pull #1130](https://github.com/webcompat/webcompat.com/pull/1130) [Issue #1120](https://github.com/webcompat/webcompat.com/issues/1120)


## 2.7.0 - 2016-07-11

* Add IP logging for bug reports (to be able to investigate abuse) [Pull #1125](https://github.com/webcompat/webcompat.com/pull/1125) * [Issue #719](https://github.com/webcompat/webcompat.com/issues/719)
* Fix CSS variable name [Pull #1122](https://github.com/webcompat/webcompat.com/pull/1122) [Issue #1121](https://github.com/webcompat/webcompat.com/issues/1121)
* Handle Link headers from Comments endpoints [Pull #1117](https://github.com/webcompat/webcompat.com/pull/1117) [Issue #1100](https://github.com/webcompat/webcompat.com/pull/1100)
* Replace "new" with "needs triage" [Pull #1114](https://github.com/webcompat/webcompat.com/pull/1114) [Issue #975](https://github.com/webcompat/webcompat.com/issues/975)
* Document strict review comment policy [Pull #1112](https://github.com/webcompat/webcompat.com/pull/1112) [Issue #1110](https://github.com/webcompat/webcompat.com/issues/1110)
* Pointer-events tweak on icon images for Chrome [Pull #1107](https://github.com/webcompat/webcompat.com/pull/1107) [Issue #1088](https://github.com/webcompat/webcompat.com/issues/1088)

## 2.6.1 - 2016-06-28

* Hide NSFW images if they have a nsfw label [Pull #1087](https://github.com/webcompat/webcompat.com/pull/1087) [Issue #1001](https://github.com/webcompat/webcompat.com/pull/1001)
* Improve label contrast [Pull #1094](https://github.com/webcompat/webcompat.com/pull/1094) [Issue #482](https://github.com/webcompat/webcompat.com/issues/482)
* Improve comment header layout [Pull #1095](https://github.com/webcompat/webcompat.com/pull/1095) [Issue #972](https://github.com/webcompat/webcompat.com/issues/972)
* Improve submit comment design [Pull #1096](https://github.com/webcompat/webcompat.com/pull/1096) (No issue)
* Fix path for requirements.txt in CONTRIBUTING [Pull #1099](https://github.com/webcompat/webcompat.com/pull/1099) [Issue #1098](https://github.com/webcompat/webcompat.com/issues/1098)
* Pass params with comments endpoint [Pull #1103](https://github.com/webcompat/webcompat.com/pull/1103) [Issue #1101](https://github.com/webcompat/webcompat.com/issues/11001)
* Fix different favicon bug [Pull #1105](https://github.com/webcompat/webcompat.com/pull/1105) [Issue #1046](https://github.com/webcompat/webcompat.com/issues/1046)

## 2.6.0 - 2016-06-14

* Remove nested labels from markup [Pull #1092](https://github.com/webcompat/webcompat.com/pull/1092) [Issue #1072](https://github.com/webcompat/webcompat.com/issues/1072)
* Improved search bar design [Pull #1091](https://github.com/webcompat/webcompat.com/pull/1091) [Issue #1089](https://github.com/webcompat/webcompat.com/issues/1089)
* Syntax and import clean ups [Pull #1085](https://github.com/webcompat/webcompat.com/pull/1085) [Issue #1084](https://github.com/webcompat/webcompat.com/issues/1084)
* Functional tests around label URL updates [Pull #1080](https://github.com/webcompat/webcompat.com/pull/1080) [Issue #1079](https://github.com/webcompat/webcompat.com/pull/1079)
* Add clear filter event to labelSearch [Pull #1078](https://github.com/webcompat/webcompat.com/pull/1078) [Issue #1074](https://github.com/webcompat/webcompat.com/pull/1074)
* Fix label href URL [Pull #1077](https://github.com/webcompat/webcompat.com/pull/1077) [Issue #1075](https://github.com/webcompat/webcompat.com/pull/1075)
* Update docs around ISSUES_REPO_URI [Pull #1076](https://github.com/webcompat/webcompat.com/pull/1076) [Issue #1069](https://github.com/webcompat/webcompat.com/issues/1069)

## 2.5.2 - 2016-05-31

* Ensure label list UI is updated when labels are set [Pull #1073](https://github.com/webcompat/webcompat.com/pull/1073) [Issue #1045](https://github.com/webcompat/webcompat.com/issues/1045)
* Make search bar distinct from background [Pull #1065](https://github.com/webcompat/webcompat.com/pull/1065) [Issue #1064](https://github.com/webcompat/webcompat.com/issues/1064)
* Fix image uploads for issues [Pull #1067](https://github.com/webcompat/webcompat.com/pull/1067) [Issue #1063](https://github.com/webcompat/webcompat.com/pull/1063)

## 2.5.1 - 2016-05-26

* Scope labelSearch to actual anchor elm (not its wrapper) [Pull #1068](https://github.com/webcompat/webcompat.com/pull/1068) [Issue #1066](https://github.com/webcompat/webcompat.com/issues/1066)
* Bandaid fix to allow for up to 100 comments per issue [Pull #1057](https://github.com/webcompat/webcompat.com/pull/1057) [Issue #1044](https://github.com/webcompat/webcompat.com/issues/1044)

## 2.5.0 - 2016-05-20

* Convert PNG to JPEG on the server [Pull #1052](https://github.com/webcompat/webcompat.com/pull/1052) [Issue #1051](https://github.com/webcompat/webcompat.com/issues/1051)
Expand Down
83 changes: 58 additions & 25 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,46 +77,52 @@ project.

All code contributions should come in the form of a [pull request](https://help.github.com/articles/creating-a-pull-request), as a topic branch.

* Have a quick search through existing issues and pull requests so you don't waste any of your time.
1. Have a quick search through existing issues and pull requests so you don't waste any of your time.

* If no existing issue covers the change you want to make, please [open a new issue](https://github.com/webcompat/webcompat.com/issues/new) before you start coding.
2. If no existing issue covers the change you want to make, please [open a new issue](https://github.com/webcompat/webcompat.com/issues/new) before you start coding.

* Fork repository
3. Fork repository

![master](http://f.cl.ly/items/1E3f0A0I2A2b3T2L2I2c/forked.png)
![master](http://f.cl.ly/items/1E3f0A0I2A2b3T2L2I2c/forked.png)

You'll probably want to [set up a local development environment](#working-environment-setup) to get that far. If you've already been through this process, make sure you've [set the main repo as an upstream remote](https://help.github.com/articles/configuring-a-remote-for-a-fork/) and make sure [your fork is up to date](https://help.github.com/articles/syncing-a-fork/) before sending pull requests.
You'll probably want to [set up a local development environment](#working-environment-setup) to get that far. If you've already been through this process, make sure you've [set the main repo as an upstream remote](https://help.github.com/articles/configuring-a-remote-for-a-fork/) and make sure [your fork is up to date](https://help.github.com/articles/syncing-a-fork/) before sending pull requests.

* Make your changes in a new branch
4. Make your changes in a new branch

`git checkout -b name-of-fix-branch`
`git checkout -b name-of-fix-branch`

* Create your patch; commit your changes. Referencing the issue number you're working on from the message is recommended.
5. Create your patch; commit your changes. Referencing the issue number you're working on from the message is recommended.

`git commit -m 'Issue #123 - Fixes broken layout on mobile browsers`
`git commit -m 'Issue #123 - Fixes broken layout on mobile browsers`

* Push your branch to GitHub:
6. Push your branch to GitHub:

`git push origin name-of-fix-branch`
`git push origin name-of-fix-branch`

* If you want to discuss your code or ask questions, please comment in the corresponding issue. You can link to the code you have pushed to your repository to ask for code review.
7. If you want to discuss your code or ask questions, please comment in the corresponding issue. You can link to the code you have pushed to your repository to ask for code review.

* When your code is ready to be integrated into the project, use the GitHub site to send a pull request to `webcompat.com:master`, aka the master branch of the repo you forked from. This will be the default choice.
8. When your code is ready to be integrated into the project, use the GitHub site to send a pull request to `webcompat.com:master`, aka the master branch of the repo you forked from. This will be the default choice.

![master](https://cldup.com/YVlLDGItPf-3000x3000.png)
![master](https://cldup.com/YVlLDGItPf-3000x3000.png)

* Set the title of the pull request to reference the issue number.
`Fixes #123 - Fixes broken layout on mobile browsers`
9. Set the title of the pull request to reference the issue number.

* When sending the pull request do not forget to call out someone for review by using the following convention:
`Fixes #123 - Fixes broken layout on mobile browsers`

`r? @miketaylr`
10. When sending the pull request do not forget to call out someone for review by using the following convention:

This will notify the person that your request is waiting for a review for merging. Ask a review only by one person, this will avoid misunderstandings and the ball is dropped. (Python: karlcow, miketaylr. JavaScript: magsout, miketaylr, tagawa CSS: magsout).
`r? @miketaylr`

* Continue discussion in the pull request.
This will notify the person that your request is waiting for a review for merging. Ask a review only by one person, this will avoid misunderstandings and the ball is dropped. (Python: karlcow, miketaylr. JavaScript: magsout, miketaylr, tagawa CSS: magsout).

11. Continue discussion in the pull request.

The discussion might lead to modify or abandon this specific pull request. This is the place where you can have a code review.

12. Once the Pull Request **got an explicit `r+`** from the reviewer(s), it is the responsibility of the reviewer to merge the branch (or the admin). A pull request submitter should never merge himself/herself the pull request.

The repo owners might choose to self-merge for urgent security or hot fixes.

The discussion might lead to modify or abandon this specific pull request. This is the place where you can have a code review.

After all that, if you'd like, you can send a pull request to add your name to our humans.txt file.

Expand Down Expand Up @@ -211,6 +217,18 @@ sudo apt-get update
sudo apt-get install python2.7 python2.7-dev
```
In Ubuntu, sometimes even after installing Node.js, the command `node -v` does not show the installed version. To complete installation, a symbolic link has to be created to the sbin folder.
```
#remove old symbolic links if any
sudo rm -r /usr/bin/node
#add new symbolic link
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo ln -s /usr/bin/nodejs /usr/sbin/node
```
### Simple setup (Mac OS and Linux)
#### Initializing Project source code
Expand Down Expand Up @@ -276,9 +294,12 @@ source env/bin/activate
# Windows: http://pillow.readthedocs.org/en/3.0.x/installation.html#windows-installation
# Linux: http://pillow.readthedocs.org/en/3.0.x/installation.html#linux-installation
# install rest of dependencies
pip install -r requirements.txt
pip install -r config/requirements.txt
# In Ubuntu, if ImportError: No module named flask.ext.github occurs, it means the dependencies in requirements.txt are installed in /usr/lib instead of <project_repository>/env/python<version>/site-packages.
# In this case, use virtual environment's pip from <project_repository>/env/lib/pip folder of the project repository instead of the global pip.
```
#### Installing Grunt
We use [Grunt](http://gruntjs.com/) as a task runner to perform certain things (minify + concat JS assets, for example). You need to have [Node.js](https://nodejs.org/en/download/) installed to be able to run Grunt. Once that's done, `npm` can be used to install Grunt and other build dependencies.
Expand Down Expand Up @@ -391,10 +412,10 @@ We use [Intern](http://theintern.io/) to run functional tests.
To run them, make sure you download the Selenium standalone server from the repo root:
``` bash
wget http://selenium-release.storage.googleapis.com/2.52/selenium-server-standalone-2.52.0.jar
wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
```
**Note: This version is known to work with Firefox 44. If things aren't working with the current stable version of Firefox, check to see
**Note: This version is known to work with Firefox 47.0.1. If things aren't working with the current stable version of Firefox, check to see
if there isn't a newer version of the Selenium standalone server and file a bug on these docs!**
The `firefox` binary will also need to be in your `PATH`. Here's how this can be done on OS X:
Expand All @@ -403,10 +424,14 @@ The `firefox` binary will also need to be in your `PATH`. Here's how this can be
export PATH="/Applications/Firefox.app/Contents/MacOS/:$PATH"
```
If you are a member of webcompat organisation in GitHub, edit `config/secrets.py`. The value of `ISSUES_REPO_URI` is the path of the repository containing test issues.
Change the value to : `ISSUES_REPO_URI = 'webcompat/webcompat-tests/issues'`.
Now start Selenium:
``` bash
java -jar selenium-server-standalone-2.52.0.jar
java -jar selenium-server-standalone-2.53.1.jar
```
In a separate terminal window or tab, start the application servers:
Expand All @@ -431,6 +456,14 @@ node_modules/.bin/intern-runner config=tests/intern user=testusername pw=testpas
**Note** Be aware that this will add the `testusername` and `testpassword` to your bash history. It is possible to run the tests without using a GitHub username and password as command-line arguments. In that case, the automatic login will fail and you then have 10 seconds to manually enter a username and password in the GitHub login screen that appears.
If you have [Two-Factor Authentication](https://help.github.com/articles/about-two-factor-authentication/) enabled and need time to enter a token, you can use the `loginDelay` command-line argument:
``` bash
node_modules/.bin/intern-runner config=tests/intern user=testusername pw=testpassword loginDelay=true
```
This will give you 10 extra seconds to enter a 2FA token when the inital login happens. By default there is no delay, so if you don't need this &mdash; you don't need to do anything differently.
To run a single test suite, where foo.js is the file found in the `tests/functional` directory:
```bash
Expand Down
5 changes: 3 additions & 2 deletions config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@
# app.logger.info(Thing_To_Log)
# it will create a line with the following format
# 2015-09-14 20:50:19,185 INFO: Thing_To_Log [in /codepath/views.py:127]

LOG_FILE = '/tmp/webcompat.log'
LOG_FMT = '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'
LOG_FMT = '%(asctime)s tracking %(message)s'

# Status categories used in the project
# 'new', 'needsdiagnosis', 'needscontact', 'contactready' , 'sitewait', 'close'
# Creating the model
Category = namedtuple('Category', ['name', 'dataAttribute', 'label'])
CATEGORIES = []
cat_labels = [('new', 'new', 'New Issues'),
cat_labels = [('needstriage', 'needstriage', 'Needs Triage'),
('needsDiagnosis', 'needsdiagnosis', 'Needs Diagnosis'),
('needsContact', 'needscontact', 'Needs Contact'),
('ready', 'contactready', 'Ready for Outreach'),
Expand Down
11 changes: 3 additions & 8 deletions config/secrets.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,10 @@ elif LOCALHOST:

# Database backup path. PRODUCTION and STAGING can be ignored for
# local testing.
if PRODUCTION:
BACKUP_DEFAULT_DEST = ''
BACKUP_DEFAULT_URL = ''
elif STAGING:
if LOCALHOST:
BACKUP_DEFAULT_DEST = BASE_DIR + '/backups/'
else:
BACKUP_DEFAULT_DEST = ''
BACKUP_DEFAULT_URL = ''
elif LOCALHOST:
BACKUP_DEFAULT_DEST = BASE_DIR + '/backup/'
BACKUP_DEFAULT_URL = 'http://localhost:5000/backup/'

# Production GiHub Issues repo URI. Can be ignored for local testing.
if PRODUCTION:
Expand Down
20 changes: 10 additions & 10 deletions labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def get_issue_labels(labels_uri):
def create_label(labels):
'''Create a label in the user repo'''
response = requests.post(
USER_LABELS_URI,
json.dumps(labels),
headers=AUTH_HEADERS)
USER_LABELS_URI,
json.dumps(labels),
headers=AUTH_HEADERS)
if not response.status_code == 201:
response.raise_for_status()

Expand All @@ -45,28 +45,28 @@ def delete_label(name):

def main():
'''Duplicate webcompat test repo labels in user test repo'''
#check if the user repo is a webcompat repo
# check if the user repo is a webcompat repo
if (ISSUES_URI == "webcompat/webcompat-tests" or
ISSUES_URI == "webcompat/webcompat.com"):
sys.exit("Error: Attempting to change a webcompat repo")
try:
#get all existing labels from the user issues repo
# get all existing labels from the user issues repo
user_labels = get_issue_labels(USER_LABELS_URI)
#delete all existing labels from the user issues repo
# delete all existing labels from the user issues repo
for label in user_labels:
delete_label(label.get('name'))
#get all labels from the webcompat tests repo
# get all labels from the webcompat tests repo
webcompat_labels = get_issue_labels(WEBCOMPAT_LABELS_URI)
#re-create labels in user issues repo
# re-create labels in user issues repo
for label in webcompat_labels:
data = {"name": label.get('name'), "color": label.get('color')}
create_label(data)
sys.exit(0)
except requests.exceptions.HTTPError as e:
#handles exceptions occuring due to undesired response status code
# handles exceptions occuring due to undesired response status code
sys.exit("Error: {}".format(e))
except requests.exceptions.RequestException as e:
#handles all other exceptions
# handles all other exceptions
sys.exit("Error: {}".format(e))


Expand Down
Loading

0 comments on commit 1e6f8c3

Please sign in to comment.