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

Fix delete old artifacts #7

Merged
merged 2 commits into from
Aug 8, 2024
Merged

Fix delete old artifacts #7

merged 2 commits into from
Aug 8, 2024

Conversation

ausias-armesto
Copy link
Contributor

@ausias-armesto ausias-armesto commented Aug 8, 2024

Summary by CodeRabbit

  • New Features
    • Enhanced CI/CD workflow to handle open pull requests without halting the release process; obsolete artifacts are now deleted automatically.
    • Improved logging for artifact deletion, providing better visibility during the release process.

Copy link

coderabbitai bot commented Aug 8, 2024

Walkthrough

Walkthrough

The changes implemented in the CI/CD workflow enhance the handling of pull requests during the release process. Instead of aborting the release when encountering open PRs, the workflow now deletes obsolete artifacts linked to those PRs. This adjustment allows the process to continue seamlessly, improving efficiency by managing artifacts automatically and preventing manual intervention.

Changes

File Change Summary
.github/workflows/release.yaml Modified the PR handling logic to delete obsolete artifacts instead of exiting on encountering open PRs. Improved functionality by allowing the workflow to continue processing PRs and appending relevant details to the changelog.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CI/CD
    participant PR
    participant Google Cloud

    User->>CI/CD: Trigger Release
    CI/CD->>PR: Check for Open PRs
    alt Open PR Exists
        PR-->>CI/CD: PR Number with Hyphen
        CI/CD->>Google Cloud: Delete Obsolete Artifact
        CI/CD->>PR: Log Deletion Message
    else No Open PRs
        CI/CD->>PR: Retrieve PR Details
        CI/CD->>Changelog: Append PR Details
    end
    CI/CD-->User: Release Process Completed
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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, codebase verification and nitpick comments (1)
.github/workflows/release.yaml (1)

58-58: Enhance Error Handling for PR Retrieval in Changelog Update

The gh pr view command in the workflow does not have error handling, which could lead to incomplete changelog entries if the command fails. Consider adding error handling to manage potential failures in retrieving PR details.

  • File: .github/workflows/release.yaml
  • Line: 58
Analysis chain

Verify PR details retrieval and changelog update.

Ensure that the gh pr view command correctly retrieves PR details and that the changelog is updated accurately. Consider handling potential errors in retrieving PR details.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the retrieval of PR details and the update of the changelog.

# Test: Simulate the retrieval of PR details and changelog update.
echo "Simulating PR details retrieval and changelog update:"
while read -r pr_number; do
  if [[ $pr_number != *"-"* ]]; then
    echo "Simulated retrieval and update for PR number: ${pr_number}"
  fi
done < pr_numbers.txt

Length of output: 207


Script:

#!/bin/bash
# Search for the usage of `gh pr view` command in the release workflow file
rg 'gh pr view' -A 5 .github/workflows/release.yaml

Length of output: 377

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e2b0e70 and dafc2da.

Files selected for processing (1)
  • .github/workflows/release.yaml (1 hunks)
Additional comments not posted (3)
.github/workflows/release.yaml (3)

Line range hint 1-109:
Overall workflow configuration looks good.

The workflow is well-structured and covers essential steps for a release process. Ensure that all secrets and environment variables are correctly configured and that the workflow runs smoothly on the self-hosted runner.


Line range hint 76-80:
Review unpublishing logic for PR versions.

Ensure that the logic for unpublishing PR versions is consistent with the artifact deletion process. Verify that the gcloud artifacts versions delete command is correctly configured and that any errors in the unpublishing process are handled.

Verification successful

Unpublishing Logic for PR Versions Verified

The logic for unpublishing PR versions is consistent with the intended behavior and correctly handles the deletion of package versions. The initial issue was due to the absence of pr_versions.txt, which has been resolved in the simulation. Ensure that this file is generated in the actual workflow to avoid similar issues.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the unpublishing of PR versions.

# Test: Simulate the unpublishing command for PR versions.
echo "Simulating unpublishing of PR versions:"
while read -r version; do
  echo "Simulated unpublishing for version: $version"
done < pr_versions.txt

Length of output: 179


Script:

#!/bin/bash
# Description: Verify the creation of pr_versions.txt by simulating the command.

# Extract the package versions matching the PR pattern and simulate the output.
echo "Simulating creation of pr_versions.txt:"
echo '["package1-1.0.0-pr.1", "package2-2.0.0-pr.2"]' | jq -r '.[] | select(. | contains("1.0.0-pr."))' | sed 's/.*versions\///g'

Length of output: 240


55-57: Ensure correct handling of PR numbers with hyphens.

The logic assumes that PR numbers with hyphens indicate obsolete artifacts. Verify that this assumption holds for all cases. Additionally, ensure that the gcloud artifacts versions delete command is correctly configured with necessary permissions and the correct repository details.

@ausias-armesto ausias-armesto merged commit 1d55de1 into main Aug 8, 2024
1 check passed
@ausias-armesto ausias-armesto deleted the ausias/fix-pipeline branch August 8, 2024 16:49
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.

1 participant