Hacktoberfest 03: More Python and Automatic tests of PR

André Rosa
Oct 22 · 2 min read

In the 3rd Pull request for the Hacktoberfest I went back to Python programming. The page ‘Os Programadores’ (https://osprogramadores.com/) is a Portuguese language page aimed to teach new programming skills. The app has several contributors but it is not too hard to understand. The problem they faced was to check periodically if the links they provided in the pages were alive. To check the links manually was out of question, therefore I developed a Python script to do the job.

The program followed these steps:

1) Create a list of all files according to the extensions. As default ‘.html’ and ‘.yaml’;

2) Open and search each file for URLs, with the use of regular expressions, to create a list of existing URLs;

3) Validate each URL in the list;

4) Generated a report of broken links and the source file they are located in.

To succeed I had to work with Python classes, lists, functions and methods to search, open and read files and in about two hours I had a working script. As this is a brand-new file in the app, I was careful to create good comments and keep the code simple as possible with the use of plain Python.

The Original repo is: https://github.com/OsProgramadores/op-website-hugo , the original Issue is: https://github.com/OsProgramadores/op-website-hugo/issues/369 and my Pull Request is: https://github.com/OsProgramadores/op-website-hugo/pull/391

Well, what was interesting after the Pull Request? I received a message from Travis Buddy (https://github.com/TravisBuddy) at first I thought it was a real person but then I realized it was a kind of bot used to test the changes in the page. This was the first time I saw a bot testing a pull request. In Travis we can read: ‘TravisBuddy is a cloud service that creates comments in failed pull requests and tells the author what went wrong and what they can do to fix it.’