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

Support Drupal 11 SQLite version #13

Merged
merged 5 commits into from
Dec 5, 2024
Merged

Conversation

jhedstrom
Copy link
Member

@jhedstrom jhedstrom commented Oct 24, 2024

This is a downstream fix of docksal/service-cli#327

There's some talk of removing this version requirement in https://www.drupal.org/project/drupal/issues/3346338 but until then, this is necessary for running pre-build Drupal tests (Kernel, and Functional).

Summary by CodeRabbit

  • New Features

    • Added conditional SQLite3 installation for Drupal 11 testing support based on the PHP CLI version.
  • Chores

    • Enhanced the build script to manage PHP CLI versions and facilitate the conditional installation of SQLite during the Docker build process.

Copy link

coderabbitai bot commented Oct 24, 2024

Walkthrough

The changes in this pull request focus on updating the Dockerfile and the build.sh script to handle different versions of the PHP CLI. The primary change is the addition of a conditional installation of SQLite3 for Drupal 11 testing, which is triggered when the CLI version is 8.3 or higher.

Changes

File Change Summary
src/Dockerfile Added conditional RUN command to install SQLite3 for Drupal 11 testing if the CLI version is 8.3 or higher, including repository setup and cleanup.
build.sh Introduced a new variable CLI_VERSION that defaults to 8.3 if no version is provided as an argument. Checks the CLI version and sets a new variable INSTALL_SQLITE accordingly, which is then passed as a build argument to the docker build command.

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant Dockerfile
    participant Docker

    CLI->>Dockerfile: Provide CLI version
    Dockerfile->>Dockerfile: Check CLI version
    Dockerfile->>Dockerfile: Set INSTALL_SQLITE variable
    Dockerfile->>Docker: Build image with INSTALL_SQLITE
    Docker->>Dockerfile: Install SQLite3 if INSTALL_SQLITE is true
Loading

Poem

In the realm of code, a Dockerfile shines,
Adapting to versions, a task it defines.
SQLite, the hero, joins the fray,
For Drupal 11, a brighter day.
Rabbits rejoice, the build is complete,
A triumph of progress, a victory sweet! 🐇🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ebf092d and c3370ec.

📒 Files selected for processing (2)
  • build.sh (1 hunks)
  • src/Dockerfile (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • build.sh
  • src/Dockerfile

🪧 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

🧹 Outside diff range and nitpick comments (3)
build.sh (3)

6-7: Add version format validation

While the default version is correctly set, the script should validate the input version format to prevent invalid versions from being passed to Docker.

 CLI_VERSION=${1:-8.3}
+# Validate version format (e.g., 8.3, 7.4, etc.)
+if ! echo "$CLI_VERSION" | grep -qE '^[0-9]+\.[0-9]+$'; then
+  echo "Error: Invalid version format. Expected format: X.Y (e.g., 8.3)"
+  exit 1
+fi

8-12: Enhance comment clarity for SQLite installation

The current comment could be more specific about the purpose and requirements.

-# Install SQLite 3.x for Drupal 11 testing if CLI version >= 8.3
+# Enable SQLite 3.x installation for Drupal 11 Kernel and Functional testing
+# This is required for PHP CLI versions >= 8.3 as per https://www.drupal.org/project/drupal/issues/3346338

9-12: Consider making SQLite version requirement configurable

Currently, the SQLite installation is hardcoded to PHP 8.3+. Consider making this more flexible for future requirements.

You could introduce an environment variable or configuration file to specify PHP versions requiring SQLite, making it easier to update without changing the script:

-if [ "$(echo "${CLI_VERSION} >= 8.3" | bc -l)" -eq 1 ]; then
+# Default versions that need SQLite
+SQLITE_REQUIRED_VERSIONS=${SQLITE_REQUIRED_VERSIONS:-"8.3,8.4"}
+
+if echo "$SQLITE_REQUIRED_VERSIONS" | tr ',' '\n' | grep -q "^${CLI_VERSION}$"; then
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d0e383a and e6d55af.

📒 Files selected for processing (2)
  • build.sh (1 hunks)
  • src/Dockerfile (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Dockerfile
🔇 Additional comments (1)
build.sh (1)

14-14: Verify build arguments in Dockerfile

The build arguments look correct, but let's verify their usage in the Dockerfile.

✅ Verification successful

Build arguments are properly declared and used in Dockerfile

The verification confirms that:

  • CLI_VERSION and INSTALL_SQLITE are properly declared as build arguments
  • INSTALL_SQLITE is effectively used in a conditional SQLite installation block
  • While CLI_VERSION appears to use a template value ({{cli_version}}), let's verify its actual usage

Build arguments are properly configured and utilized

The build arguments in the Dockerfile are correctly implemented:

  • CLI_VERSION is used to specify the base image version (FROM docksal/cli:${CLI_VERSION})
  • INSTALL_SQLITE controls the conditional installation of SQLite in a dedicated RUN block
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the Dockerfile properly uses the build arguments

# Check if build arguments are properly declared and used
echo "Checking build arguments in Dockerfile..."
rg -A 2 'ARG (CLI_VERSION|INSTALL_SQLITE)' src/Dockerfile

# Check SQLite installation logic
echo "Checking SQLite installation logic..."
rg -A 5 'INSTALL_SQLITE' src/Dockerfile

Length of output: 1165


Script:

#!/bin/bash
# Check how CLI_VERSION is used in the Dockerfile
rg -A 3 'CLI_VERSION' src/Dockerfile

# Also check if there are any FROM statements that might use it
rg '^FROM' src/Dockerfile

Length of output: 335

@mike-potter mike-potter merged commit c136e0b into master Dec 5, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants