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

Changed printing of simulation results #397

Merged
merged 8 commits into from
Nov 5, 2024

Conversation

JulianTrommer
Copy link
Member

@JulianTrommer JulianTrommer commented Oct 30, 2024

Description

This PR changes the logging of the simulation results. They are now always printed inside the log of the drive action and only put in the comments of a PR.

Fixes #390

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Does this PR introduce a breaking change?

No.

Most important changes

Simulation results are now always printed in the action log.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (might be obsolete with CI later on)
  • New and existing unit tests pass locally with my changes (might be obsolete with CI later on)

Summary by CodeRabbit

  • New Features

    • Introduced new steps for improved artifact handling in workflows, including specific actions for pull requests and merges.
    • Added a step to format simulation results into a markdown table.
  • Improvements

    • Streamlined artifact management processes for clarity and efficiency.
    • Enhanced caching mechanisms for Docker builds.
    • Improved cleanup processes for Docker images, now pruning images older than 1 day.
  • Bug Fixes

    • Updated artifact names and paths to ensure correct processing and retrieval.
    • Generalized error messaging for missing artifacts.

@JulianTrommer JulianTrommer linked an issue Oct 30, 2024 that may be closed by this pull request
@JulianTrommer
Copy link
Member Author

@coderabbitai full review

Copy link
Contributor

coderabbitai bot commented Oct 31, 2024

✅ Actions performed

Full review triggered.

Copy link
Contributor

coderabbitai bot commented Oct 31, 2024

Walkthrough

The changes in this pull request involve modifications to two workflow files, .github/workflows/build.yml and .github/workflows/drive.yml. The updates enhance the handling of artifacts related to pull requests and merges by renaming steps, introducing new steps for artifact management, and restructuring the workflow logic to improve clarity and functionality.

Changes

File Change Summary
.github/workflows/build.yml - Added "Cache Docker layers" step for caching Docker layers.
- Renamed "Save PR ID" to "Save pull request artifact" and added logic for PR ID JSON creation.
- Added "Save merge artifact" step for non-PR events.
- Renamed "Upload PR ID" to "Upload artifact," now uploading the new JSON artifact.
- Modified cleanup steps to differentiate between PR and merge events.
- Added step to prune Docker images older than 1 day.
.github/workflows/drive.yml - Modified drive job to run conditionally based on previous workflow success.
- Updated artifact name from "pr_id" to "artifact.json" and generalized error message.
- Renamed steps for artifact handling and added new steps for creating a simulation results table.

Assessment against linked issues

Objective Addressed Explanation
The action should check if the pr_id is present in the artifacts and then post the results to the comments. (#390) The implementation does not ensure the results are commented if pr_id is missing.

Possibly related PRs

Suggested reviewers

  • ll7

Poem

🐇 In the garden where artifacts play,
Changes bloom bright, lighting the way.
With JSONs saved and steps renamed,
Our workflows dance, no time to be drained!
Hop along, let the results be seen,
In the world of code, we reign supreme! 🌼


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

@JulianTrommer JulianTrommer requested a review from ll7 October 31, 2024 07:29
Copy link
Contributor

@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 (3)
.github/workflows/build.yml (2)

86-94: LGTM! Consider using heredoc for better readability.

The logic for creating the merge artifact is correct. The condition and JSON structure are well-defined.

Consider using heredoc for better readability:

-      - name: Save merge artifact
-        if: github.event_name != 'pull_request'
-        run: |
-          mkdir -p ./artifact
-          printf '{
-            "is_pr": false,
-            "pr_id": -1
-          }' >> ./artifact/artifact.json
+      - name: Save merge artifact
+        if: github.event_name != 'pull_request'
+        run: |
+          mkdir -p ./artifact
+          cat << EOF > ./artifact/artifact.json
+          {
+            "is_pr": false,
+            "pr_id": -1
+          }
+          EOF

86-110: Well-structured approach to artifact handling.

The changes introduce a more robust artifact handling system:

  1. Clear separation between PR and merge artifacts through structured JSON
  2. Consistent artifact naming across workflows
  3. Type-safe approach with explicit boolean flags and IDs

This implementation provides better integration with the drive workflow and resolves the issue of identifying PR-triggered builds.

Consider documenting the artifact schema in the repository's documentation to help maintain consistency as the workflow evolves.

🧰 Tools
🪛 actionlint

99-99: shellcheck reported issue in this script: SC2016:info:2:8: Expressions don't expand in single quotes, use double quotes for that

(shellcheck)

.github/workflows/drive.yml (1)

48-59: Add error handling for unzip and JSON parsing operations.

The current implementation could be more robust with proper error handling:

  1. Unzip operation should verify successful extraction
  2. JSON parsing should handle potential errors

Consider updating the script like this:

 - name: Unzip artifact
   run: |
-    unzip artifact.zip
+    unzip artifact.zip || exit 1
+    [ -f "./artifacts/artifacts.json" ] || exit 1

 - name: Return artifact JSON
   id: return-artifact-json
   uses: actions/github-script@v6
   with:
     script: |
       let fs = require('fs');
-      let data = JSON.parse(fs.readFileSync('./artifacts/artifacts.json'));
-      return data;
+      try {
+        let data = JSON.parse(fs.readFileSync('./artifacts/artifacts.json'));
+        return data;
+      } catch (error) {
+        core.setFailed(`Failed to parse artifacts.json: ${error.message}`);
+        return null;
+      }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c3011ee and cc897df.

📒 Files selected for processing (2)
  • .github/workflows/build.yml (1 hunks)
  • .github/workflows/drive.yml (5 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/build.yml

99-99: shellcheck reported issue in this script: SC2016:info:2:8: Expressions don't expand in single quotes, use double quotes for that

(shellcheck)

.github/workflows/drive.yml

94-94: shellcheck reported issue in this script: SC2028:info:1:6: echo may not expand escape sequences. Use printf

(shellcheck)

🔇 Additional comments (3)
.github/workflows/build.yml (1)

106-110: LGTM! Verify artifact path pattern.

The upload configuration is correct, using the latest stable version of the action with appropriate retention settings.

Let's verify the artifact path pattern:

✅ Verification successful

Artifact path pattern is correctly configured

The artifact path configuration is consistent with the workflow's logic:

  • The ./artifact/ directory is properly created using mkdir -p ./artifact
  • The JSON file is correctly written to ./artifact/artifact.json
  • The upload step correctly references this path with path: ./artifact/
  • The artifact contains workflow-specific metadata that's properly generated based on the event type
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the artifact path pattern is used consistently across workflows
# Expected: All references to this artifact should use the same path pattern

# Test: Search for artifact path patterns in workflow files
rg -g '*.yml' -g '*.yaml' --type yaml 'artifact.json|name: artifact'

Length of output: 70


Script:

#!/bin/bash
# Let's try a broader search to find any artifact-related configurations in workflows
rg -g '*.yml' -g '*.yaml' --type yaml 'artifact' -A 3 -B 3

Length of output: 58


Script:

#!/bin/bash
# Also check if the ./artifact/ directory is referenced elsewhere
rg -g '*.yml' -g '*.yaml' --type yaml './artifact/' -A 2 -B 2

Length of output: 61


Script:

#!/bin/bash
# Check for any upload-artifact action usage
rg -g '*.yml' -g '*.yaml' --type yaml 'actions/upload-artifact' -A 3 -B 1

Length of output: 73


Script:

#!/bin/bash
# Let's check the workflow file directly to understand the context
cat .github/workflows/build.yml

Length of output: 3392


Script:

#!/bin/bash
# Also check for any download-artifact actions that might be consuming this artifact
rg -g '*.yml' -g '*.yaml' --type yaml 'actions/download-artifact'

Length of output: 65


Script:

#!/bin/bash
# Check if the artifact directory is created or referenced in the workflow
rg -g '*.yml' -g '*.yaml' --type yaml 'mkdir.*artifact|cp.*artifact'

Length of output: 70

.github/workflows/drive.yml (2)

Line range hint 23-46: LGTM! Artifact download implementation is robust.

The artifact download logic is well-implemented with proper error handling and clear messaging.


Line range hint 72-110: LGTM! Well-structured implementation of simulation results handling.

The changes effectively address the original issue by:

  1. Always printing results to action logs
  2. Creating a well-formatted markdown table
  3. Conditionally adding results as PR comments when appropriate

This implementation aligns perfectly with the PR objectives from issue #390.

🧰 Tools
🪛 actionlint

94-94: shellcheck reported issue in this script: SC2028:info:1:6: echo may not expand escape sequences. Use printf

(shellcheck)

🪛 yamllint

[error] 113-113: no new line character at the end of file

(new-line-at-end-of-file)

Comment on lines +95 to +104
- name: Save pull request artifact
if: github.event_name == 'pull_request'
env:
PR_ID: ${{ github.event.number }}
run: |
mkdir -p ./pr
echo $PR_ID > ./pr/pr_id
mkdir -p ./artifact
printf '{
"is_pr": true,
"pr_id": $PR_ID
}' >> ./artifact/artifact.json
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix shell script to properly expand environment variable.

The logic is correct, but there's a potential issue with variable expansion due to single quotes.

Apply this fix to ensure proper variable expansion:

       - name: Save pull request artifact
         if: github.event_name == 'pull_request'
         env:
           PR_ID: ${{ github.event.number }}
         run: |
           mkdir -p ./artifact
-          printf '{
-            "is_pr": true,
-            "pr_id": $PR_ID
-          }' >> ./artifact/artifact.json
+          cat << EOF > ./artifact/artifact.json
+          {
+            "is_pr": true,
+            "pr_id": $PR_ID
+          }
+          EOF
📝 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
- name: Save pull request artifact
if: github.event_name == 'pull_request'
env:
PR_ID: ${{ github.event.number }}
run: |
mkdir -p ./pr
echo $PR_ID > ./pr/pr_id
mkdir -p ./artifact
printf '{
"is_pr": true,
"pr_id": $PR_ID
}' >> ./artifact/artifact.json
- name: Save pull request artifact
if: github.event_name == 'pull_request'
env:
PR_ID: ${{ github.event.number }}
run: |
mkdir -p ./artifact
cat << EOF > ./artifact/artifact.json
{
"is_pr": true,
"pr_id": $PR_ID
}
EOF
🧰 Tools
🪛 actionlint

99-99: shellcheck reported issue in this script: SC2016:info:2:8: Expressions don't expand in single quotes, use double quotes for that

(shellcheck)

Comment on lines +94 to +96
run: |
echo "Simulation results\n"
echo "${{ steps.simulation-results.outputs.result }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix echo command to properly handle escape sequences.

The current echo command may not properly expand the newline character.

Update the command to use printf:

-  echo "Simulation results\n"
-  echo "${{ steps.simulation-results.outputs.result }}"
+  printf "Simulation results\n\n%s\n" "${{ steps.simulation-results.outputs.result }}"
📝 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
run: |
echo "Simulation results\n"
echo "${{ steps.simulation-results.outputs.result }}"
run: |
printf "Simulation results\n\n%s\n" "${{ steps.simulation-results.outputs.result }}"
🧰 Tools
🪛 actionlint

94-94: shellcheck reported issue in this script: SC2028:info:1:6: echo may not expand escape sequences. Use printf

(shellcheck)

Copy link
Member

@ll7 ll7 left a comment

Choose a reason for hiding this comment

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

Hard to test without merging, but given all the changes, I'm convinced it's worth the risk.

Copy link
Contributor

@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)
.github/workflows/build.yml (2)

116-126: Clean up trailing spaces in the workflow file.

The cache cleanup logic is correct, but there are some minor formatting issues to address.

Remove trailing spaces from lines 121 and 127:

       - name: Clean up PR cache
         if: github.event_name == 'pull_request'
         run: |
           rm -rf /tmp/.buildx-cache/cache/test
-          mv /tmp/.buildx-cache/cache-new/test /tmp/.buildx-cache/cache/test
-      
+          mv /tmp/.buildx-cache/cache-new/test /tmp/.buildx-cache/cache/test
+
       - name: Clean up merge cache
         if: github.event_name != 'pull_request'
         run: |
           rm -rf /tmp/.buildx-cache/cache/latest
-          mv /tmp/.buildx-cache/cache-new/latest /tmp/.buildx-cache/cache/latest
-      
+          mv /tmp/.buildx-cache/cache-new/latest /tmp/.buildx-cache/cache/latest
+
🧰 Tools
🪛 yamllint

[error] 121-121: trailing spaces

(trailing-spaces)


128-129: Add newline at end of file.

The Docker image pruning logic is good for maintaining disk space on the self-hosted runner.

Add a newline at the end of the file:

       - name: Prune all images older than 1 days from self-hosted runner
-        run: docker image prune -a --filter "until=24h"
\ No newline at end of file
+        run: docker image prune -a --filter "until=24h"
+
🧰 Tools
🪛 yamllint

[error] 129-129: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/drive.yml (1)

Line range hint 72-91: Add error handling for simulation results parsing.

While the table formatting logic is well-implemented, consider adding error handling for cases where the JSON structure might be unexpected.

 script: |
   const fs = require('fs');
   // read the simulation results
   const results = fs.readFileSync('./simulation_results.json', 'utf8');
-  let resultsJson = JSON.parse(results);
+  let resultsJson;
+  try {
+    resultsJson = JSON.parse(results);
+    if (!resultsJson.values || !resultsJson.labels || 
+        !Array.isArray(resultsJson.values) || 
+        !Array.isArray(resultsJson.labels)) {
+      throw new Error('Invalid simulation results format');
+    }
+  } catch (error) {
+    core.setFailed(`Failed to parse simulation results: ${error.message}`);
+    return '';
+  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cc897df and f6f84f2.

📒 Files selected for processing (2)
  • .github/workflows/build.yml (3 hunks)
  • .github/workflows/drive.yml (5 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/build.yml

93-93: shellcheck reported issue in this script: SC2016:info:2:8: Expressions don't expand in single quotes, use double quotes for that

(shellcheck)

.github/workflows/drive.yml

94-94: shellcheck reported issue in this script: SC2028:info:1:6: echo may not expand escape sequences. Use printf

(shellcheck)

🪛 yamllint
.github/workflows/build.yml

[error] 121-121: trailing spaces

(trailing-spaces)


[error] 127-127: trailing spaces

(trailing-spaces)


[error] 129-129: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/drive.yml

[error] 113-113: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (8)
.github/workflows/build.yml (3)

38-49: LGTM! Well-structured caching configuration.

The Docker layer caching is properly configured with:

  • Latest actions/cache@v4
  • Separate paths for test and latest builds
  • Effective cache key strategy with fallback

65-66: LGTM! Consistent cache configuration across builds.

The cache paths are properly configured for both test and production builds, using temporary locations for new cache data.

Also applies to: 82-83


89-113: ⚠️ Potential issue

Fix shell script variable expansion in artifact creation.

The artifact handling logic is correct, but there's still a critical issue with variable expansion in the PR artifact creation due to single quotes.

Apply this fix to ensure proper variable expansion:

       - name: Save pull request artifact
         if: github.event_name == 'pull_request'
         env:
           PR_ID: ${{ github.event.number }}
         run: |
           mkdir -p ./artifact
-          printf '{
-            "is_pr": true,
-            "pr_id": $PR_ID
-          }' >> ./artifact/artifact.json
+          cat << EOF > ./artifact/artifact.json
+          {
+            "is_pr": true,
+            "pr_id": $PR_ID
+          }
+          EOF

Also apply similar changes to the merge artifact step for consistency:

       - name: Save merge artifact
         if: github.event_name != 'pull_request'
         run: |
           mkdir -p ./artifact
-          printf '{
-            "is_pr": false,
-            "pr_id": -1
-          }' >> ./artifact/artifact.json
+          cat << EOF > ./artifact/artifact.json
+          {
+            "is_pr": false,
+            "pr_id": -1
+          }
+          EOF
🧰 Tools
🪛 actionlint

93-93: shellcheck reported issue in this script: SC2016:info:2:8: Expressions don't expand in single quotes, use double quotes for that

(shellcheck)

.github/workflows/drive.yml (5)

52-59: LGTM! Clean JSON parsing implementation.

The JSON parsing step is well-implemented using native Node.js functionality.


94-96: Fix echo command to properly handle escape sequences.

🧰 Tools
🪛 actionlint

94-94: shellcheck reported issue in this script: SC2028:info:1:6: echo may not expand escape sequences. Use printf

(shellcheck)


98-110: LGTM! Proper implementation of conditional PR commenting.

The implementation correctly addresses issue #390 by checking the is_pr flag before attempting to comment on the PR.


Line range hint 23-50: LGTM! Improved artifact handling implementation.

The changes to artifact handling are well-structured and more robust. The switch to JSON format provides better type safety and extensibility.

Let's verify the artifact structure in the build workflow:

✅ Verification successful

Artifact handling changes are correctly implemented

The verification confirms that:

  • The build workflow correctly creates artifact.json with the expected structure
  • The artifact is properly uploaded with the name artifact.json
  • The drive workflow's download and handling logic matches the build workflow's artifact format
  • Both PR and non-PR scenarios are handled appropriately with correct JSON structures

The artifact handling changes are well-coordinated between the build and drive workflows, ensuring reliable data transfer between them.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the build workflow creates the expected artifact.json

# Test: Search for artifact.json creation in build workflow
rg -A 5 'artifact\.json' .github/workflows/build.yml

Length of output: 520


Script:

#!/bin/bash
# Let's verify the complete artifact creation logic in build.yml
rg -B 5 -A 2 'artifact\.json' .github/workflows/build.yml

Length of output: 588


112-113: Verify impact of aggressive Docker image pruning.

The change from 30 days to 1 day for Docker image pruning is significant. Please ensure this doesn't impact development workflows that might need older images.

✅ Verification successful

Let me check the Docker image usage patterns in these workflows to better understand the potential impact.


Let me check for any Docker build or pull operations to understand the image lifecycle better.


Let me check the docker-compose configuration to understand the complete Docker setup.


Docker image pruning change is safe to proceed

Based on the analysis of workflows:

  • The repository uses Docker primarily for CI/CD purposes with docker-compose
  • Images are built from Dockerfiles in the build/docker/agent/ directory
  • Workflows rebuild images during execution rather than relying on cached images
  • The 24-hour pruning only affects the self-hosted runner's local storage

The aggressive pruning won't impact development since:

  1. CI/CD builds fresh images for each run
  2. Local development would use their own Docker environment, not the runner's
  3. No workflows depend on pre-existing or cached images
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other workflows that might reference Docker images

# Test: Search for Docker image references in workflows
rg -l 'docker.*image' .github/workflows/

Length of output: 98


Script:

#!/bin/bash
# Check Docker image usage patterns in both workflows
echo "=== drive.yml ==="
rg -A 5 'docker.*image' .github/workflows/drive.yml

echo -e "\n=== build.yml ==="
rg -A 5 'docker.*image' .github/workflows/build.yml

# Also check if there are any image caching or reuse patterns
echo -e "\n=== Checking for image caching patterns ==="
rg 'cache.*docker|docker.*cache' .github/workflows/

Length of output: 472


Script:

#!/bin/bash
# Check for Docker build and pull operations
echo "=== Checking Docker operations in drive.yml ==="
rg -B 5 -A 5 'docker (build|pull)' .github/workflows/drive.yml

echo -e "\n=== Checking Docker operations in build.yml ==="
rg -B 5 -A 5 'docker (build|pull)' .github/workflows/build.yml

# Also check for any docker-compose usage which might involve images
echo -e "\n=== Checking docker-compose usage ==="
rg -l 'docker-compose' .github/workflows/

Length of output: 506


Script:

#!/bin/bash
# Check docker-compose configuration and context
echo "=== Checking docker-compose context in drive.yml ==="
rg -B 5 -A 5 'docker-compose' .github/workflows/drive.yml

# Look for any docker-compose files in the repository
echo -e "\n=== Looking for docker-compose files ==="
fd 'docker-compose.ya?ml'

# Check for any Docker build context or Dockerfile references
echo -e "\n=== Checking for Dockerfile references ==="
rg 'Dockerfile|docker build' .github/workflows/

Length of output: 1663

🧰 Tools
🪛 yamllint

[error] 113-113: no new line character at the end of file

(new-line-at-end-of-file)

Copy link
Contributor

@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: 1

🧹 Outside diff range and nitpick comments (5)
.github/workflows/build.yml (2)

116-126: Remove trailing spaces.

The cache cleanup logic is correct, but there are trailing spaces on lines 121 and 127.

🧰 Tools
🪛 yamllint

[error] 121-121: trailing spaces

(trailing-spaces)


128-129: Consider more selective pruning and add newline.

While pruning old images is good practice, consider:

  1. Being more selective by adding filters (e.g., --filter "label=<your-app-label>")
  2. Adding a newline at the end of the file
-      - name: Prune all images older than 1 days from self-hosted runner
-        run: docker image prune -a -f --filter "until=24h"
+      - name: Prune old images from self-hosted runner
+        run: docker image prune -a -f --filter "until=24h" --filter "label=org.opencontainers.image.source=${{ github.repository }}"
+
🧰 Tools
🪛 yamllint

[error] 129-129: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/drive.yml (3)

11-11: Document custom runner labels.

The workflow uses a custom label drive for the self-hosted runner. While this is valid, it would be helpful to document the available custom labels in the repository.

Consider adding an actionlint.yaml configuration file to suppress the warning, or add a comment explaining the custom label's purpose.

🧰 Tools
🪛 actionlint

11-11: label "drive" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)


52-59: Add error handling for JSON processing.

The JSON processing step could benefit from additional error handling:

  1. Check if the file exists before reading
  2. Handle JSON parsing errors
  3. Validate required fields in the parsed data

Consider updating the script:

 script: |
   let fs = require('fs');
-  let data = JSON.parse(fs.readFileSync('./artifacts/artifacts.json'));
+  const artifactPath = './artifacts/artifacts.json';
+  if (!fs.existsSync(artifactPath)) {
+    core.setFailed(`Artifact file not found at ${artifactPath}`);
+    return;
+  }
+  try {
+    let data = JSON.parse(fs.readFileSync(artifactPath));
+    if (!data.hasOwnProperty('is_pr')) {
+      core.setFailed('Required field "is_pr" missing in artifact JSON');
+      return;
+    }
+    return data;
+  } catch (error) {
+    core.setFailed(`Failed to parse artifact JSON: ${error.message}`);
+    return;
+  }

113-113: Add missing newline at end of file.

Add a newline character at the end of the file to comply with POSIX standards and fix the yamllint error.

 run: docker image prune -a --filter "until=24h"
+
🧰 Tools
🪛 yamllint

[error] 113-113: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f6f84f2 and a202d2f.

📒 Files selected for processing (2)
  • .github/workflows/build.yml (4 hunks)
  • .github/workflows/drive.yml (6 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/build.yml

18-18: label "build" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)


93-93: shellcheck reported issue in this script: SC2016:info:2:8: Expressions don't expand in single quotes, use double quotes for that

(shellcheck)

.github/workflows/drive.yml

11-11: label "drive" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)


94-94: shellcheck reported issue in this script: SC2028:info:1:6: echo may not expand escape sequences. Use printf

(shellcheck)

🪛 yamllint
.github/workflows/build.yml

[error] 121-121: trailing spaces

(trailing-spaces)


[error] 127-127: trailing spaces

(trailing-spaces)


[error] 129-129: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/drive.yml

[error] 113-113: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (6)
.github/workflows/build.yml (3)

38-49: LGTM! Well-structured Docker layer caching implementation.

The cache configuration follows best practices:

  • Uses the latest stable version of actions/cache
  • Separates test and latest build caches
  • Implements proper cache key strategy with fallback

65-66: LGTM! Consistent cache path configuration.

The build steps correctly use absolute paths that match the cache configuration.

Also applies to: 82-83


89-113: LGTM with existing review comment.

The artifact handling logic is correct, but please address the variable expansion issue noted in the previous review comment.

🧰 Tools
🪛 actionlint

93-93: shellcheck reported issue in this script: SC2016:info:2:8: Expressions don't expand in single quotes, use double quotes for that

(shellcheck)

.github/workflows/drive.yml (3)

Line range hint 23-46: LGTM! Improved artifact handling.

The changes improve error handling and align with the build workflow's artifact naming convention.


Line range hint 72-91: LGTM! Well-structured results formatting.

The table formatting provides a clear and consistent presentation of simulation results.


112-113: Verify impact of aggressive image pruning.

