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

feat(ci): add swagger outdated check #283

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

MaxMustermann2
Copy link
Contributor

@MaxMustermann2 MaxMustermann2 commented Jan 10, 2025

  • Update swagger.json
  • Add check on the PR level

Summary by CodeRabbit

  • Chores
    • Added a new GitHub Actions workflow to validate Proto Swagger file generation
    • Updated Dockerfile with latest CA certificates version

If this CI fails, run `make proto-swagger-gen` and commit the changes
Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

This pull request introduces a new GitHub Actions workflow to validate Proto Swagger file generation and updates the Dockerfile's certificate package version. The check-swagger.yml workflow automates the process of checking Swagger file generation, ensuring that any changes during the generation process are detected and reported. Simultaneously, the Dockerfile sees a minor update to the ca-certificates package version, potentially improving security and system certificate management.

Changes

File Change Summary
.github/workflows/check-swagger.yml New workflow added to automate Proto Swagger file generation check on pull requests and branch pushes
Dockerfile Updated ca-certificates package version from 20241121-r0 to 20241121-r1 in build and final image stages

Possibly related PRs

Poem

🐰 Swagger checks, a rabbit's delight,
Workflows dancing, files shining bright
Certificates updated with care
CI/CD magic beyond compare!
Hop, hop, code's integrity we'll share! 🔍


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

🧹 Nitpick comments (1)
.github/workflows/check-swagger.yml (1)

19-33: Enhance error reporting and artifact handling.

While the current implementation works, consider these improvements for better debugging and visibility:

       - name: Check if any files have changed post regeneration
         run: |
           if ! git diff --exit-code > /dev/null 2>&1; then
             echo "Changes detected after running 'make proto-swagger-gen'."
             git diff
+            # Create a patch file
+            git diff > swagger-changes.patch
+            # Upload the patch as an artifact
+            echo "::error::Swagger files are outdated. See the artifact 'swagger-changes' for details."
             exit 1
           fi
+      - name: Upload changes as artifact
+        if: failure()
+        uses: actions/upload-artifact@v4
+        with:
+          name: swagger-changes
+          path: swagger-changes.patch
+          retention-days: 5

Also, consider adding a pre-check step:

      - name: Check prerequisites
        run: |
          if ! command -v make &> /dev/null; then
            echo "::error::make command not found"
            exit 1
          fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc740e8 and b1a0a56.

