-
Notifications
You must be signed in to change notification settings - Fork 189
chore: test Academy exercises #2097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4954ee6
wip
honzajavorek b9c8cd9
feat: keep exercises as separate files, include them to Markdown
honzajavorek 0125aae
chore: implement testing of JavaScript exercises
honzajavorek 2401347
refactor: use shorter names
honzajavorek ac7e71a
chore: add GitHub Action to run tests automatically
honzajavorek 26c9c2e
chore: ouch, wrong branch
honzajavorek 390a890
chore: one does not simply npm install
honzajavorek 44da821
style: make linter happy
honzajavorek ab61f89
chore: make sure there is no schedule until we merge this, add explan…
honzajavorek 9dbdc11
refactor: simplify the tests
honzajavorek 9ca5758
docs: document lychee and academy testing
honzajavorek c6fceb3
refactor: make exercises testable
honzajavorek 9c589f3
fix: avoid the yes option, fix crawlee installation, improve readabil…
honzajavorek bd72f32
chore: make the tests more meaningful
honzajavorek d65a95e
chore: improve the JS test suite
honzajavorek 820b1d4
style: make the code linter happy
honzajavorek f439180
style: condense and fix the solutions markup
honzajavorek d9182fd
chore: setup and teardown for Python
honzajavorek 5fcc7a2
chore: fix the JS test suite not to rely on npx --package
honzajavorek 1ad107f
fix: improve the Python test suite and fix solutions using Crawlee (s…
honzajavorek 2f3cb5c
style: fix markup
honzajavorek 3d9bbba
chore: fix typo
honzajavorek 3239895
chore: enable only as a cron
honzajavorek 971da08
chore: run monthly
honzajavorek 1e413ef
style: fix markup
honzajavorek 3bde6d6
fix: address bugbot comments
honzajavorek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,31 @@ | ||
| name: Test Academy | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 3 1 * *" # at 3am UTC on 1st day of month | ||
| workflow_dispatch: # allows running this workflow manually from the Actions tab | ||
|
|
||
| jobs: | ||
| test-exercises: | ||
| name: Test Academy Exercises | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Source code | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| cache: npm | ||
| cache-dependency-path: package-lock.json | ||
|
|
||
| - name: Setup Python | ||
| uses: astral-sh/setup-uv@v7 | ||
|
|
||
| - name: Install Bats | ||
| run: | | ||
| corepack enable | ||
| npm install --only=dev | ||
|
|
||
| - name: Test | ||
| run: npm run test:academy |
This file contains hidden or 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,8 +5,10 @@ description: Lesson about building a Node.js application for watching prices. Us | |
| slug: /scraping-basics-javascript/downloading-html | ||
| --- | ||
|
|
||
| import CodeBlock from '@theme/CodeBlock'; | ||
| import LegacyJsCourseAdmonition from '@site/src/components/LegacyJsCourseAdmonition'; | ||
| import Exercises from '../scraping_basics/_exercises.mdx'; | ||
| import LegoExercise from '!!raw-loader!roa-loader!./exercises/lego.mjs'; | ||
|
|
||
| <LegacyJsCourseAdmonition /> | ||
|
|
||
|
|
@@ -184,28 +186,17 @@ Letting our program visibly crash on error is enough for our purposes. Now, let' | |
|
|
||
| <Exercises /> | ||
|
|
||
| ### Scrape AliExpress | ||
| ### Scrape LEGO | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only I fixed. After this one I decided fixing the exercises should be in separate PRs, not in this one: #2113 |
||
|
|
||
| Download HTML of a product listing page, but this time from a real world e-commerce website. For example this page with AliExpress search results: | ||
| Download HTML of a product listing page, but this time from a real world e-commerce website. For example this page with LEGO search results: | ||
|
|
||
| ```text | ||
| https://www.aliexpress.com/w/wholesale-darth-vader.html | ||
| https://www.lego.com/en-us/themes/star-wars | ||
| ``` | ||
|
|
||
| <details> | ||
| <summary>Solution</summary> | ||
|
|
||
| ```js | ||
| const url = "https://www.aliexpress.com/w/wholesale-darth-vader.html"; | ||
| const response = await fetch(url); | ||
|
|
||
| if (response.ok) { | ||
| console.log(await response.text()); | ||
| } else { | ||
| throw new Error(`HTTP ${response.status}`); | ||
| } | ||
| ``` | ||
|
|
||
| <CodeBlock language="js">{LegoExercise.code}</CodeBlock> | ||
| </details> | ||
|
|
||
| ### Save downloaded HTML as a file | ||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TC-MO Can you take a look at this README change, please? Does it make sense this way?