The image pruning interval has been significantly reduced from 30 days to 1 day. While this helps manage disk space more aggressively, please verify that this won't affect any dependent workflows that might need older images.

✅ Verification successful

Let me check the specific docker pull commands in the workflow file to understand the image dependencies better.


Let me check the docker-compose file to understand the image configuration and dependencies.


Let me search for the docker-compose file as it might be in a different location.


Let me check if there are any other workflow files that might be affected by the image pruning.


Aggressive image pruning is safe to implement

The 1-day pruning policy is already consistently implemented across both workflow files (drive.yml and build.yml). The workflows use docker-compose for running containers and don't show any dependencies on cached images older than 24 hours. The images are pulled fresh during workflow execution with --quiet-pull, making the aggressive pruning safe for the current workflow setup.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for workflow dependencies on docker images
rg -l "docker.*pull" .github/workflows/

Length of output: 69


Script:

#!/bin/bash
# Check docker pull commands and their context in the workflow
rg -B 5 -A 5 "docker.*pull" .github/workflows/drive.yml

Length of output: 516


Script:

#!/bin/bash
# Check docker-compose configuration
cat docker-compose.yml

Length of output: 75


Script:

#!/bin/bash
# Find docker-compose file
fd -t f "docker-compose.y[a]?ml"

Length of output: 34


Script:

#!/bin/bash
# Check for any docker image usage in workflows
rg -B 5 -A 5 "docker.*image|FROM\s+\w+" .github/workflows/

Length of output: 1003

🧰 Tools
🪛 yamllint

[error] 113-113: no new line character at the end of file

(new-line-at-end-of-file)

@@ -15,7 +15,7 @@ env:
jobs:
build-and-push-image:
name: Build and push image
runs-on: self-hosted
runs-on: [self-hosted, build]
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Missing documentation for self-hosted runner configuration

The build label is only used in the build.yml workflow file and there is no documentation explaining the runner setup, required labels, or infrastructure configuration. This poses a maintainability risk as other developers won't know how to set up runners with the correct labels.

  • Add documentation about self-hosted runner setup and required labels
  • Consider creating an actionlint.yaml to suppress warnings for custom labels
  • Document the purpose of the build label and any specific requirements for runners using this label
🔗 Analysis chain

Document custom runner label configuration.

The build label appears to be a custom label for self-hosted runners. While this is a valid practice, it should be properly documented.

Run this script to check for runner setup documentation:

Consider:

  1. Adding documentation about the required runner labels
  2. Creating an actionlint.yaml to configure custom labels and suppress warnings

Let me gather more information about the runner configuration by checking other workflow files and documentation.


Let me check if there are any infrastructure-related files or documentation in other common locations that might contain runner setup information.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for runner setup documentation
fd -t f "README|CONTRIBUTING|SETUP|INSTALL" -X rg -i "runner|build.*label"

Length of output: 175


Script:

#!/bin/bash
# Check all workflow files for runner labels and configurations
fd -e yml -e yaml . .github/workflows -X rg -i "runs-on.*build"

# Look for any runner setup or infrastructure documentation
fd -t f -e md . .github/docs .github -X rg -i "self.hosted.*runner|runner.*setup|runner.*label"

# Check if there's an actionlint configuration
fd "actionlint" -X cat {}

Length of output: 312


Script:

#!/bin/bash
# Check for infrastructure or deployment related files
fd -t f "infrastructure|deploy|runner|setup" -X rg -i "self.hosted.*runner|runner.*setup|runner.*label"

# Check root level documentation
fd -t f -d 1 "README|CONTRIBUTING|SETUP|INSTALL" -X rg -i "github.*action|runner|workflow"

# Check if build label is used in any shell scripts or configuration files
fd -e sh -e conf -e yaml -e yml -X rg -i "build.*label|runner.*label"

Length of output: 270

🧰 Tools
🪛 actionlint

18-18: label "build" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

@ll7 ll7 merged commit b2ab308 into main Nov 5, 2024
4 checks passed
@ll7 ll7 deleted the 390-bug-drive-action-does-not-comment-driving-results branch November 5, 2024 08:58
@coderabbitai coderabbitai bot mentioned this pull request Nov 7, 2024
7 tasks
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.

[Bug]: Drive action does not comment driving results
2 participants