Skip to content

Commit

Permalink
Merge pull request #33 from fterh/release-v1.0
Browse files Browse the repository at this point in the history
Release v1.0.0
  • Loading branch information
fterh authored May 10, 2019
2 parents e13b522 + 4c1768d commit 52d075e
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 73 deletions.
14 changes: 13 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
dist: xenial
services:
- docker
language: python
python:
- "3.7"
before_install:
- docker pull python:3
install:
- pip install pipenv
script:
before_script:
- pipenv install
script:
- pipenv run invoke test
deploy:
provider: heroku
api_key:
secure: "$HEROKU_API_KEY"
app:
master: fterh-sneakpeek
develop: fterh-sneakpeek-staging
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## Changelog
## v1.0.0
* Add support for Docker
* Set up continuous deployment (Heroku)
* Update README
* Separate changelog into CHANGELOG.md

### v0.8.0-beta
* Fix program stops running after a while (issue #30)
* Implement proper logging
* Clean up and refactor codebase
* Travis CI

### v0.7.0-beta
* Fix random crashes (issue #25)
* Fix README formatting issues
* Clean up code
* Update README developer documentation

### v0.6.0-beta
* Update subreddit monitoring implementation

### v0.5.0-beta
* Fix program crash when exception occurs (issue #13)
* Fix exception in handling Ricemedia links (issue #19)
* Add support for businesstimes.com.sg, tnp.sg, yahoo.com
* Add support for CNAlifestyle

### v0.4.0-beta
* Add Straits Times support

### v0.3.0-beta
* Temporarily remove Straits Times support
(until premium article detection feature)
* Fix Todayonline article handling
* Fix Ricemedia article handling
* Update AbstractBaseHandler `handle` method definition
* Add tests

### v0.2.2-beta
* Fix scheduling bug

### v0.2.1-beta
* Remove ricemedia.co from list of supported sites (incompatibility)
* Fix start script to run immediately
* Fix long lines in README

### v0.2.0-beta
* Add scheduling to run every 2 minutes
* Update database module to be compatible with new database table structure
(3 columns)

### v0.1.0-beta
* Minimum viable product
* Supports channelnewsasia.com, mothership.sg, ricemedia.co, straitstimes.com,
todayonline.com, zula.sg
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3
WORKDIR /
COPY . /
RUN pip install pipenv
RUN pipenv install
RUN pipenv run pip freeze > requirements.txt
RUN pip install -r requirements.txt
CMD ["python", "main.py"]
90 changes: 23 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ too long.
* zula.sg

## Contributing
1. Write documentation
2. Write Handlers to support more websites
3. Write tests
PRs are always welcome.

1. Write Handlers to support more websites
2. Improve test coverage
3. Improve documentation

### New version release checklist
1. Create a release branch (e.g. `release-v1.2.3`) from the `develop` branch
Expand All @@ -30,9 +32,25 @@ too long.
4. Possibly commit minor bug fixes to the release branch
5. Merge the release branch into `master` and `develop`

This project follows this [Git branching workflow](https://nvie.com/posts/a-successful-git-branching-model/):
This project follows this [Git branching workflow](https://nvie.com/posts/a-successful-git-branching-model/).

## Operation
### Before running
The program requires an environmental variable `SUBREDDIT` to be set.
This specifies the subreddit that the bot will monitor.
If it's not set, the default subreddit `/r/all` will be monitored.
At the moment, only 1 subreddit may be specified.

### Running/Testing
All the commands below assume that the virtual environment has been activated
(`pipenv shell`).

* Running: `SUBREDDIT=name python main.py` (or `SUBREDDIT=name nohup python main.py &`)
* Testing: `invoke test`

#### Docker
This application can be built and run as a Docker image.

## How it works
### General
`main.py` starts the bot and calls `scan(subreddit)` (in `scan.py`),
which monitors for new submissions in the provided subreddit.
Expand Down Expand Up @@ -68,65 +86,3 @@ sub-modules or sub-packages as necessary.
The comments module (in `comment.py`) exports the Comment class,
which all Handlers must return. A Comment class requires a `title` and `body`,
and accepts a `byline` and `attribution` (which are optional).

## Running and deploying
All the commands below assume you have already activated the
virtual environment (`pipenv shell`). Alternatively, prepend `pipenv run` to
the commands.

### Development
`python main.py`

### Testing
`invoke test`

### Production
`ENV=prod python main.py` or `ENV=prod nohup python main.py &`

## Changelog
### v0.8.0-beta
* Fix program stops running after a while (issue #30)
* Implement proper logging
* Clean up and refactor codebase
* Travis CI

### v0.7.0-beta
* Fix random crashes (issue #25)
* Fix README formatting issues
* Clean up code
* Update README developer documentation

### v0.6.0-beta
* Update subreddit monitoring implementation
### v0.5.0-beta
* Fix program crash when exception occurs (@yleong PR #22)
* Fix exception in handling Ricemedia links (@yleong PR #20)
* Add support for businesstimes.com.sg, tnp.sg, yahoo.com (@changhuapeng PR #18)
* Add support for CNAlifestyle (@changhuapeng PR #17)
### v0.4.0-beta
* Add Straits Times support
### v0.3.0-beta
* Temporarily remove Straits Times support
(until premium article detection feature)
* Fix Todayonline article handling
* Fix Ricemedia article handling
* Update AbstractBaseHandler `handle` method definition
* Add tests

### v0.2.2-beta
* Fix scheduling bug

### v0.2.1-beta
* Remove ricemedia.co from list of supported sites (incompatibility)
* Fix start script to run immediately
* Fix long lines in README

### v0.2.0-beta
* Add scheduling to run every 2 minutes
* Update database module to be compatible with new database table structure
(3 columns)

### v0.1.0-beta
* Minimum viable product
* Supports channelnewsasia.com, mothership.sg, ricemedia.co, straitstimes.com,
todayonline.com, zula.sg
7 changes: 2 additions & 5 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@

load_dotenv()

# Set to "prod" in production, but default to "dev"
ENV = os.getenv("ENV", "dev")

# Logging configuration
LOGGING = {
"LEVEL": logging.DEBUG,
"HANDLER": logging.StreamHandler(sys.stdout) # Log to stdout (see: https://12factor.net/logs)
}

BOT = {
"VERSION": "0.8.0-beta",
"VERSION": "1.0.0",
"REPO_LINK": "https://github.com/fterh/sneakpeek",
"CONTRIBUTE_LINK": "https://github.com/fterh/sneakpeek"
}
Expand All @@ -31,5 +28,5 @@

USER_AGENT = os.getenv("USER_AGENT")

SUBREDDIT = "singapore" if ENV == "prod" else "rsgretrivr"
SUBREDDIT = os.getenv("SUBREDDIT", "all") # Set subreddit using environmental variables, default to /r/all
COMMENT_LENGTH_LIMIT = 9900
3 changes: 3 additions & 0 deletions heroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build:
docker:
worker: Dockerfile
28 changes: 28 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
beautifulsoup4==4.7.1
certifi==2018.11.29
chardet==3.0.4
cssselect==1.0.3
feedfinder2==0.0.4
feedparser==5.2.1
idna==2.8
invoke==1.2.0
jieba3k==0.35.1
lxml==4.3.0
newspaper3k==0.2.8
nltk==3.4
Pillow==5.4.1
praw==6.0.0
prawcore==1.0.0
python-dateutil==2.7.5
python-dotenv==0.10.1
PyYAML==3.13
requests==2.21.0
requests-file==1.4.3
schedule==0.5.0
singledispatch==3.4.0.3
six==1.12.0
soupsieve==1.7
tinysegmenter==0.3
tldextract==2.2.0
update-checker==0.16
urllib3==1.24.1

0 comments on commit 52d075e

Please sign in to comment.