-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from mwood77/chron-job-links
Add product link validation for BOM
- Loading branch information
Showing
8 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"ignorePatterns": [ | ||
{ | ||
"pattern": "^http://winderoo.local/" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters