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

ci: ensure bicep is upgraded #1593

Merged
merged 7 commits into from
Dec 11, 2024
Merged

ci: ensure bicep is upgraded #1593

merged 7 commits into from
Dec 11, 2024

Conversation

arealmaas
Copy link
Collaborator

Description

Related Issue(s)

  • #{issue number}

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • Documentation is updated (either in docs-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)

@arealmaas arealmaas requested review from a team as code owners December 11, 2024 13:42
Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Warning

Rate limit exceeded

@arealmaas has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between fc0d4da and ada95f1.

📒 Files selected for processing (5)
  • .azure/modules/redis/main.bicep (0 hunks)
  • .azure/modules/serviceBus/main.bicep (0 hunks)
  • .github/actions/azure-login/action.yml (1 hunks)
  • .github/workflows/workflow-deploy-apps.yml (3 hunks)
  • .github/workflows/workflow-deploy-infra.yml (1 hunks)
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces significant changes to the CI/CD workflow configurations in three YAML files. The .github/workflows/ci-cd-pull-request.yml file removes the dry-run-deploy-apps job and updates the dependencies for the delete-github-deployments job. The .github/workflows/workflow-deploy-apps.yml file removes the deploy-migration-job and deploy-jobs, modifies the deploy-apps job to include a step for upgrading Bicep, and adds new environment variables. The .github/workflows/workflow-deploy-infra.yml file adds a step to upgrade the Bicep CLI before deployment. These alterations streamline the deployment processes.

Changes

File Path Change Summary
.github/workflows/ci-cd-pull-request.yml Removed job dry-run-deploy-apps. Updated dependencies for delete-github-deployments.
.github/workflows/workflow-deploy-apps.yml Removed jobs deploy-migration-job and deploy-jobs. Modified deploy-apps to add Bicep upgrade step and new environment variables.
.github/workflows/workflow-deploy-infra.yml Added step to upgrade Bicep CLI before deployment.

Possibly related PRs

Suggested reviewers

  • oskogstad
  • knuhau

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. (Experiment)
  • @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.

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

🧹 Outside diff range and nitpick comments (2)
.github/workflows/workflow-deploy-apps.yml (2)

88-91: Consider adding version constraint for Bicep upgrade

While adding the Bicep upgrade step aligns with the PR objectives, consider specifying a minimum version to ensure consistency across environments.

Consider modifying the upgrade command to include a minimum version:

-az bicep upgrade
+az bicep upgrade --version-min="0.20.0"

Based on the gathered information, I can now provide a final response:

Migration and job deployments have been moved to Container Apps Jobs

The removal of deploy-migration-job and deploy-jobs from the workflow is actually part of a modernization effort. The codebase now uses Azure Container Apps Jobs for handling migrations and scheduled tasks, as evidenced by:

  • Dedicated Bicep modules for Container App Jobs in .azure/modules/containerAppJob/
  • Migration job configuration in .azure/applications/web-api-migration-job/
  • Other scheduled jobs like sync-subject-resource-mappings-job and sync-resource-policy-information-job

The workflow output reference jobs.deploy-jobs.result should be updated to reflect this architectural change.

🔗 Analysis chain

Line range hint 1-150: Verify scope of job removals

The removal of deploy-migration-job and deploy-jobs appears to be a significant change that's not directly related to the PR's objective of upgrading Bicep. This could impact the deployment workflow.

Let's analyze the impact of these removals:


Let me gather more information about the deployment workflow changes.


Let me gather one final piece of information to understand if these jobs are being deployed through a different workflow.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to the removed jobs
rg -A 5 'deploy-migration-job|deploy-jobs' .github/workflows/

Length of output: 543


Script:

#!/bin/bash
# Check for any migration-related files or configurations
fd migration .azure/

# Look for any job definitions in bicep files
rg -i "job|migration" .azure/ -A 5

# Check git history for the specific file
git log -p -1 -- .github/workflows/workflow-deploy-apps.yml

Length of output: 19205


Script:

#!/bin/bash
# Check for other workflow files that might be handling job deployments
fd workflow .github/workflows/ --type f --exec rg -l 'deploy.*job|migration' {}

Length of output: 277


Script:

#!/bin/bash
# Check the content of these workflow files for job deployment patterns
rg -A 5 'deploy.*job|migration' .github/workflows/workflow-send-ci-cd-status-slack-message.yml .github/workflows/workflow-publish.yml .github/workflows/workflow-check-for-changes.yml

# Also check for any recent changes to job-related workflows
git log --since="1 month ago" --grep="job\|migration" --oneline

Length of output: 2697

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6e88e0c and be2e40e.

📒 Files selected for processing (2)
  • .github/workflows/ci-cd-pull-request.yml (1 hunks)
  • .github/workflows/workflow-deploy-apps.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/ci-cd-pull-request.yml (1)

70-70: Verify impact of removing infrastructure validation

While simplifying the dependency chain by removing dry-run-deploy-infra makes the workflow leaner, we should ensure this doesn't bypass critical infrastructure validation steps.

Let's check if there are any other infrastructure validation steps in place:

✅ Verification successful

The initial search shows multiple workflow files related to infrastructure, but we need to understand:

  1. The actual structure of the PR workflow
  2. How infrastructure deployment is handled in the dedicated workflow

This will help us verify if removing the infrastructure validation step from PR workflow is safe.


From the PR workflow, I can see that infrastructure validation is still present through the build-infrastructure job, but I need to verify:

  1. What the build-infrastructure workflow actually does
  2. Whether there are any Bicep files that need validation

This will help confirm if infrastructure validation is adequately covered despite removing the dry-run-deploy-infra dependency.


Infrastructure validation is properly maintained despite dependency removal

