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(zap): Update runs-on to ubuntu-22.04, Add retry mechanism, Modify run-ci command, Remove --wait flag #88

Merged
merged 20 commits into from
Jun 7, 2024

Conversation

manoelhc
Copy link
Owner

@manoelhc manoelhc commented Jun 7, 2024

Description

  • Updated the runs-on value to ubuntu-22.04 in the .github/workflows/zap-scanner.yaml file
  • Added a retry mechanism to wait for the web application to start before running ZAP scan in the .github/workflows/zap-scanner.yaml file
  • Modified the run-ci command in the ZAP Scan job to remove the --wait flag in the .github/workflows/zap-scanner.yaml file
  • Removed the --wait flag from the run-ci command in the justfile

Changes walkthrough 📝

Relevant files
Enhancement
zap-scanner.yaml
Updated runs-on to ubuntu-22.04, Added retry mechanism, Modified
run-ci command

.github/workflows/zap-scanner.yaml
['Updated the runs-on value to ubuntu-22.04', 'Added a retry mechanism to wait for the web application to start before running ZAP scan', 'Modified the run-ci command in the ZAP Scan job to remove the --wait flag']

+11/-3   
justfile
Removed --wait flag from run-ci command                                   

justfile
['Removed the --wait flag from the run-ci command']

+2/-2     

Summary by Sourcery

This pull request updates the ZAP Scan GitHub Action workflow to run on a specific feature branch, changes the runner to 'ubuntu-22.04', and adds a step to ensure the web application is running before starting the ZAP scan. Additionally, it modifies the 'justfile' to remove the '--wait' flag from the 'docker-compose up' command in the 'run-ci' task.

  • CI:
    • Updated the ZAP Scan GitHub Action workflow to run on the 'feat/fix-zap-tests' branch instead of 'main'.
    • Changed the runner for the ZAP Scan job from 'ubuntu-latest' to 'ubuntu-22.04'.
    • Added a step to wait for the web application to start before proceeding with the ZAP scan, including retry logic.

Summary by CodeRabbit

  • Chores
    • Updated CI workflow to use ubuntu-22.04 for better compatibility.
    • Improved ZAP scan workflow by adding a script to ensure the web application starts before scanning.

@manoelhc manoelhc linked an issue Jun 7, 2024 that may be closed by this pull request
@manoelhc manoelhc self-assigned this Jun 7, 2024
Copy link

codecov bot commented Jun 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.81%. Comparing base (cb8fa08) to head (cfa2159).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #88   +/-   ##
=======================================
  Coverage   97.81%   97.81%           
=======================================
  Files          10       10           
  Lines         411      411           
  Branches       76       76           
=======================================
  Hits          402      402           
  Misses          9        9           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

sourcery-ai bot commented Jun 7, 2024

Reviewer's Guide by Sourcery

This pull request updates the ZAP scan workflow and the justfile to ensure the web application starts correctly before running the ZAP scan. The changes include modifying the GitHub Actions workflow to wait for the web application to be ready and updating the justfile to remove the --wait flag from the docker-compose command.

File-Level Changes

Files Changes
.github/workflows/zap-scanner.yaml
justfile
Updated the ZAP scan workflow and justfile to ensure the web application starts correctly before running the ZAP scan.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

deepsource-io bot commented Jun 7, 2024

Here's the code health analysis summary for commits cb8fa08..cfa2159. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython✅ SuccessView Check ↗
DeepSource Test coverage LogoTest coverage✅ SuccessView Check ↗

Code Coverage Report

MetricAggregatePython
Branch Coverage87.9%87.9%
Condition Coverage87.9%87.9%
Composite Coverage96.2%96.2%
Line Coverage97.5%97.5%

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@penify-dev penify-dev bot added the enhancement New feature or request label Jun 7, 2024
@penify-dev penify-dev bot changed the title feat(zap): Fix docker-compose run Update runs-on to ubuntu-22.04, Add retry mechanism, Modify run-ci command, Remove --wait flag Jun 7, 2024
Copy link
Contributor

penify-dev bot commented Jun 7, 2024

PR Review 🔍

⏱️ Estimated effort to review [1-5]

2, because the changes are straightforward and well-documented in the description.

🧪 Relevant tests

No

⚡ Possible issues

None

🔒 Security concerns

No

Copy link
Contributor

coderabbitai bot commented Jun 7, 2024

Walkthrough

The recent updates focus on enhancing the .github/workflows/zap-scanner.yaml file to improve the ZAP scanning process. Key changes include altering the branch trigger, updating the operating system to ubuntu-22.04, and adding a script to ensure the web application starts before running the ZAP scan. Additionally, the justfile has been modified to streamline the run-ci command by removing the --wait option from docker-compose up.

Changes

