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

Development: Improve and simplify local playwright setup #9796

Merged
merged 30 commits into from
Dec 10, 2024

Conversation

SimonEntholzer
Copy link
Contributor

@SimonEntholzer SimonEntholzer commented Nov 16, 2024

Checklist

General

Motivation and Context

Setting up playwright initially is quite cumbersome, as several steps need to be followed before it can be used.

Description

This PR simplifies the setup by providing three simple scripts, the user can execute to run playwright fast.

Steps for Testing

  1. Locally, checkout this branch. (checkout feature/playwright/simplify-setup)
  2. See the README.md in supporting_scripts/playwright
  3. Follow the steps, and verify that the steps are easy to follow, and you can run playwright tests in the UI.

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1 on linux (ubuntu/debian, other distros might not work)
  • Test 2 on macOS
  • Test 3 on macOS

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced documentation for Playwright setup, including a streamlined three-step process.
    • New scripts for automating user setup and running Artemis in Docker on both macOS and Linux.
    • Introduced a new script for installing and launching Playwright.
  • Improvements

    • Simplified username and password template configuration.
    • Added timeout configuration options for better test execution control.
    • Updated installation command for Playwright to reflect changes in the setup process.
  • Documentation

    • Added a README file for clearer instructions on setting up Playwright with Artemis.

@github-actions github-actions bot added tests documentation config-change Pull requests that change the config in a way that they require a deployment via Ansible. playwright labels Nov 16, 2024
@github-actions github-actions bot removed the docker label Nov 16, 2024
Copy link

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

@github-actions github-actions bot added the stale label Nov 25, 2024
@SimonEntholzer SimonEntholzer marked this pull request as ready for review December 4, 2024 19:00
@SimonEntholzer SimonEntholzer requested a review from a team as a code owner December 4, 2024 19:00
@SimonEntholzer SimonEntholzer changed the title changed playwright setup Development: Improve and simplify local playwright setup Dec 4, 2024
Copy link

coderabbitai bot commented Dec 4, 2024

Warning

Rate limit exceeded

@SimonEntholzer has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 5 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4a91a81 and 842dbaf.

📒 Files selected for processing (1)
  • supporting_scripts/playwright/startPlaywright.sh (1 hunks)

Walkthrough

The pull request introduces updates to the Playwright setup documentation and scripts. Key changes include a revised docs/dev/playwright.rst document that clarifies prerequisites and provides a streamlined three-step setup process. New scripts for user setup and Docker execution on different operating systems are added, alongside modifications to environment variable templates. The package.json file is updated with new scripts for local setup. Overall, these changes enhance the usability and clarity of the Playwright testing environment.

Changes

File Path Change Summary
docs/dev/playwright.rst Updated to clarify prerequisites, streamline setup process, and modify timeout configurations.
src/test/playwright/package.json Added new scripts playwright:setup-local and playwright:init for installing Playwright.
src/test/playwright/playwright.env Updated environment variables PLAYWRIGHT_USERNAME_TEMPLATE and PLAYWRIGHT_PASSWORD_TEMPLATE to remove USERID suffix.
supporting_scripts/playwright/README.md New documentation added outlining a three-step process for setting up and running Playwright.
supporting_scripts/playwright/runArtemisInDocker_linux.sh New script to automate Artemis setup in Docker for Linux.
supporting_scripts/playwright/runArtemisInDocker_macOS.sh New script to automate Artemis setup in Docker for macOS.
supporting_scripts/playwright/setupUsers.sh New script to automate user creation process.
supporting_scripts/playwright/startPlaywright.sh New script to automate installation and launching of Playwright.

Possibly related PRs

Suggested labels

ready to merge, docker, chore

Suggested reviewers

  • florian-glombik
  • az108
  • krusche

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Outside diff range and nitpick comments (8)
supporting_scripts/playwright/setupUsers.sh (1)

1-1: Use more specific shebang for Python environment

Since this script manages Python virtual environments, it's better to use bash explicitly.

-#!/bin/sh
+#!/bin/bash
supporting_scripts/playwright/runArtemisInDocker_linux.sh (2)

20-21: Create backup when modifying Docker Compose file

The sed command should create a backup file when modifying the Docker Compose configuration.

-sed -i "s/999/$(getent group docker | cut -d: -f3)/g" artemis-dev-local-vc-local-ci-mysql.yml
+sed -i.bak "s/999/$(getent group docker | cut -d: -f3)/g" artemis-dev-local-vc-local-ci-mysql.yml

1-31: Consider adding cleanup functionality

The script should handle cleanup of resources on failure or interruption.

Consider adding a trap for cleanup:

+cleanup() {
+    echo "Cleaning up..."
+    cd docker && docker compose -f artemis-dev-local-vc-local-ci-mysql.yml down
+    exit 1
+}
+
+trap cleanup INT TERM
supporting_scripts/playwright/runArtemisInDocker_macOS.sh (1)

34-37: Add npm and node version validation

The script should verify that the required versions of npm and node are installed before proceeding with npm operations.

Add these checks before npm operations:

+# Check for required node version
+required_node_version="16.0.0"
+if ! command -v node >/dev/null 2>&1; then
+    echo "Error: node is not installed" >&2
+    exit 1
+fi
+if ! node -v | grep -q "v$required_node_version"; then
+    echo "Error: node version $required_node_version or higher is required" >&2
+    exit 1
+fi
+
 echo "Installing Artemis npm dependencies and start Artemis client"
 npm install
 npm run start
supporting_scripts/playwright/README.md (2)

14-14: Fix grammatical issues

There are two grammatical issues in the text:

  1. Line 14: "you are be able" should be "you are able"
  2. Line 20: "it's" should be "its" (possessive form)

Apply these corrections:

-After this step, you are be able to access Artemis locally as you usually would be.
+After this step, you are able to access Artemis locally as you usually would be.
-Playwright needs users for it's tests.
+Playwright needs users for its tests.

Also applies to: 20-20

🧰 Tools
🪛 LanguageTool

[grammar] ~14-~14: Consider using either the present participle “are being” here.
Context: ...he client via npm. After this step, you are be able to access Artemis locally as you u...

(BEEN_PART_AGREEMENT)


1-27: Enhance documentation with prerequisites and troubleshooting

While the documentation is well-structured, it would benefit from additional sections covering prerequisites and common issues.

Consider adding these sections:

# Prerequisites
- Docker Desktop installed and running
- Node.js version 16.0.0 or higher
- npm version 8.0.0 or higher
- At least 4GB of free RAM
- At least 10GB of free disk space

# Troubleshooting
## Common Issues
1. Docker fails to start
   - Ensure Docker Desktop is running
   - Check system resources
   
2. npm install fails
   - Clear npm cache: `npm cache clean --force`
   - Delete node_modules and package-lock.json
   
3. Playwright tests fail
   - Verify all users are created successfully
   - Check Artemis server logs for errors
🧰 Tools
🪛 LanguageTool

[grammar] ~14-~14: Consider using either the present participle “are being” here.
Context: ...he client via npm. After this step, you are be able to access Artemis locally as you u...

(BEEN_PART_AGREEMENT)


[uncategorized] ~20-~20: Did you mean “its” (the possessive pronoun)?
Context: ...Setup users Playwright needs users for it's tests. If you do not have users set up,...

(ITS_PREMIUM)

docs/dev/playwright.rst (2)

43-44: Document the rationale for timeout values

New timeout configurations have been added:

  • FAST_TEST_TIMEOUT_SECONDS=45
  • SLOW_TEST_TIMEOUT_SECONDS=180

Consider adding a comment explaining:

  • What determines a "fast" vs "slow" test
  • Why these specific values were chosen
  • Which types of tests should use which timeout

52-62: Enhance user setup documentation

The user setup section needs several improvements:

  1. Add example output or expected results from running setupUsers.sh
  2. Explain what roles/permissions the generated users will have
  3. Clarify the limitation regarding the template string changes

Consider adding this content:

 setupUsers.sh

+The script will generate the following test users:
+- artemis_test_user_1 (student role)
+- artemis_test_user_2 (tutor role)
+...
+
+Note: The script currently only supports the default template format due to [specific reason].
+If you need custom usernames, please modify the script accordingly.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0f12a54 and 7973c1f.

⛔ Files ignored due to path filters (1)
  • src/main/resources/config/application-local-template.yml is excluded by !**/*.yml
📒 Files selected for processing (10)
  • docker/artemis/config/dev-local-vc-local-ci.env (1 hunks)
  • docs/dev/playwright.rst (1 hunks)
  • src/test/playwright/init/ImportUsers.spec.ts (0 hunks)
  • src/test/playwright/package.json (1 hunks)
  • src/test/playwright/playwright.env (1 hunks)
  • supporting_scripts/playwright/README.md (1 hunks)
  • supporting_scripts/playwright/runArtemisInDocker_linux.sh (1 hunks)
  • supporting_scripts/playwright/runArtemisInDocker_macOS.sh (1 hunks)
  • supporting_scripts/playwright/setupUsers.sh (1 hunks)
  • supporting_scripts/playwright/startPlaywright.sh (1 hunks)
💤 Files with no reviewable changes (1)
  • src/test/playwright/init/ImportUsers.spec.ts
✅ Files skipped from review due to trivial changes (2)
  • src/test/playwright/playwright.env
  • supporting_scripts/playwright/startPlaywright.sh
🧰 Additional context used
🪛 Shellcheck (0.10.0)
supporting_scripts/playwright/setupUsers.sh

[warning] 13-13: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🪛 LanguageTool
supporting_scripts/playwright/README.md

[grammar] ~14-~14: Consider using either the present participle “are being” here.
Context: ...he client via npm. After this step, you are be able to access Artemis locally as you u...

(BEEN_PART_AGREEMENT)


[uncategorized] ~20-~20: Did you mean “its” (the possessive pronoun)?
Context: ...Setup users Playwright needs users for it's tests. If you do not have users set up,...

(ITS_PREMIUM)

🔇 Additional comments (3)
docker/artemis/config/dev-local-vc-local-ci.env (1)

5-5: Verify the impact of adding the 'local' profile

The addition of the 'local' profile to SPRING_PROFILES_ACTIVE might affect Spring configuration loading order and override behavior.

✅ Verification successful

Let me gather more specific information about the local profile usage.


Adding 'local' profile is consistent with existing configuration

The 'local' profile addition is safe and aligns with the existing development setup:

  • The application already uses multiple local-related profiles (localci, localvc) with well-defined configurations
  • Found application-local configuration files contain development-specific settings
  • Java classes using @Profile("local") are primarily test and development-focused services
  • Profile ordering in SPRING_PROFILES_ACTIVE follows the standard pattern with development profiles at the end
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any local profile configurations that might conflict
rg -l "application-local\." --glob '!*.env'

# Search for profile-specific beans or configurations
ast-grep --pattern 'class $_ {
  $$$
  @Profile("local")
  $$$
}'

Length of output: 721


Script:

#!/bin/bash
# Check content of application-local properties/yml files
fd -e yml -e yaml -e properties 'application-local' -x cat {}

# Search for local profile references in configuration files
rg -A 3 '"local"' --type yaml --type properties

# Search for Spring configuration classes with local profile
rg -l '@Profile.*local' --type java

Length of output: 4840

docs/dev/playwright.rst (2)

32-33: Verify template changes across the codebase

The username and password templates have been simplified by removing the USERID suffix. This change needs to be consistent with the actual implementation.

✅ Verification successful

Template changes in documentation match the implementation

The documentation accurately reflects the current implementation:

  • The environment file (playwright.env) uses the same template format: artemis_test_user_
  • The implementation in users.ts correctly uses these environment variables with fallback values
  • The templates are used as prefixes and combined with a user ID selector in the actual code
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the template changes are consistent across the codebase

# Check the actual environment file
rg "PLAYWRIGHT_USERNAME_TEMPLATE|PLAYWRIGHT_PASSWORD_TEMPLATE" src/test/playwright/playwright.env

# Check for any hardcoded references to the old format
rg "artemis_test_user_\d+" src/test/playwright/

Length of output: 245


Script:

#!/bin/bash
# Let's check for any test files or configuration that might be using these templates
rg -A 2 "PLAYWRIGHT_USERNAME_TEMPLATE|PLAYWRIGHT_PASSWORD_TEMPLATE" src/test/playwright/

# Also check for any dynamic user generation or related patterns
rg -A 2 "generateUser|createUser|setupUser" src/test/playwright/

Length of output: 1263


66-67: 🛠️ Refactor suggestion

Improve OS-specific installation instructions

The documentation mentions potential OS-specific installation issues but doesn't provide details.

Please add:

  1. List of affected operating systems
  2. Package manager commands for manual installation
  3. Troubleshooting steps for common installation issues

Example addition:

 npm run playwright:install

+Known OS-specific requirements:
+- Ubuntu/Debian: Additional dependencies needed (libwebkit2gtk-4.0-dev, etc.)
+- macOS: No additional steps required
+- Windows: May require Microsoft Visual C++ Redistributable

Also applies to: 71-72

✅ Verification successful

Based on the search results, I can see that the project uses cross-platform tools like cross-env and has Docker-based test infrastructure, but there's no explicit documentation about OS-specific installation requirements for Playwright. Let me check the package.json and any setup scripts to understand the installation process better.


Let me check if there are any specific OS-related dependencies or requirements mentioned in the Playwright documentation or configuration files.


Based on the search results and package.json content, I can now generate a final response. The playwright:install command uses npx playwright install --with-deps chromium which includes system dependencies, and there's evidence of cross-platform support through cross-env usage.

Add specific OS installation instructions

Please add the following OS-specific details to the documentation:

  • Ubuntu/Debian:
 npm run playwright:install

+## Operating System Requirements
+
+### Ubuntu/Debian
+```bash
+# Install system dependencies
+sudo apt-get update
+sudo apt-get install -y libwebkit2gtk-4.0-0 libgtk-3-0 libgbm1
+```
+
+### Windows
+- No additional system dependencies required
+- Ensure Microsoft Visual C++ Redistributable is installed (usually present by default)
+
+### macOS
+- No additional system dependencies required
+
+## Troubleshooting
+If the automatic installation fails:
+1. Check system requirements above for your OS
+2. Run `npx playwright install-deps chromium` to install dependencies separately
+3. Run `npx playwright install chromium` to install browser binaries
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the npm command exists in package.json

# Check if the command exists in package.json
rg '"playwright:install"' src/test/playwright/package.json

Length of output: 137


Script:

#!/bin/bash
# Let's check the Playwright documentation and test files for OS-specific information
rg -i "os|linux|ubuntu|debian|windows|macos" docs/dev/playwright.rst

# Check test files for OS-specific configurations or imports
rg -i "os|platform|process\.platform" src/test/playwright/ -A 2

# Look for any existing troubleshooting or installation guides
fd README.md src/test/playwright/ -x cat {}

Length of output: 67193


Script:

#!/bin/bash
# Check package.json for installation scripts and dependencies
cat src/test/playwright/package.json

# Look for any setup or installation scripts
fd -e sh -e bash setup install src/test/playwright/

# Check for any documentation about installation
rg -i "install|setup|prerequisite" docs/dev/playwright.rst

Length of output: 2380


Script:

#!/bin/bash
# Check Playwright's config and environment files
cat src/test/playwright/playwright.config.ts
cat src/test/playwright/playwright.env

# Look for any OS-specific dependencies in the documentation
rg -i "linux|ubuntu|debian|windows|macos|dependencies" docs/dev/ -A 2

Length of output: 96623

supporting_scripts/playwright/setupUsers.sh Show resolved Hide resolved
supporting_scripts/playwright/setupUsers.sh Outdated Show resolved Hide resolved
supporting_scripts/playwright/runArtemisInDocker_linux.sh Outdated Show resolved Hide resolved
supporting_scripts/playwright/runArtemisInDocker_macOS.sh Outdated Show resolved Hide resolved
src/test/playwright/package.json Outdated Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 4, 2024
az108
az108 previously approved these changes Dec 4, 2024
Copy link
Contributor

@az108 az108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it locally, was able to install playwright and run the tests successfully 👍

@github-actions github-actions bot removed the stale label Dec 5, 2024
muradium
muradium previously approved these changes Dec 10, 2024
Copy link
Contributor

@muradium muradium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. Supporting scripts also work as expected 👍

@muradium
Copy link
Contributor

Left a small comment. Also I added this branch manually to bamboo, as it wasn't created for some reason 😅

Copy link
Contributor

@magaupp magaupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scripts would be more comfortable to use if they work regardless of the current working directory.

The target of the cd commands can be made more obvious if they use paths relative to Artemis' root directory.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (6)
supporting_scripts/playwright/README.md (5)

12-12: Fix grammar in the sentence

The sentence contains a grammatical error.

-After this step, you are be able to access Artemis locally as you usually would be.
+After this step, you will be able to access Artemis locally as you usually would be.
🧰 Tools
🪛 LanguageTool

[grammar] ~12-~12: Consider using either the present participle “are being” here.
Context: ...he client via npm. After this step, you are be able to access Artemis locally as you u...

(BEEN_PART_AGREEMENT)


10-11: Consider adding supported OS version information

To prevent potential compatibility issues, it would be helpful to specify which OS versions are supported for both macOS and Linux scripts.


18-18: Fix possessive pronoun usage

The word "it's" (contraction of "it is") should be "its" (possessive pronoun).

-Playwright needs users for it's tests.
+Playwright needs users for its tests.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~18-~18: Did you mean “its” (the possessive pronoun)?
Context: ...Setup users Playwright needs users for it's tests. If you do not have users set up,...

(ITS_PREMIUM)


18-20: Add information about prerequisites

The section should mention any prerequisites required for running the setupUsers.sh script (e.g., Python environment setup).

🧰 Tools
🪛 LanguageTool

[uncategorized] ~18-~18: Did you mean “its” (the possessive pronoun)?
Context: ...Setup users Playwright needs users for it's tests. If you do not have users set up,...

(ITS_PREMIUM)


24-25: Enhance setup instructions clarity

Consider adding:

  1. An explanation of what "UI mode" means and its benefits
  2. The exact location where these scripts can be found
  3. The expected outcome when running in UI mode
supporting_scripts/playwright/setupUsers.sh (1)

1-5: Enhance script robustness and documentation

Consider adding these improvements:

  1. Additional error handling flags
  2. Script description and usage instructions
 #!/bin/sh
 
-# We use the supporting scripts to create users
+# Script: setupUsers.sh
+# Description: Creates test users for Artemis Playwright testing environment
+# Usage: ./setupUsers.sh
 
-set -e
+set -euo pipefail
+
+# Ensure script is sourced from the correct location
+if [ "$(basename "$0")" = "setupUsers.sh" ]; then
+    cd "$(dirname "$0")" || exit 1
+fi
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 35031ca and 4a91a81.

📒 Files selected for processing (4)
  • supporting_scripts/playwright/README.md (1 hunks)
  • supporting_scripts/playwright/runArtemisInDocker_linux.sh (1 hunks)
  • supporting_scripts/playwright/runArtemisInDocker_macOS.sh (1 hunks)
  • supporting_scripts/playwright/setupUsers.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • supporting_scripts/playwright/runArtemisInDocker_macOS.sh
  • supporting_scripts/playwright/runArtemisInDocker_linux.sh
🧰 Additional context used
🪛 LanguageTool
supporting_scripts/playwright/README.md

[grammar] ~12-~12: Consider using either the present participle “are being” here.
Context: ...he client via npm. After this step, you are be able to access Artemis locally as you u...

(BEEN_PART_AGREEMENT)


[uncategorized] ~18-~18: Did you mean “its” (the possessive pronoun)?
Context: ...Setup users Playwright needs users for it's tests. If you do not have users set up,...

(ITS_PREMIUM)

🪛 Shellcheck (0.10.0)
supporting_scripts/playwright/setupUsers.sh

[warning] 14-14: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🔇 Additional comments (5)
supporting_scripts/playwright/README.md (2)

1-7: LGTM!

The introduction provides a clear and concise overview of the setup process.


10-10: Verify the existence of referenced scripts

Let's ensure all referenced scripts exist in the repository.

Also applies to: 19-19, 24-24

✅ Verification successful

All referenced scripts are present in the repository

All shell scripts mentioned in the README.md (runArtemisInDocker_macOS.sh, runArtemisInDocker_linux.sh, setupUsers.sh, and startPlaywright.sh) exist in the supporting_scripts/playwright/ directory.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of all referenced scripts

echo "Checking for referenced scripts..."
for script in "runArtemisInDocker_macOS.sh" "runArtemisInDocker_linux.sh" "setupUsers.sh" "startPlaywright.sh"; do
  if fd "$script" .; then
    echo "✓ Found: $script"
  else
    echo "✗ Missing: $script"
  fi
done

Length of output: 1150

supporting_scripts/playwright/setupUsers.sh (3)

10-14: Replace 'source' with POSIX-compliant '.' command

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 14-14: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)


1-19: Verify script integration with Playwright setup

Let's verify how this script integrates with other Playwright setup scripts.

✅ Verification successful

Script is properly integrated with Playwright setup

The script is correctly integrated into the Playwright testing workflow as evidenced by:

  • It's documented in docs/dev/playwright.rst as a required step (Step 3) for configuring test users before running Playwright tests
  • Works in conjunction with other scripts in the supporting_scripts/playwright directory:
    • runArtemisInDocker_linux.sh/runArtemisInDocker_macOS.sh set up the Docker environment
    • setupUsers.sh creates the required test users
    • startPlaywright.sh handles the Playwright installation and execution
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for related setup scripts and their execution order
echo "Checking for related Playwright setup scripts..."
fd -t f -e sh . supporting_scripts/playwright

# Check if this script is referenced in documentation
echo -e "\nChecking for script references in documentation..."
rg -l "setupUsers.sh" docs/

Length of output: 532


Script:

#!/bin/bash
# Check the content of the Playwright documentation
echo "Checking Playwright documentation..."
cat docs/dev/playwright.rst

# Check the content of related Playwright scripts
echo -e "\nChecking startPlaywright.sh..."
cat supporting_scripts/playwright/startPlaywright.sh

echo -e "\nChecking Docker setup scripts..."
cat supporting_scripts/playwright/runArtemisInDocker_linux.sh
cat supporting_scripts/playwright/runArtemisInDocker_macOS.sh

Length of output: 11924

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 14-14: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)


16-19: 🛠️ Refactor suggestion

Add error handling and success verification

The script should verify successful execution of critical commands and provide meaningful error messages.

-cd "$artemis_path/supporting_scripts/course-scripts/quick-course-setup"
+cd "$artemis_path/supporting_scripts/course-scripts/quick-course-setup" || {
+    echo "Error: Failed to change to quick-course-setup directory" >&2
+    exit 1
+}
 
-python3 -m pip install -r requirements.txt
-python3 create_users.py
+if [ ! -f "requirements.txt" ]; then
+    echo "Error: requirements.txt not found" >&2
+    exit 1
+fi
+
+echo "Installing dependencies..."
+if ! python3 -m pip install -r requirements.txt; then
+    echo "Error: Failed to install requirements" >&2
+    exit 1
+fi
+
+echo "Creating users..."
+if ! python3 create_users.py; then
+    echo "Error: Failed to create users" >&2
+    exit 1
+fi
+
+echo "Successfully created users"

Likely invalid or redundant comment.

supporting_scripts/playwright/setupUsers.sh Show resolved Hide resolved
supporting_scripts/playwright/setupUsers.sh Show resolved Hide resolved
Copy link
Contributor

@magaupp magaupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. Code looks good 👍

Copy link
Contributor

@muradium muradium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reapprove after changes

@bassner bassner added this to the 7.7.5 milestone Dec 10, 2024
@bassner bassner merged commit 47da721 into develop Dec 10, 2024
25 of 29 checks passed
@bassner bassner deleted the feature/playwright/simplify-setup branch December 10, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants