Skip to content

Conversation

@theosanderson
Copy link
Member

@theosanderson theosanderson commented Jan 7, 2026

resolves #

Screenshot

PR Checklist

  • All necessary documentation has been adapted.
  • The implemented feature is covered by appropriate, automated tests.
  • Any manual testing that has been done is documented (i.e. what exactly was tested?)

🚀 Preview: Add preview label to enable

claude and others added 17 commits November 24, 2025 09:47
Add a CI workflow that generates and validates helm template output,
similar to the existing DB schema dump workflow.

The workflow:
- Triggers on changes to kubernetes/loculus/** files
- Generates helm template output for three configurations:
  * Default values.yaml
  * E2E/dev values (values.yaml + values_e2e_and_dev.yaml)
  * Preview server values (values.yaml + values_preview_server.yaml)
- Outputs rendered manifests to kubernetes/loculus/docs/rendered/
- Detects changes and requires 'update_helm_output' label on PR
- Auto-commits changes when label is present

This helps reviewers understand how helm chart changes affect the
final rendered Kubernetes manifests.
… diffs

Add sed commands to remove timestamp values from helm template output,
replacing them with empty strings. This ensures the generated output
files are deterministic and don't change on every run due to timestamps.

The sed command replaces any value matching the pattern:
  timestamp: "2025-11-24 09:54:08.569904811 +0000 UTC m=+0.838587464"

With:
  timestamp: ""

This makes it easier to review meaningful changes in PRs without
timestamp noise.
Instead of generating monolithic helm-output.yaml files, now split the
output into separate files based on the "# Source:" markers that helm
template generates.

Changes:
- Add .github/scripts/split-helm-output.sh script to parse and split
  helm template output by source template
- Update workflow to generate output into subdirectories:
  * kubernetes/loculus/docs/rendered/default/
  * kubernetes/loculus/docs/rendered/e2e-dev/
  * kubernetes/loculus/docs/rendered/preview-server/
- Each template (e.g., loculus-backend.yaml, secrets.yaml) gets its
  own file containing all resources from that template
- Update README.md to document the new directory structure

Benefits:
- Easier to review changes to specific components
- More focused and readable diffs
- Quickly see which templates are affected by changes
- Better organization for documentation

The split script:
- Parses "# Source: loculus/templates/foo.yaml" comments
- Extracts the template name and creates corresponding output file
- Handles subdirectories in templates
- Preserves the Source comments for reference
- Groups multiple resources from the same template together
Refactor the helm template output workflow to use GitHub Actions matrix
strategy, making it more maintainable and DRY.

Changes:
- Split workflow into two jobs:
  1. `generate-helm-output`: Uses matrix to generate 3 configs in parallel
  2. `commit-changes`: Downloads artifacts and commits all changes together

- Matrix configuration includes:
  * default: values.yaml only
  * e2e-dev: values.yaml + values_e2e_and_dev.yaml
  * preview-server: values.yaml + values_preview_server.yaml

- Each matrix job generates output, uploads as artifact
- Commit job downloads all artifacts, reorganizes them, and commits

Benefits:
- Eliminates code duplication (DRY principle)
- Easier to add new configurations
- Parallel execution of helm template generation
- Cleaner, more maintainable workflow structure
Fix artifact reorganization to prevent double-nested directories like:
  kubernetes/loculus/docs/rendered/e2e-dev/helm-output-e2e-dev/

Changes:
- Download artifacts to /tmp/helm-artifacts/ instead of directly to
  the rendered directory
- Clear existing rendered output directories before reorganizing
- Explicitly move artifact contents to the correct final locations

This ensures the final structure is:
  kubernetes/loculus/docs/rendered/
  ├── default/
  │   ├── ingest-config.yaml
  │   └── ...
  ├── e2e-dev/
  └── preview-server/

Instead of the buggy double-nested structure.
Fix non-deterministic ordering of organisms in helm template output by
sorting organism keys alphabetically.

Changes:
- Add new helper template `loculus.sortedOrganismKeys` that returns
  organism keys sorted alphabetically for deterministic iteration
- Update lapis-ingress.yaml to use sorted organism keys when building
  the traefik middleware annotation list

This ensures that the middleware annotation:
  traefik.ingress.kubernetes.io/router.middlewares
always lists organisms in the same order (alphabetically), making the
rendered helm output deterministic across CI runs.

Previously, the order was non-deterministic due to Go map iteration
order, causing unnecessary diffs in the CI-generated documentation even
when nothing had actually changed.

Fixes non-deterministic organism ordering issue in helm template output.
Fix helm template error: "Cannot find first on type map" by using direct
inline sorting instead of a helper that serializes/deserializes.

Changes:
- Revert the sortedOrganismKeys helper that was causing type issues
- Use inline `keys ... | sortAlpha` directly in lapis-ingress.yaml
- This ensures $organismKeys is a proper list that works with first()

The issue was that template helpers can only return strings, and the
JSON serialization/deserialization was causing type confusion for the
`first` function, even though iteration worked fine.

This simpler approach directly creates a sorted list of keys without
serialization, which works correctly with all Go template functions
including first, range, etc.
Add a Python script to format embedded JSON content in YAML files with
proper indentation for better readability. The CI workflow now runs this
script after splitting helm template output, making config files like
backend_config.json much easier to review in PRs.

Changes:
- Add .github/scripts/format-json-in-yaml.py to format JSON in YAML files
- Update helm-template-output.yml to run the formatter after splitting
- Update existing rendered output with nicely formatted JSON
…N output

Update helm templates to use toPrettyJson instead of toJson for ConfigMap
files that contain JSON configuration. This produces nicely formatted JSON
with proper indentation, making config files much easier to review in PRs.

Templates updated:
- loculus-backend-config.yaml (backend_config.json)
- loculus-website-config.yaml (website_config.json)
- lapis-silo-database-config.yaml (reference_genomes.json)

Removed the Python post-processing script as the formatting is now done
directly by Helm.
@claude
Copy link
Contributor

claude bot commented Jan 7, 2026

Code Review for Helm Template Output Generation

Overview

This PR introduces automated generation and documentation of Helm template outputs across different configurations. The implementation follows a similar pattern to the existing schema-dump.yml workflow and adds valuable documentation for reviewers.


Strengths

  1. Good Documentation: The README.md clearly explains the purpose and structure of the generated files
  2. Consistent Pattern: Follows the established pattern from schema-dump.yml for label-based auto-commits
  3. Multi-config Support: Properly handles different value configurations (default, e2e-dev, preview-server)
  4. Artifact Organization: Good use of GitHub artifacts to pass data between jobs
  5. Timestamp Normalization: Smart sed replacement to ensure consistent output (.github/workflows/helm-template-output.yml:45)

🔍 Issues & Concerns

1. Missing Preview Server Output (High Priority)

The workflow matrix includes preview-server configuration, but the PR doesn't contain any files in kubernetes/loculus/docs/rendered/preview-server/.

Expected: Files in all three directories (default, e2e-dev, preview-server)
Actual: Only default and e2e-dev directories present

Questions:

  • Did the preview-server generation fail silently?
  • Should preview-server be excluded from this PR?
  • Is there a conditional that skips it?

2. Shell Script Security & Best Practices (.github/scripts/split-helm-output.sh)

Minor Issues:

  • Line 43: The print statement should use > instead of >> for the first write to ensure we start with a clean file:

    # Current (could append to existing files):
    print > current_file
    
    # Consider adding explicit truncation or using > initially, then >> for subsequent writes
  • Line 38: The mkdir -p via system() call could fail silently. Consider adding error handling:

    if (system("mkdir -p \"" dir "\"") \!= 0) {
        print "Error creating directory: " dir > "/dev/stderr"
        exit 1
    }
  • Line 66-67: The cleanup step removes the input file before confirming success. If anything fails after this point, the input is lost. Consider moving rm -f after the success message or adding error handling.

Good Practices Already Implemented:

  • set -euo pipefail for proper error handling
  • ✅ Proper quoting of variables
  • ✅ Clear error messages

3. Workflow Error Message Inconsistency

Line .github/workflows/helm-template-output.yml:122 references the label in the error message, but there's a minor inconsistency:

echo "::error::Helm template output changes detected but 'update_helm_output' label is not present on the PR"
echo "Please add the 'update_helm_output' label if these changes are intentional"

This is fine, but for consistency with schema-dump.yml (which uses update_db_schema), the message could be clearer about the exact label name.

4. Version Pinning

  • .github/workflows/helm-template-output.yml:27: Uses @v5 for checkout action
  • .github/workflows/helm-template-output.yml:33: Uses @v4 for setup-helm
  • Compare to schema-dump.yml:37 which uses @v6 for checkout

Recommendation: Update to checkout@v6 for consistency with other workflows, or document why v5 is required.

5. Potential Race Condition (Low Priority)

Lines .github/workflows/helm-template-output.yml:78-88: The artifact reorganization removes existing directories before moving new ones. If the workflow is run concurrently on the same PR (unlikely but possible), this could cause issues. Consider using atomic moves or checking for concurrent runs.


🧪 Test Coverage

Missing:

  • No validation that the split actually worked correctly (e.g., checking file count matches expected)
  • No validation that all expected files were generated
  • Consider adding a step to verify the output structure before committing

Suggestion: Add a validation step:

- name: Validate output structure
  run: |
    # Check that we have the expected key files
    for config in default e2e-dev preview-server; do
      if [ \! -f "kubernetes/loculus/docs/rendered/$config/loculus-backend.yaml" ]; then
        echo "::error::Missing expected file: $config/loculus-backend.yaml"
        exit 1
      fi
    done

🎯 Recommendations

  1. Investigate the missing preview-server output before merging
  2. Add output validation to catch silent failures
  3. Consider adding the update_helm_output label requirement to CONTRIBUTING.md or the main CLAUDE.md
  4. Update checkout action to v6 for consistency
  5. Add error handling in the awk script for mkdir failures
  6. Consider moving the rm command in split-helm-output.sh to after success confirmation

📋 PR Checklist Review

From the PR description:

  • All necessary documentation has been adapted - ✅ README.md is good, but consider updating CONTRIBUTING.md
  • The implemented feature is covered by appropriate, automated tests - ⚠️ No validation tests for correctness
  • Any manual testing that has been done is documented - ❌ Not documented

🔒 Security Considerations

  • No obvious security vulnerabilities
  • Proper use of git config for the bot user
  • No credential exposure risks
  • Artifact retention is appropriately limited to 1 day

Performance Considerations

  • Matrix strategy is efficient for parallel generation
  • Artifact download/upload is appropriate for the file sizes
  • The sed timestamp replacement is a simple but effective approach
  • The awk-based splitting is efficient for this use case

📝 Summary

This is a solid implementation that adds valuable documentation for Helm template changes. The main concern is the missing preview-server output which should be investigated before merging. The shell script could benefit from minor improvements in error handling, but the core functionality is sound.

Recommendation: Request changes to address the missing preview-server output and add validation steps. Once those are resolved, this would be ready to merge.

@theosanderson theosanderson marked this pull request as draft January 7, 2026 17:41
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.

4 participants