Skip to content
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

[LAB7] 312551011 #576

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/lab-autograding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
const pr = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });
const labels = pr.data.labels;
const lab = labels.find((label) => label.name.startsWith('lab'));
if (!lab) {
if (!lab) {
core.setFailed('No lab label found on the PR.');
return { number: 0 };
}
Expand All @@ -44,12 +44,11 @@ jobs:

const files = await github.rest.pulls.listFiles({ owner, repo, pull_number: issue_number });
const changedFiles = files.data.map((file) => file.filename);
const allowedFiles = [
`lab${labNumber}/main_test.js`,
];
// if (!changedFiles.every((file) => allowedFiles.includes(file))) {
// core.setFailed('The PR contains changes to files other than the allowed files.');
// }
const allowedFileRegex = /^lab\d+\/main_test.js$/;
const specialChangedFiles = ["lab5/Answer.md", "lab5/antiasan.c", "lab6/Answer.md", "lab7/sol.py"];
if (!changedFiles.every((file) => (allowedFileRegex.test(file) || specialChangedFiles.includes(file)))) {
core.setFailed('The PR contains changes to files other than the allowed files.');
}
return labNumber;
- name: Grading
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
29 changes: 29 additions & 0 deletions lab4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Lab4

## Introduction

In this lab, you will write tests in `main_test.js`. You can learn how to use [Puppeteer](https://pptr.dev/) to tests a web UI.

## Preparation (Important!!!)

1. Sync fork your branch (e.g., `SQLab:311XXXXXX`)
2. `git checkout -b lab4` (**NOT** your student ID !!!)

## Requirement

1. (100%) Goto https://pptr.dev/, type `chipi chipi chapa chapa` into the search box, click on **1st** result in the **Docs** section, and print the title.

For the detailed steps and hints, please check the slide of this lab.

You can run `validate.sh` in your local to test if you satisfy the requirements.

Please note that you must not alter files other than `main_test.js`. You will get 0 points if

1. you modify other files to achieve requirements.
2. you can't pass all CI on your PR.

## Submission

You need to open a pull request to your branch (e.g. 311XXXXXX, your student number) and contain the code that satisfies the abovementioned requirements.

Moreover, please submit the URL of your PR to E3. Your submission will only be accepted when you present at both places.
22 changes: 22 additions & 0 deletions lab4/main_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const puppeteer = require('puppeteer');

(async () => {
// Launch the browser and open a new blank page
const browser = await puppeteer.launch();
const page = await browser.newPage();

// Navigate the page to a URL
await page.goto('https://pptr.dev/');

// Hints:
// Click search button
// Type into search box
// Wait for search result
// Get the `Docs` result section
// Click on first result in `Docs` section
// Locate the title
// Print the title

// Close the browser
await browser.close();
})();
Loading
Loading