📒 Files selected for processing (2)
  • .github/workflows/check-swagger.yml (1 hunks)
  • Dockerfile (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build
  • GitHub Check: goreleaser
  • GitHub Check: build
🔇 Additional comments (4)
.github/workflows/check-swagger.yml (2)

1-13: LGTM! Well-configured workflow triggers and permissions.

The workflow is properly configured with:

  • Descriptive name
  • Appropriate triggers for PRs and main branches
  • Security-conscious read-only permissions

14-18: Verify if the 10-minute timeout is sufficient.

While the timeout setting seems reasonable, please verify that make proto-swagger-gen typically completes well within 10 minutes to avoid false failures in the CI pipeline.

Let's check the typical duration of proto-swagger generation:

✅ Verification successful

10-minute timeout is sufficient for proto-swagger generation

Based on the analysis of the proto-swagger-gen task in the Makefile and the number of proto files (~80), the 10-minute timeout provides adequate headroom for both downloading dependencies and generating swagger files. Similar Cosmos-based chains typically complete this process in under 5 minutes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check workflow run history to verify if 10 minutes is sufficient
# Note: This will only work if there are previous workflow runs

gh run list --workflow=check-swagger.yml --json durationInMinutes --jq 'map(.durationInMinutes) | max'

Length of output: 347


Script:

#!/bin/bash
# Get completed workflow runs and calculate their durations
gh run list --workflow=check-swagger.yml --json startedAt,updatedAt,conclusion --jq '.[] | select(.conclusion != null) | {duration: (((strptime("%Y-%m-%dT%H:%M:%SZ", .updatedAt) - strptime("%Y-%m-%dT%H:%M:%SZ", .startedAt)) / 60)), conclusion: .conclusion}' | head -n 5

Length of output: 364


Script:

#!/bin/bash
# Find and examine Makefile and proto-swagger related files
echo "=== Makefile contents ==="
fd Makefile --type f --exec cat {}
echo -e "\n=== Proto and Swagger related files ==="
fd -e proto -e swagger --type f

Length of output: 26657

Dockerfile (2)

9-9: Verify the security implications of the ca-certificates update.

The ca-certificates package has been updated from 20241121-r0 to 20241121-r1 in both build and final stages. Let's verify the changelog and security implications of this update.

Also applies to: 26-26

✅ Verification successful

✓ Minor revision update with no security implications

The ca-certificates update from 20241121-r0 to 20241121-r1 is a routine maintenance update. The base version remains unchanged, and there are no associated security advisories or CVEs for this specific revision in Alpine Linux 3.19.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check Alpine package repository for ca-certificates version details

# Get package info from Alpine's package repository
curl -s "https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz" | tar -xz -O | grep -A3 "P:ca-certificates"

# Check for any security advisories
curl -s "https://security.alpinelinux.org/branch/v3.19" | grep -A5 "ca-certificates"

Length of output: 250


Script:

#!/bin/bash
# Try multiple approaches to gather security information

# Attempt 1: Use zcat to handle binary data properly
curl -s "https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz" | zcat | grep -A5 "P:ca-certificates"

# Attempt 2: Check Alpine Linux Git repository for package changes
curl -s "https://git.alpinelinux.org/aports/plain/main/ca-certificates/APKBUILD" | grep -A5 "pkgver="

# Attempt 3: Check Alpine Linux security advisories in text format
curl -s "https://security.alpinelinux.org/branch/v3.19.txt" | grep -A5 "ca-certificates"

# Attempt 4: Search for recent CVEs
curl -s "https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=ca-certificates+alpine" | grep -A5 "CVE-202"

Length of output: 16048


26-28: Verify all package versions are up-to-date and secure.

While version pinning is good practice, please verify that all package versions are the latest stable releases and free from known vulnerabilities.

✅ Verification successful

All package versions are current and match Alpine v3.19 repository

The package versions specified in the Dockerfile exactly match the current versions available in the Alpine v3.19 repository, indicating they are up-to-date and maintained.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check Alpine package versions and security advisories

# List of packages to check
PACKAGES=(
  "ca-certificates=20241121-r1"
  "libstdc++=13.2.1_git20231014-r0"
  "jq=1.7.1-r0"
  "curl=8.11.1-r0"
  "bash=5.2.21-r0"
  "vim=9.0.2127-r0"
  "lz4=1.9.4-r5"
  "rclone=1.65.0-r3"
)

echo "Checking package versions in Alpine v3.19..."
for pkg in "${PACKAGES[@]}"; do
  name="${pkg%=*}"
  version="${pkg#*=}"
  echo "Checking $name version $version..."
  curl -s "https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz" | tar -xz -O | grep -A3 "P:$name"
done

echo "Checking security advisories..."
curl -s "https://security.alpinelinux.org/branch/v3.19"

Length of output: 3201


Script:

#!/bin/bash
# Description: Improved package version and security check

echo "Checking current Alpine package versions..."
curl -s "https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz" | tar -xzO | awk '/^P:/{pkg=$0; getline v; print pkg "," v}' | grep -E "^P:(ca-certificates|libstdc\+\+|jq|curl|bash|vim|lz4|rclone)"

echo -e "\nChecking security advisories..."
curl -s -H "Accept: application/json" "https://security.alpinelinux.org/v1/releases/v3.19.0/issues"

Length of output: 1549

@TimmyExogenous
Copy link
Contributor

Great work. I really appreciate it.

@MaxMustermann2 MaxMustermann2 merged commit 59241ba into imua-xyz:develop Jan 10, 2025
18 checks passed
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.

3 participants