File Change Summary
.github/workflows/zap-scanner.yaml Changed branch trigger from main to feat/fix-zap-tests, updated OS to ubuntu-22.04, added script to wait for web app
.github/workflows/zap-scanner.yaml Changed OS to ubuntu-22.04, added script to wait for web app using curl --retry
justfile Removed --wait option from docker-compose up in run-ci command

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant Web Application
    participant ZAP Scanner

    Developer->>+GitHub Actions: Push to `feat/fix-zap-tests`
    GitHub Actions->>+Web Application: Start application
    loop Retry 5 times
        GitHub Actions->>Web Application: Check if started
        Web Application-->>GitHub Actions: Response
    end
    GitHub Actions->>+ZAP Scanner: Run ZAP scan
    ZAP Scanner-->>GitHub Actions: Scan results
    GitHub Actions-->>Developer: CI/CD pipeline results
Loading

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

penify-dev bot commented Jun 7, 2024

PR Code Suggestions ✨

CategorySuggestion                                                                                                                                    Score
Best practice
Improve the run-ci command by adding a timeout and a more descriptive failure message

Consider improving the retry mechanism by adding a timeout and a more informative message
in the run-ci command.

.github/workflows/zap-scanner.yaml [17-24]

 +          for i in {1..5}; do
 +            sleep 5
-+            curl -s -o /dev/null -w "%{http_code}" http://localhost:8443/ && exit 0
++            response_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8443)
++            if [ $response_code -eq 200 ]; then
++              exit 0
++            fi
 +          done
-+          exit 1
++          echo "Web application did not start successfully after multiple retries." && exit 1
 
Suggestion importance[1-10]: 8

Why: The suggestion enhances the reliability of the retry mechanism in the run-ci command by introducing a timeout and a more informative failure message.

8
Maintainability
Remove the --wait flag from the run-ci command to align with the workflow changes

Update the run-ci command to remove the --wait flag and align it with the changes made in
the workflow file.

justfile [54-55]

++run-ci:
++    docker-compose up -d
 
-
Suggestion importance[1-10]: 5

Why: The suggestion aims to maintain consistency between the workflow file and the run-ci command by removing the --wait flag.

5

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @manoelhc - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Removal of '--wait' flag might cause race conditions (link)
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue, 1 other issue
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

run-ci: build
docker-compose up -d --wait
run-ci:
docker-compose up -d
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Removal of '--wait' flag might cause race conditions

The '--wait' flag ensures that the services are fully started before proceeding. Removing this flag might cause race conditions where subsequent steps run before the services are ready. Consider re-adding the '--wait' flag or implementing an alternative waiting mechanism.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Github's docker-compose doesn't support --wait flag.

Copy link

github-actions bot commented Jun 7, 2024

Tag v0.13.1 (branch: main, SHA: a06b5fa) Added.

Copy link
Contributor

codacy-production bot commented Jun 7, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (cb8fa08) 407 397 97.54%
Head commit (cfa2159) 407 (+0) 397 (+0) 97.54% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#88) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cb8fa08 and 9de9939.

Files selected for processing (2)
  • .github/workflows/zap-scanner.yaml (1 hunks)
  • justfile (1 hunks)
Files skipped from review due to trivial changes (1)
  • justfile
Additional comments not posted (2)
.github/workflows/zap-scanner.yaml (2)

5-5: Branch trigger updated to feat/fix-zap-tests.

This change ensures that the workflow only runs on the specific feature branch, which is a good practice for testing new features without affecting the main branch.


10-10: Operating system updated to ubuntu-22.04.

Specifying a fixed OS version can lead to more predictable builds. Please ensure that all dependencies and tools used in the workflow are compatible with Ubuntu 22.04.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9de9939 and a96772e.

Files selected for processing (1)
  • .github/workflows/zap-scanner.yaml (1 hunks)
Additional comments not posted (2)
.github/workflows/zap-scanner.yaml (2)

5-5: Branch trigger updated to feat/fix-zap-tests.


10-10: Operating system updated to ubuntu-22.04.

Copy link

sonarqubecloud bot commented Jun 7, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a96772e and cfa2159.

Files selected for processing (1)
  • .github/workflows/zap-scanner.yaml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/zap-scanner.yaml

@manoelhc manoelhc changed the title Update runs-on to ubuntu-22.04, Add retry mechanism, Modify run-ci command, Remove --wait flag fix(zap): Update runs-on to ubuntu-22.04, Add retry mechanism, Modify run-ci command, Remove --wait flag Jun 7, 2024
@manoelhc manoelhc merged commit a06b5fa into main Jun 7, 2024
21 checks passed
@manoelhc manoelhc deleted the feat/fix-zap-tests branch June 7, 2024 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix ZAP tests
1 participant