The removal of dry-run-deploy-infra from the dependencies is safe because:

  1. The PR workflow still includes infrastructure validation through the build-infrastructure job, which performs Bicep linting
  2. The infrastructure changes are gated by check-for-changes.outputs.hasInfraChanges
  3. The build-infrastructure job runs independently and doesn't need to be a dependency for delete-github-deployments
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for infrastructure validation steps across workflow files
rg -l 'infrastructure|bicep' .github/workflows/

Length of output: 598


Script:

#!/bin/bash
# Check the content of ci-cd-pull-request.yml to understand the workflow structure
cat .github/workflows/ci-cd-pull-request.yml

# Also check the infrastructure-specific workflow
cat .github/workflows/workflow-deploy-infra.yml

Length of output: 8887


Script:

#!/bin/bash
# Check the build-infrastructure workflow to understand how infrastructure validation is handled
cat .github/workflows/workflow-build-infrastructure.yml

# Also check for any changes in infrastructure files
rg -l "\.bicep" .azure/

Length of output: 3477

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 (1)
.github/workflows/workflow-deploy-infra.yml (1)

73-76: Add error handling to Bicep upgrade step

The Bicep upgrade step is well-positioned after Azure login. However, consider adding error handling and version verification.

  - name: Upgrade bicep
    run: |
-     az bicep upgrade
+     if ! az bicep upgrade; then
+       echo "Failed to upgrade Bicep CLI"
+       exit 1
+     fi
+     # Verify upgrade
+     az bicep version
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between be2e40e and fc0d4da.

📒 Files selected for processing (2)
  • .github/workflows/ci-cd-pull-request.yml (1 hunks)
  • .github/workflows/workflow-deploy-infra.yml (1 hunks)
🔇 Additional comments (2)
.github/workflows/ci-cd-pull-request.yml (1)

67-67: Verify the workflow execution order after dependency changes

The dependency update for delete-github-deployments job is consistent with the removal of dry-run-deploy-apps. However, let's verify that no critical cleanup steps are skipped.

✅ Verification successful

Dependency changes are safe and consistent with workflow structure

After analyzing the workflow files, the removal of dry-run-deploy-apps from the dependencies of delete-github-deployments job in ci-cd-pull-request.yml is correct because:

  1. The dry-run-deploy-apps job has been completely removed from this workflow
  2. The delete-github-deployments job only needs to run after infrastructure checks, which is maintained through its dependency on dry-run-deploy-infra
  3. The job's conditional if: ${{ always() && !failure() && !cancelled() }} ensures it runs for cleanup as long as the workflow hasn't failed or been cancelled
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any references to the removed dry-run-deploy-apps job
# and verify no other jobs depend on it

echo "Checking for any remaining references to dry-run-deploy-apps..."
rg "dry-run-deploy-apps" .github/workflows/

echo "Checking for any jobs that might need the removed job as a dependency..."
rg "needs.*dry-run-deploy-apps" .github/workflows/

Length of output: 886


Script:

#!/bin/bash
# Let's check the full context of the workflow files to understand the job dependencies better

echo "Checking ci-cd-pull-request.yml for job dependencies..."
cat .github/workflows/ci-cd-pull-request.yml

echo -e "\nChecking ci-cd-pull-request-release-please.yml for job dependencies..."
cat .github/workflows/ci-cd-pull-request-release-please.yml

echo -e "\nChecking ci-cd-prod.yml for job dependencies..."
cat .github/workflows/ci-cd-prod.yml

Length of output: 16705

.github/workflows/workflow-deploy-infra.yml (1)

73-76: Verify Bicep template usage in the workflow

Let's verify that all Bicep templates referenced in the workflow exist and are valid.

✅ Verification successful

Bicep template and workflow configuration verified successfully

The verification shows that:

  • The main Bicep template exists at .azure/infrastructure/main.bicep and contains valid resource declarations
  • Environment-specific parameter files are present (test, staging, prod, yt01)
  • The workflow correctly references both the main template and environment-specific parameter files
  • The Bicep upgrade step is properly integrated into the workflow
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Bicep template references and validate templates

echo "Checking referenced Bicep files..."
# Check main template
if [ -f ".azure/infrastructure/main.bicep" ]; then
  echo "Found main.bicep"
else
  echo "main.bicep not found!"
  exit 1
fi

# Check parameter files for different environments
echo "Checking Bicep parameter files..."
fd -e bicepparam . .azure/infrastructure/

# Look for Bicep-specific syntax in templates
echo "Checking Bicep syntax usage..."
rg "resource\s+\w+\s+'[^']+'\s+=\s+{" .azure/infrastructure/

Length of output: 714


Script:

#!/bin/bash
# Let's verify Bicep files with a simpler approach

# Check if main.bicep exists and show its content
echo "=== Main Bicep Template ==="
cat .azure/infrastructure/main.bicep

# List all Bicep files
echo -e "\n=== All Bicep Files ==="
fd -e bicep . .azure/infrastructure/

# Check for resource declarations with a simpler pattern
echo -e "\n=== Resource Declarations ==="
rg "resource\s" .azure/infrastructure/main.bicep

# Check workflow file for Bicep deployment steps
echo -e "\n=== Workflow Bicep Usage ==="
rg "bicep" .github/workflows/workflow-deploy-infra.yml

Length of output: 11913

oskogstad
oskogstad previously approved these changes Dec 11, 2024
Copy link

sonarcloud bot commented Dec 11, 2024

@arealmaas arealmaas merged commit bb4433b into main Dec 11, 2024
25 checks passed
@arealmaas arealmaas deleted the chore/ensure-latest-bicep branch December 11, 2024 14:12
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.

2 participants