Skip to content

Commit

Permalink
Merge pull request #14 from mwood77/chron-job-links
Browse files Browse the repository at this point in the history
Add product link validation for BOM
  • Loading branch information
mwood77 authored Oct 18, 2023
2 parents 6a05b9f + d85a670 commit dbe4c3a
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 6 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/lint-markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Markdown Link Checker

on:
pull_request:
workflow_dispatch:

jobs:
check-links:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4

- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-verbose-mode: 'yes'
config-file: '.github/workflows/markdown.links.config.json'
folder-path: 'docs/'
7 changes: 7 additions & 0 deletions .github/workflows/markdown.links.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ignorePatterns": [
{
"pattern": "^http://winderoo.local/"
}
]
}
32 changes: 32 additions & 0 deletions .github/workflows/selenium-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Aliexpress Product Checker

on:
workflow_dispatch:
schedule:
- cron: 0 9 * * 1 # 9AM every monday

jobs:
test:
runs-on: ubuntu-latest

container:
image: node:19

services:
selenium:
image: selenium/standalone-chrome
options: --shm-size=2gb

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: 19

- uses: abhi1693/setup-browser@v0.3.4
with:
browser: firefox

- run: npm i selenium-webdriver
- run: npx node .github/workflows/test-ali-links.mjs
43 changes: 43 additions & 0 deletions .github/workflows/test-ali-links.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { readFile } from 'fs/promises';
import { By, Builder } from 'selenium-webdriver';
import firefox from 'selenium-webdriver/firefox.js'

const links = [];
let driver;

const content = async(file) => {
return await readFile(file, 'utf8')
}

const search = async (item) => {
await driver.get('https://s.click.aliexpress.com/e/_' + item);
return await driver.findElements(By.className('not-found-page'))
}

content('./docs/bom-requirements.md')
.then(
result => {
const sanitizedMD = result.split('/_')
sanitizedMD.shift(); // remove stuff that doesn't include links
sanitizedMD.forEach((el) => {
links.push(el.split(')')[0])
})
}
)
.finally(
async () => {
driver = new Builder()
.forBrowser('firefox')
.setFirefoxOptions(new firefox.Options().headless())
.build();

// Test scraped aliexpress links from bom-doc
links.every(async el => {
const result = await search(el);

if (result.length > 0) {
throw new Error(`product ${el} is a broken link`, content)
}
});
}
);
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.vscode/launch.json
.vscode/ipch

node_modules/

src/platformio/osww-server/src/configurables.h

# System files
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* [Click Here to see the user manual](./docs/user-manual.md)

## Prerequisites
> [!IMPORTANT]
> This project is an add-on to your already built [Open Source Watch Winder (OSWW)](https://github.com/mwood77/osww)
#### Download and install the following on your computer:
Expand Down
3 changes: 1 addition & 2 deletions docs/bom-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# Bill of Materials & Cost

> ⚠️ IMPORTANT - READ THIS ⚠️
>
> [!IMPORTANT]
> This project is an add-on to your already built [Open Source Watch Winder (OSWW)](https://github.com/mwood77/osww).
- This microcontroller replaces the Pi Pico used in the OSWW.
Expand Down
8 changes: 4 additions & 4 deletions docs/install-software.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# Software Installtion & Flashing your ESP32

> ⚠️ IMPORTANT - READ THIS ⚠️
>
> [!IMPORTANT]
> This project is an add-on to your already built [Open Source Watch Winder (OSWW)](https://github.com/mwood77/osww).
- This project requires a microncontroller which replaces the Pi Pico used in the OSWW.
Expand All @@ -12,8 +11,9 @@

# Getting Started

### Have you completed the Prerequisites?
- [Read them here](./prereqs.md)
### Prerequisites
- Download [Visual Studio Code (VSCode)](https://code.visualstudio.com/download)
- Download [PlatformIO](https://platformio.org/install/ide?install=vscode)

## Flashing your microcontroller

Expand Down

0 comments on commit dbe4c3a

Please sign in to comment.