Skip to content

Fix stale pull request CI compatibility - #641

Merged
terjekv merged 4 commits into
masterfrom
agent/fix-stale-pr-ci
Jul 29, 2026
Merged

Fix stale pull request CI compatibility#641
terjekv merged 4 commits into
masterfrom
agent/fix-stale-pr-ci

Conversation

@terjekv

@terjekv terjekv commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Preserve the pre-Fix OpenAPI schema generation #628 field order for NetworkSerializer and NetGroupRegexPermissionSerializer.
  • Retain the explicit network and range fields required for OpenAPI generation.
  • Restore mreg.api.views.LIBRARIES_TO_REPORT as a compatibility alias.
  • Ensure mreg-cli tests the image built for the current pull request.
  • Add regression tests for both serializer orders and the compatibility alias.

Root cause

Serializer field ordering

PR #628 explicitly declared two custom model fields so drf-spectacular could describe them:

NetworkSerializer.network = serializers.CharField()
NetGroupRegexPermissionSerializer.range = serializers.CharField()

Combined with fields = "__all__", DRF moved those fields earlier in the serialized output.

NetworkSerializer changed from:

id, excluded_ranges, policy, communities, created_at, updated_at, network, ...

to:

id, network, excluded_ranges, policy, communities, created_at, updated_at, ...

NetGroupRegexPermissionSerializer changed from:

id, created_at, updated_at, group, range, regex, labels

to:

id, range, created_at, updated_at, group, regex, labels

Although JSON object order is not semantically significant, mreg-cli’s recorded-output tests compare it, and stable serialization avoids unnecessary changes for existing consumers.

Both serializers now use explicit field tuples in their previous order while retaining the explicit custom fields required for OpenAPI generation.

Renamed constant

PR #628 moved the reported-library constant from mreg.api.views to mreg.api.serializers and renamed it to REPORTED_LIBRARY_VERSION_FIELDS.

In-flight pull requests created before #628, including #616, still import LIBRARIES_TO_REPORT from mreg.api.views. The previous name is retained as an alias:

LIBRARIES_TO_REPORT = REPORTED_LIBRARY_VERSION_FIELDS

This keeps older branches compatible without duplicating the value.

Incorrect image used by mreg-cli

The container workflow tagged the newly built PR image locally as:

ghcr.io/unioslo/mreg:latest

However, the mreg-cli integration script defaults to:

ghcr.io/unioslo/mreg:master

The integration job could therefore test the published registry image instead of the image built for the current pull request.

The workflow now tags the locally built image as :master, ensuring mreg-cli exercises the PR artifact. This local tag is not pushed to the registry.

@coveralls

coveralls commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 97.697% (+0.001%) from 97.696% — agent/fix-stale-pr-ci into master

@terjekv
terjekv marked this pull request as ready for review July 28, 2026 19:27
@terjekv
terjekv requested review from Copilot and pederhan July 28, 2026 19:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR restores compatibility for older/in-flight branches and stabilizes API serializer output ordering after the drf-spectacular changes in #628, while also ensuring CI’s mreg-cli integration tests exercise the image built for the current PR.

Changes:

  • Make NetworkSerializer and NetGroupRegexPermissionSerializer use explicit Meta.fields tuples to preserve the pre-#628 serialized field order while keeping the explicit OpenAPI-friendly custom fields.
  • Reintroduce mreg.api.views.LIBRARIES_TO_REPORT as an alias for REPORTED_LIBRARY_VERSION_FIELDS and add a regression test for the alias.
  • Fix CI image tagging so the mreg-cli workflow uses the locally built PR image (tagged as ghcr.io/unioslo/mreg:master) and add regression tests for serializer field ordering.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
mreg/api/v1/serializers.py Switch NetworkSerializer and NetGroupRegexPermissionSerializer from __all__ to explicit ordered field tuples to stabilize output order.
mreg/tests/test_serializers.py Add regression tests asserting the serializer field order for the two affected serializers.
mreg/api/views.py Restore LIBRARIES_TO_REPORT as a compatibility alias to the renamed constant in mreg.api.serializers.
mreg/api/tests/test_versions.py Add regression coverage ensuring the legacy constant remains compatible (same object).
.github/workflows/container-image.yml Tag the locally built image as ghcr.io/unioslo/mreg:master so mreg-cli tests the PR artifact instead of a registry image.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pederhan pederhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. We must look into more robust and flexible diffing in mreg-cli (DeepDiff), so we avoid this churn.

@terjekv
terjekv merged commit 8153a31 into master Jul 29, 2026
39 checks passed
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.

4 participants