Skip to content

Commit

Permalink
Added automatic test workflow.
Browse files Browse the repository at this point in the history
- Added actions workflow to run unit tests, rebuild and run
  the action.
- Added example flyscrape script for testing.
  • Loading branch information
MrFlynn committed Jul 7, 2024
1 parent d6251ac commit 6c2ade4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: tests
on:
push:
paths:
- .github/workflows/test.yml
- __tests__/*.ts
- src/*.ts
- package.json
- package-lock.json
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- run: npm test
build-and-run-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- run: npm run build
- uses: ./
id: run-action
with:
script: examples/script.js
- run: 'echo "${{ steps.run-action.outputs.output }}" | jq'
18 changes: 18 additions & 0 deletions examples/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// A sample flyscrape script.

export const config = {
url: "https://example.com",
};

export default function ({ doc, _ }) {
const links = doc.find("a");

return {
urls: links.map((link) => {
return {
name: link.text(),
url: link.attr("href"),
};
}),
};
}

0 comments on commit 6c2ade4

Please sign in to comment.