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

build: Read build matrix from Mill #909

Merged
merged 1 commit into from
Dec 30, 2024
Merged

Conversation

nightscape
Copy link
Owner

@nightscape nightscape commented Dec 30, 2024

PR Type

enhancement, configuration changes


Description

  • Introduced a new prepare job in the CI workflow to dynamically generate a build matrix using Mill and jq.
  • Replaced the static build matrix in the build job with a dynamically generated matrix, improving maintainability and flexibility.
  • Removed hardcoded matrix configurations and exclusions, simplifying the CI configuration.
  • Updated the build job to depend on the prepare job, ensuring the dynamically generated matrix is used.

Changes walkthrough 📝

Relevant files
Configuration changes
ci.yml
Dynamically generate build matrix using Mill in CI workflow

.github/workflows/ci.yml

  • Added a new prepare job to generate a build matrix dynamically using
    Mill and jq.
  • Replaced the static build matrix in the build job with a dynamically
    generated matrix from the prepare job.
  • Removed hardcoded matrix configurations and exclusions, simplifying
    the workflow.
  • Updated the build job to depend on the prepare job for the matrix.
  • +18/-13 

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Possible Issue

    The ./mill resolve "spark-excel[_,_]" command in the prepare job assumes that Mill is installed and accessible in the CI environment. Ensure that Mill is properly installed or added as a prerequisite step in the workflow.

    echo -n "matrix="
    ./mill resolve "spark-excel[_,_]" | \
    jq -Rsc 'split("\n") | map(capture("spark-excel\\[(?<scala>[^,]+),(?<spark>[^\\]]+)\\]") | select(.)) | {include: .}'
    Matrix Validation

    The dynamically generated matrix relies on the output of the jq command. Ensure that the jq tool is installed and that the parsing logic correctly handles all expected and edge cases in the spark-excel output.

    ./mill resolve "spark-excel[_,_]" | \
    jq -Rsc 'split("\n") | map(capture("spark-excel\\[(?<scala>[^,]+),(?<spark>[^\\]]+)\\]") | select(.)) | {include: .}'

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add error handling to the ./mill resolve command to prevent pipeline failures in case of command errors

    Ensure the ./mill resolve command handles errors gracefully by checking its exit
    status and providing a fallback or error message to avoid pipeline failures if the
    command fails.

    .github/workflows/ci.yml [30-32]

    +set -e
     ./mill resolve "spark-excel[_,_]" | \
    -jq -Rsc 'split("\n") | map(capture("spark-excel\\[(?<scala>[^,]+),(?<spark>[^\\]]+)\\]") | select(.)) | {include: .}'
    +jq -Rsc 'split("\n") | map(capture("spark-excel\\[(?<scala>[^,]+),(?<spark>[^\\]]+)\\]") | select(.)) | {include: .}' || echo '{"include": []}'
    Suggestion importance[1-10]: 9

    Why: Adding error handling to the ./mill resolve command ensures that the pipeline does not fail unexpectedly if the command encounters an error. This is a critical improvement for robustness in CI workflows.

    9
    Ensure the jq command output is valid JSON to prevent runtime errors in the matrix configuration

    Validate the output of the jq command to ensure it produces a valid JSON object
    before using it in the matrix configuration to avoid runtime errors.

    .github/workflows/ci.yml [31-32]

    -jq -Rsc 'split("\n") | map(capture("spark-excel\\[(?<scala>[^,]+),(?<spark>[^\\]]+)\\]") | select(.)) | {include: .}'
    +jq -Rsc 'split("\n") | map(capture("spark-excel\\[(?<scala>[^,]+),(?<spark>[^\\]]+)\\]") | select(.)) | {include: .}' > matrix.json && jq empty matrix.json
    Suggestion importance[1-10]: 8

    Why: Validating the jq command output ensures that the matrix configuration receives a proper JSON object, preventing potential runtime errors. This is a valuable enhancement for reliability.

    8

    @nightscape nightscape force-pushed the read-build-matrix-from-mill branch from 932a1a2 to 5a75d8f Compare December 30, 2024 22:58
    @nightscape nightscape force-pushed the read-build-matrix-from-mill branch from 5a75d8f to 6aa02fd Compare December 30, 2024 23:01
    @nightscape nightscape merged commit deb412e into main Dec 30, 2024
    28 checks passed
    @nightscape nightscape deleted the read-build-matrix-from-mill branch December 30, 2024 23:23
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant