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

Feature/playwright/simplify setup 2 #9961

Closed
wants to merge 20 commits into from

Conversation

SimonEntholzer
Copy link
Contributor

@SimonEntholzer SimonEntholzer commented Dec 6, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).
  • I tested all changes and their related features with all corresponding user types on a test server configured with Gitlab and Jenkins.

Motivation and Context

Description

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Programming Exercise with Complaints enabled
  1. Log in to Artemis
  2. Navigate to Course Administration
  3. ...

Exam Mode Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Exam with a Programming Exercise
  1. Log in to Artemis
  2. Participate in the exam as a student
  3. Make sure that the UI of the programming exercise in the exam mode stays unchanged. You can use the exam mode documentation as reference.
  4. ...

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2

Test Coverage

Screenshots

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced streamlined scripts for setting up and running Playwright tests in Docker for both macOS and Linux.
    • Added a new README file with clear setup instructions for running Playwright locally.
    • New user creation script to automate user setup for testing.
  • Improvements

    • Enhanced documentation for Playwright test setup, including prerequisites and installation steps.
    • Updated environment configuration for Playwright to simplify username and password templates.
  • Bug Fixes

    • Removed deprecated user creation logic from the Playwright testing environment.

Copy link

coderabbitai bot commented Dec 6, 2024

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • src/test/playwright/init/importUsers.spec.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces several changes, primarily focusing on the configuration and setup of Playwright for testing within a Dockerized Artemis environment. Key modifications include updates to environment variables in configuration files, enhancements to documentation for local Playwright setup, and the addition of various shell scripts to streamline the setup process. Notably, a test suite for user importation has been removed, and the Playwright installation process has been simplified by modifying scripts in the package.json.

Changes

File Path Change Summary
docker/artemis/config/dev-local-vc-local-ci.env Updated SPRING_PROFILES_ACTIVE to include the local profile.
docs/dev/playwright.rst Enhanced setup instructions for Playwright, added prerequisites, new streamlined setup process, and updated configuration details.
src/test/playwright/ImportUsers.spec.ts Deleted test suite for user setup in Playwright testing environment.
src/test/playwright/package.json Removed playwright:setup script; added playwright:install script for simplified Playwright installation.
src/test/playwright/playwright.env Updated username/password templates and removed CREATE_USERS variable.
supporting_scripts/playwright/README.md Added new README file outlining a three-step process for running Playwright locally.
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 within a Python virtual environment.
supporting_scripts/playwright/startPlaywright.sh New script to automate the setup and execution of Playwright for testing.

Possibly related PRs

Suggested labels

chore, documentation, docker, tests, ready to merge

Suggested reviewers

  • az108
  • sarpsahinalp
  • egekurt123

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 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: 12

🧹 Outside diff range and nitpick comments (5)
supporting_scripts/playwright/runArtemisInDocker_macOS.sh (1)

1-26: Consider architectural improvements for better maintainability

The script would benefit from the following architectural improvements:

  1. Split the script into smaller, focused scripts (e.g., separate Docker setup from npm setup)
  2. Add a proper logging mechanism
  3. Make the script configurable through environment variables
  4. Add a usage/help message

Example structure:

# Configuration
ARTEMIS_DOCKER_DIR="${ARTEMIS_DOCKER_DIR:-docker}"
COMPOSE_FILE="${COMPOSE_FILE:-artemis-dev-local-vc-local-ci-mysql.yml}"
LOG_LEVEL="${LOG_LEVEL:-INFO}"

# Logging function
log() {
    local level=$1
    shift
    if [[ $LOG_LEVEL == "DEBUG" || $level != "DEBUG" ]]; then
        echo "[$level] $@"
    fi
}

# Usage function
usage() {
    echo "Usage: $0 [-h] [-d directory] [-f compose-file] [-l log-level]"
    echo "Options:"
    echo "  -h            Show this help message"
    echo "  -d directory  Docker directory (default: docker)"
    echo "  -f file       Docker compose file (default: artemis-dev-local-vc-local-ci-mysql.yml)"
    echo "  -l level      Log level: DEBUG, INFO, ERROR (default: INFO)"
    exit 1
}
supporting_scripts/playwright/README.md (2)

14-14: Fix grammatical error in sentence

Change "you are be able" to "you will be able"

-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] ~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)


20-20: Fix possessive pronoun usage

Change "it's" to "its" (possessive form)

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

[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)

55-56: Document the purpose of timeout variables

The new timeout variables FAST_TEST_TIMEOUT_SECONDS and SLOW_TEST_TIMEOUT_SECONDS are added but their purpose and recommended values aren't explained.

Consider adding a brief explanation of when these timeouts are used and how to determine appropriate values.


64-74: Consider documenting user naming constraints

While the documentation mentions that changing the template string is discouraged, it would be helpful to explain why and what the current limitations are.

Consider adding:

  1. The expected format of usernames
  2. Why changing the template is discouraged
  3. Future plans for supporting custom naming patterns
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8036d43 and 7ef9160.

📒 Files selected for processing (10)
  • docker/artemis/config/dev-local-vc-local-ci.env (1 hunks)
  • docs/dev/playwright.rst (2 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 (1)
  • src/test/playwright/playwright.env
🧰 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 (4)
docker/artemis/config/dev-local-vc-local-ci.env (2)

5-5: LGTM - Profile addition aligns with Playwright setup simplification

The addition of the 'local' profile to SPRING_PROFILES_ACTIVE is consistent with the PR's objective of simplifying the Playwright setup. This change maintains the existing development environment configuration while adding the necessary profile for local testing.


5-5: Verify documentation for the 'local' profile addition

The addition of the 'local' profile to SPRING_PROFILES_ACTIVE should be documented in the setup instructions.

✅ Verification successful

Documentation for 'local' profile is properly maintained

The 'local' profile addition is well documented across multiple setup files:

  • Found in production setup tips
  • Present in setup instructions for various components (Iris, Apollon, Athena, Aeolus)
  • Documented in integrated code lifecycle setup
  • Included in the main README.md's application startup command
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the profile addition is documented in setup instructions
rg -i "spring.*profiles.*local" docs/
# Check README for any profile-related setup instructions
cat README.md | grep -i "profile" -A 5 -B 5

Length of output: 2967

supporting_scripts/playwright/README.md (1)

12-12: Verify referenced shell scripts exist

The README references several shell scripts. Let's verify their existence and permissions.

Also applies to: 26-27

✅ Verification successful

Let me verify if these scripts exist in the correct directory since the file under review is in supporting_scripts/playwright/README.md.


All referenced shell scripts exist and have correct executable permissions

All the shell scripts mentioned in the README (runArtemisInDocker_macOS.sh, runArtemisInDocker_linux.sh, setupUsers.sh, and startPlaywright.sh) exist in the correct directory and have the proper executable permissions (755).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if all referenced scripts exist and are executable
for script in runArtemisInDocker_macOS.sh runArtemisInDocker_linux.sh setupUsers.sh startPlaywright.sh; do
  if [ -f "$script" ]; then
    echo "Found $script"
    ls -l "$script"
  else
    echo "Missing $script"
  fi
done

Length of output: 838


Script:

#!/bin/bash
cd supporting_scripts/playwright
# Check if all referenced scripts exist and are executable
for script in runArtemisInDocker_macOS.sh runArtemisInDocker_linux.sh setupUsers.sh startPlaywright.sh; do
  if [ -f "$script" ]; then
    echo "Found $script"
    ls -l "$script"
  else
    echo "Missing $script"
  fi
done

Length of output: 1259

docs/dev/playwright.rst (1)

83-83: Verify npm script reference

The documentation now correctly references the new playwright:install command, aligning with the package.json changes.

Let's verify the command works as expected:

✅ Verification successful

Playwright install script reference is correctly documented

The playwright:install script is properly defined in the package.json file with the command npx playwright install --with-deps chromium, which matches the documentation's reference to npm run playwright:install.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the playwright:install script is properly defined in package.json
cd src/test/playwright && jq -r '.scripts["playwright:install"]' package.json

Length of output: 122

Comment on lines +1 to +3
#!/bin/sh

set -e
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance shell configuration for better error handling

Consider these improvements for more robust script execution:

  1. Use /bin/bash instead of /bin/sh for better feature support
  2. Add -u flag to catch undefined variables
-#!/bin/sh
+#!/bin/bash
 
-set -e
+set -eu
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/sh
set -e
#!/bin/bash
set -eu

Comment on lines +5 to +8
cd ../..

cd docker
open -a Docker
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve directory navigation and Docker startup reliability

The current implementation has several potential issues:

  1. Relative path navigation is fragile and depends on script location
  2. No verification if Docker is already running
  3. No wait for Docker to be ready before proceeding
-cd ../..
-cd docker
+# Get the repository root directory
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+REPO_ROOT="$( cd "$SCRIPT_DIR/../.." && pwd )"
+cd "$REPO_ROOT/docker"
 
+# Check if Docker is already running
+if ! docker info > /dev/null 2>&1; then
 open -a Docker
+  # Wait for Docker to be ready
+  echo "Waiting for Docker to start..."
+  while ! docker info > /dev/null 2>&1; do
+    sleep 1
+  done
+fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cd ../..
cd docker
open -a Docker
# Get the repository root directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPO_ROOT="$( cd "$SCRIPT_DIR/../.." && pwd )"
cd "$REPO_ROOT/docker"
# Check if Docker is already running
if ! docker info > /dev/null 2>&1; then
open -a Docker
# Wait for Docker to be ready
echo "Waiting for Docker to start..."
while ! docker info > /dev/null 2>&1; do
sleep 1
done
fi

Comment on lines +18 to +19
docker compose -f artemis-dev-local-vc-local-ci-mysql.yml up -d
echo "Finished docker compose"
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add service health checks after Docker compose

The script should verify that all services are running correctly before proceeding.

 docker compose -f artemis-dev-local-vc-local-ci-mysql.yml up -d
-echo "Finished docker compose"
+echo "Waiting for services to be healthy..."
+
+# Function to check service health
+check_service() {
+    local service=$1
+    local max_attempts=30
+    local attempt=1
+    
+    while [ $attempt -le $max_attempts ]; do
+        if docker compose ps $service | grep -q "running"; then
+            return 0
+        fi
+        echo "Waiting for $service to start (attempt $attempt/$max_attempts)..."
+        sleep 2
+        attempt=$((attempt + 1))
+    done
+    return 1
+}
+
+# Add checks for each critical service
+for service in artemis-mysql artemis-server; do
+    if ! check_service $service; then
+        echo "Error: Service $service failed to start"
+        exit 1
+    fi
+done
+
+echo "All services are running"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docker compose -f artemis-dev-local-vc-local-ci-mysql.yml up -d
echo "Finished docker compose"
docker compose -f artemis-dev-local-vc-local-ci-mysql.yml up -d
echo "Waiting for services to be healthy..."
# Function to check service health
check_service() {
local service=$1
local max_attempts=30
local attempt=1
while [ $attempt -le $max_attempts ]; do
if docker compose ps $service | grep -q "running"; then
return 0
fi
echo "Waiting for $service to start (attempt $attempt/$max_attempts)..."
sleep 2
attempt=$((attempt + 1))
done
return 1
}
# Add checks for each critical service
for service in artemis-mysql artemis-server; do
if ! check_service $service; then
echo "Error: Service $service failed to start"
exit 1
fi
done
echo "All services are running"

Comment on lines +23 to +26
echo "Installing Artemis npm dependencies and start Artemis client"

npm install
npm run start
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance npm setup with version checks and error handling

Add proper version checks and error handling for npm operations.

+# Check npm version
+required_npm_version="8.0.0"
+current_npm_version=$(npm -v)
+if ! command -v npm >/dev/null 2>&1; then
+    echo "Error: npm is not installed"
+    exit 1
+fi
+
+if [ "$(printf '%s\n' "$required_npm_version" "$current_npm_version" | sort -V | head -n1)" != "$required_npm_version" ]; then
+    echo "Error: npm version $required_npm_version or higher is required"
+    exit 1
+fi
+
 echo "Installing Artemis npm dependencies and start Artemis client"
 
-npm install
-npm run start
+# Cleanup function
+cleanup() {
+    echo "Cleaning up..."
+    docker compose -f docker/artemis-dev-local-vc-local-ci-mysql.yml down
+    exit 1
+}
+
+# Set up trap for script interruption
+trap cleanup INT TERM
+
+# Run npm commands with error handling
+if ! npm install; then
+    echo "Error: npm install failed"
+    cleanup
+fi
+
+if ! npm run start; then
+    echo "Error: npm start failed"
+    cleanup
+fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "Installing Artemis npm dependencies and start Artemis client"
npm install
npm run start
# Check npm version
required_npm_version="8.0.0"
current_npm_version=$(npm -v)
if ! command -v npm >/dev/null 2>&1; then
echo "Error: npm is not installed"
exit 1
fi
if [ "$(printf '%s\n' "$required_npm_version" "$current_npm_version" | sort -V | head -n1)" != "$required_npm_version" ]; then
echo "Error: npm version $required_npm_version or higher is required"
exit 1
fi
echo "Installing Artemis npm dependencies and start Artemis client"
# Cleanup function
cleanup() {
echo "Cleaning up..."
docker compose -f docker/artemis-dev-local-vc-local-ci-mysql.yml down
exit 1
}
# Set up trap for script interruption
trap cleanup INT TERM
# Run npm commands with error handling
if ! npm install; then
echo "Error: npm install failed"
cleanup
fi
if ! npm run start; then
echo "Error: npm start failed"
cleanup
fi

Comment on lines +10 to +16
echo "Updating docker group ID in the docker compose file"
PRIMARY_GROUP_ID=$(dscl . -read /Groups/docker PrimaryGroupID | awk '{print $2}')
if [ -n "$PRIMARY_GROUP_ID" ]; then
sed -i '' "s/999/$PRIMARY_GROUP_ID/g" artemis-dev-local-vc-local-ci-mysql.yml
else
echo "PrimaryGroupID not found, skipping replacement"
fi
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add safety measures for Docker compose file modification

The current implementation lacks several safety checks:

  1. No backup of the compose file before modification
  2. No validation of the group ID format
  3. No check if the file exists
 echo "Updating docker group ID in the docker compose file"
+COMPOSE_FILE="artemis-dev-local-vc-local-ci-mysql.yml"
+
+# Check if compose file exists
+if [ ! -f "$COMPOSE_FILE" ]; then
+    echo "Error: Docker compose file not found: $COMPOSE_FILE"
+    exit 1
+fi
+
 PRIMARY_GROUP_ID=$(dscl . -read /Groups/docker PrimaryGroupID | awk '{print $2}')
-if [ -n "$PRIMARY_GROUP_ID" ]; then
-    sed -i '' "s/999/$PRIMARY_GROUP_ID/g" artemis-dev-local-vc-local-ci-mysql.yml
+
+# Validate group ID format
+if [[ -n "$PRIMARY_GROUP_ID" && "$PRIMARY_GROUP_ID" =~ ^[0-9]+$ ]]; then
+    # Create backup
+    cp "$COMPOSE_FILE" "${COMPOSE_FILE}.bak"
+    sed -i '' "s/999/$PRIMARY_GROUP_ID/g" "$COMPOSE_FILE"
 else
-    echo "PrimaryGroupID not found, skipping replacement"
+    echo "Error: Invalid or missing Docker group ID"
+    exit 1
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "Updating docker group ID in the docker compose file"
PRIMARY_GROUP_ID=$(dscl . -read /Groups/docker PrimaryGroupID | awk '{print $2}')
if [ -n "$PRIMARY_GROUP_ID" ]; then
sed -i '' "s/999/$PRIMARY_GROUP_ID/g" artemis-dev-local-vc-local-ci-mysql.yml
else
echo "PrimaryGroupID not found, skipping replacement"
fi
echo "Updating docker group ID in the docker compose file"
COMPOSE_FILE="artemis-dev-local-vc-local-ci-mysql.yml"
# Check if compose file exists
if [ ! -f "$COMPOSE_FILE" ]; then
echo "Error: Docker compose file not found: $COMPOSE_FILE"
exit 1
fi
PRIMARY_GROUP_ID=$(dscl . -read /Groups/docker PrimaryGroupID | awk '{print $2}')
# Validate group ID format
if [[ -n "$PRIMARY_GROUP_ID" && "$PRIMARY_GROUP_ID" =~ ^[0-9]+$ ]]; then
# Create backup
cp "$COMPOSE_FILE" "${COMPOSE_FILE}.bak"
sed -i '' "s/999/$PRIMARY_GROUP_ID/g" "$COMPOSE_FILE"
else
echo "Error: Invalid or missing Docker group ID"
exit 1
fi

python -m venv venv
fi

source venv/bin/activate
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace 'source' with POSIX-compatible '.' command

The 'source' command is not POSIX-compliant. Use the '.' command instead for better compatibility.

-source venv/bin/activate
+. venv/bin/activate
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
source venv/bin/activate
. venv/bin/activate
🧰 Tools
🪛 Shellcheck (0.10.0)

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

(SC3046)

Comment on lines +7 to +18
cd ..

if [ ! -d "venv" ]; then
python -m venv venv
fi

source venv/bin/activate

cd course-scripts/quick-course-setup

python3 -m pip install -r requirements.txt
python3 create_users.py
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add robust error handling and environment checks

The script needs better error handling and environment validation.

 set -e
 
-cd ..
+# Get the absolute path to the project root
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+cd "$SCRIPT_DIR/.."
+
+# Check Python version
+if ! command -v python3 >/dev/null 2>&1; then
+    echo "Error: Python 3 is required but not installed"
+    exit 1
+fi
+
+PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
+if [ "$(echo "$PYTHON_VERSION 3.8" | awk '{if ($1 < $2) print 1}')" = "1" ]; then
+    echo "Error: Python 3.8 or higher is required"
+    exit 1
+fi
 
 if [ ! -d "venv" ]; then
     python -m venv venv
 fi
 
-source venv/bin/activate
+. venv/bin/activate
 
-cd  course-scripts/quick-course-setup
+SETUP_DIR="course-scripts/quick-course-setup"
+if [ ! -d "$SETUP_DIR" ]; then
+    echo "Error: Setup directory not found at $SETUP_DIR"
+    exit 1
+fi
+cd "$SETUP_DIR"
 
-python3 -m pip install -r requirements.txt
+if [ ! -f "requirements.txt" ]; then
+    echo "Error: requirements.txt not found"
+    exit 1
+fi
+
+echo "Installing Python dependencies..."
+if ! python3 -m pip install -r requirements.txt; then
+    echo "Error: Failed to install Python dependencies"
+    exit 1
+fi
+
+echo "Creating users..."
 python3 create_users.py
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cd ..
if [ ! -d "venv" ]; then
python -m venv venv
fi
source venv/bin/activate
cd course-scripts/quick-course-setup
python3 -m pip install -r requirements.txt
python3 create_users.py
set -e
# Get the absolute path to the project root
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/.."
# Check Python version
if ! command -v python3 >/dev/null 2>&1; then
echo "Error: Python 3 is required but not installed"
exit 1
fi
PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
if [ "$(echo "$PYTHON_VERSION 3.8" | awk '{if ($1 < $2) print 1}')" = "1" ]; then
echo "Error: Python 3.8 or higher is required"
exit 1
fi
if [ ! -d "venv" ]; then
python -m venv venv
fi
. venv/bin/activate
SETUP_DIR="course-scripts/quick-course-setup"
if [ ! -d "$SETUP_DIR" ]; then
echo "Error: Setup directory not found at $SETUP_DIR"
exit 1
fi
cd "$SETUP_DIR"
if [ ! -f "requirements.txt" ]; then
echo "Error: requirements.txt not found"
exit 1
fi
echo "Installing Python dependencies..."
if ! python3 -m pip install -r requirements.txt; then
echo "Error: Failed to install Python dependencies"
exit 1
fi
echo "Creating users..."
python3 create_users.py
🧰 Tools
🪛 Shellcheck (0.10.0)

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

(SC3046)

@github-actions github-actions bot removed the docker label Dec 6, 2024
@SimonEntholzer SimonEntholzer deleted the feature/playwright/simplify-setup-2 branch December 7, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant