{"id":13725443,"url":"https://github.com/avasconcelos114/lighthouse-bot","last_synced_at":"2025-05-07T20:32:48.805Z","repository":{"id":42295676,"uuid":"230772767","full_name":"avasconcelos114/lighthouse-bot","owner":"avasconcelos114","description":"A chatbot that automates website auditing with Lighthouse for Mattermost","archived":false,"fork":false,"pushed_at":"2022-12-11T23:40:06.000Z","size":28918,"stargazers_count":5,"open_issues_count":13,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-04T01:27:44.223Z","etag":null,"topics":["chatops","hackfest-proposal","lighthouse-audits","mattermost","puppeteer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avasconcelos114.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-29T16:04:09.000Z","updated_at":"2023-09-14T18:28:56.000Z","dependencies_parsed_at":"2023-01-27T09:16:25.447Z","dependency_job_id":null,"html_url":"https://github.com/avasconcelos114/lighthouse-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avasconcelos114%2Flighthouse-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avasconcelos114%2Flighthouse-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avasconcelos114%2Flighthouse-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avasconcelos114%2Flighthouse-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avasconcelos114","download_url":"https://codeload.github.com/avasconcelos114/lighthouse-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224645386,"owners_count":17346140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatops","hackfest-proposal","lighthouse-audits","mattermost","puppeteer"],"created_at":"2024-08-03T01:02:23.389Z","updated_at":"2024-11-14T15:31:25.566Z","avatar_url":"https://github.com/avasconcelos114.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Lighthouse Auditing Bot   |  ![](https://img.shields.io/docker/pulls/avasconcelos114/lighthouse-bot.svg?maxAge=604800)  \n![](documentation/img/lighthouse-logo.png)\n\n## Summary\nThis project seeks to provide added value to the Mattermost ecosystem by adding performance auditing of websites with Google's [Lighthouse](https://developers.google.com/web/tools/lighthouse), offering a testing environment that is accessible directly from any Mattermost channel.\n\n![](documentation/img/readme.gif)\n\n![](documentation/img/audit-trend-dashboard.gif)\n## Features\n\n* __Ad-hoc Auditing__ - Quickly run an audit of a website with the `/lighthouse {url}` command, or simply type `/lighthouse` to launch a dialog with all available options\n* __Job Scheduling__ - With the `/lighthouse jobs` command, you can schedule an auditing job to be run whenever necessary\n* __Authentication Scripting__ - When auditing a website that requires an authenticated user, run your audit with an authentication script that will be injected into puppeteer at run-time (more information in [the auth tutorial](#tutorials))\n* __Customizeable HTML Reports__ - Always be able to view the full detailed report from Lighthouse as an HTML file, which is provided by a template in this project, and customize parts of the template (in `src/static/reportTemplate.html`) to your heart's content!\n* __Trend Charts__ - Track changes in each of the audit categories over time for a given URL by running the `/lighthouse stats {url}` command and clicking the link to an intuitive dashboard (also provided as an HTML template that can be customized in `src/static/statsTemplate.html`)\n\n## Development\n### Pre-requisites \u0026 Notes\n\n* **Node.js v10+**\n\n* **Mattermost v5.20+**\n\n* **[Create a Bot Account](https://docs.mattermost.com/developer/bot-accounts.html#user-interface-ui), or [issue a Personal Access Token](https://docs.mattermost.com/developer/personal-access-tokens.html#creating-a-personal-access-token) in a Mattermost server of your choice**\n\nNOTE: Since this bot relies on sending ephemeral messages through Mattermost's API, the account you're using __MUST__ have `System Admin` permissions\n\n* **Used environment variables**  \nRegardless of the method you are deploying with, this application relies on a variety of environment variables to be able to function properly. Either use the `export` method, or inject your docker container with env variables depending on what method you are deploying this chatbot with.\n\n| Variable name | Example value | Explanations / Notes |\n| --: | :-- | :-- |\n| PORT | 3001 | The port being used by this chatbot |\n| MATTERMOST_SERVER | http://192.168.1.10:8065 | The Mattermost instance you are using |\n| TOKEN | sd67j1cxepnc7meo3pof3krzgr | A Personal Access Token or Bot Account Token |\n| MONGO_USERNAME | root | Auth username for a mongodb server |\n| MONGO_PASSWORD | test_passwd | Auth password for a mongodb server |\n| MONGO_SERVER | 192.168.1.10:27017 | The endpoint for a mongodb server |\n| CHATBOT_SERVER | http://192.168.1.10:3001 | IP to be used by this chatbot (needed to set URL endpoints in Message Attachments) |\n| TZ (optional) | Asia/Seoul | The timezone value that will be used on server (important for job scheduling) |\n\n### Developing with Docker\n**0. Build local Lighthouse bot image** (optional)\n```\ndocker build -t avasconcelos114/lighthouse-bot .\n```\n\n**1. Run mongodb (as a separate container)**  \n```\ndocker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=\"root\" -e MONGO_INITDB_ROOT_PASSWORD=\"test_passwd\" --name lighthouse-mongo mongo:latest\n```\n\n**2. Run Lighthouse bot container**  \nNote: Ensure you have the environment variables set when running the container  \n  \nExample `run` command:\n```\ndocker run -d -p 3001:3001 -v $PWD/src:/home/app/src -e TZ=\"Asia/Seoul\" -e PORT=3001 -e MATTERMOST_SERVER=\"http://192.168.1.129:8065\" -e TOKEN=\"sd67j1cxepnc7meo3prf3krzgr\" -e MONGO_USERNAME=\"root\" -e MONGO_PASSWORD=\"test_passwd\" -e MONGO_SERVER=\"192.168.1.129:27017\" -e CHATBOT_SERVER=\"http://192.168.1.129:3001\" --name lighthouse-bot avasconcelos114/lighthouse-bot\n```\n\n**3. [Register a slash command](https://docs.mattermost.com/developer/slash-commands.html#custom-slash-command) in Mattermost that sends a `GET` request to the `/lighthouse` endpoint**  \n![](documentation/img/lighthouse-slashcmd.png)\n\n### Developing with PM2\n**0. Follow the [installation guide for MongoDB](https://docs.mongodb.com/manual/installation/) to set up your MongoDB instance** \n  \n**1. Set values for all required environment variables**  \n```\nexport PORT=3001\nexport MATTERMOST_SERVER=http://192.168.1.10:8065\nexport TOKEN=sd67j1cxepnc7meo3pof3krzgr\nexport MONGO_USERNAME=root\nexport MONGO_PASSWORD=test_passwd\nexport MONGO_SERVER=192.168.1.10:27017\nexport CHATBOT_SERVER=http://192.168.1.10:3001\nexport TZ=Asia/Seoul\n```\n\n**2. Globally install [PM2](https://pm2.keymetrics.io)**  \n\n```\nnpm install -g pm2\n```\n\n**3. Install dependencies**  \n```\nnpm install\n```\n\n**4. Run chatbot with pm2**  \n```\npm2 start ecosystem.config.js\n```\n\n**5. [Register a slash command](https://docs.mattermost.com/developer/slash-commands.html#custom-slash-command) in Mattermost that sends a `GET` request to the `/lighthouse` endpoint**  \n![](documentation/img/lighthouse-slashcmd.png)\n\n## Deployment\nDeploying this chatbot is done in the same way as the [development environment setup](#development), with the exception that you would set the `NODE_ENV` variable to `production`, as well as not do any volume binding to the host when running the chatbot with Docker.\n\n## Tutorials  \nWhile typing `/lighthouse help` provides you with a list of available commands for the Lighthouse chatbot, below are a few step-by-step tutorials that may help you with the most important aspects of using this chatbot.  \n\n* [Performing ad-hoc tests](documentation/recipes/ad-hoc.md)\n* [Scheduling audit jobs](documentation/recipes/scheduling.md)\n* [Authentication Scripting](documentation/recipes/auth-scripting.md)\n* [Viewing Audit Trends](documentation/recipes/audit-stats.md)\n\n\n## Troubleshooting\n* The audit command fails with an `error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory` error on Ubuntu\n  * Run the command below to install dependencies needed to launch Puppeteer from your host\n\n  ```\n  sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget\n  ```\n\n## Hackfest Proposal\nThis project has been created as a submission to the Mattermost Bot Hackfest.\n\nYou can [read the full Hackfest Proposal here](/documentation/README.md)\n\n### Current Tasks\n- [x] Implementing trend charts for audit results to be accessed with `/lighthouse stats {url}`\n- [x] Styling audit trends dashboard \n- [x] Add usernames to schedule schemas so that they can be easily viewed through `/lighthouse schedule list`\n- [x] Implementing `/lighthouse schedule info {id}` to get full details of a given job\n- [ ] Add unit testing with Jest or AVA\n- [x] Write documentation to make command usage clearer\n- [x] Add more comprehensive logging\n- [x] Investigate the possibility of using workers to run audits so that multiple audits can run simultaneously\n- [x] Add a configurable number of past audits to be fetched from `stats` command\n  - e.g. `/lighthouse stats https://google.com limit 15` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favasconcelos114%2Flighthouse-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favasconcelos114%2Flighthouse-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favasconcelos114%2Flighthouse-bot/lists"}