Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@betulependule
Copy link
Contributor

@betulependule betulependule commented Jul 25, 2025

Implement support for forgejo commit statuses and add relevant tests to test new functionality. Also add "warning" commit status used by forgejo.

Fixes #882

Related to #866

@betulependule betulependule changed the title Forgejo commit statuses Implement support for forgejo commit statuses Jul 25, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @betulependule, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the integration with Forgejo by providing complete support for commit statuses. It allows the system to both retrieve and set detailed status information for commits, improving visibility into the state of development processes on Forgejo repositories.

Highlights

  • Forgejo Commit Status Management: Implemented the full functionality for managing commit statuses on Forgejo. This includes the get method to retrieve existing statuses for a commit and the set method to create or update commit statuses, allowing for comprehensive status reporting.
  • New Commit Status State: Expanded the CommitStatus enum by adding a new warning state. This provides a more granular way to report the outcome of automated checks and processes.
  • API Integration and Error Handling: Integrated with the pyforgejo library to interact with the Forgejo API for status operations. Robust error handling has been added to gracefully manage scenarios such as a commit not being found on the Forgejo instance.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements support for Forgejo commit statuses. There were a few issues identified, including a critical one that would cause an infinite recursion. Suggestions were provided to improve correctness and adhere to idiomatic Python.

@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

Copy link
Member

@mfocko mfocko left a comment

Choose a reason for hiding this comment

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

Except for those few remarks looks OK :)

ogr/abstract.py Outdated
error = 4
canceled = 5
running = 6
warning = 7
Copy link
Member

Choose a reason for hiding this comment

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

Where did you find warning?

Copy link
Member

Choose a reason for hiding this comment

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

I see now where you found the warning… it's only mentioned in the filtering 🤦 not sure if it can be used, or how can you get there /o\

Copy link
Member

Choose a reason for hiding this comment

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

Ya, it will work, it's just not documented :) checked the forgejo source, LOL

Copy link
Member

Choose a reason for hiding this comment

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

and it's a partial revert, it got removed in Gitea, but it breaks some parts of the automation, so they reverted it just partially 🤦

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove warning then? I found it here forgejo.dev.

Copy link
Member

Choose a reason for hiding this comment

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

I think you can keep it, I'll open up issue on upstream to check what's the plan with that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks.

Copy link
Member

Choose a reason for hiding this comment

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

AAAAAA, I still haven't opened up the issue /o

@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

assert flag.state == CommitStatus.success
assert flag.comment == "Initial commit"
assert flag.context == "default"
assert flag.created.year == 2019
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I've realized I'm testing for a non-existing commit status (I misunderstood what a commit status is previously). Will fix this once I figure out why I keep getting pyforgejo API errors.

@softwarefactory-project-zuul
Copy link
Contributor

@betulependule
Copy link
Contributor Author

Tests are probably failing because of missing .yaml files that should have been generated by recording tests. They are passing locally when using tmt. Will look into how to get these files generated.

@mfocko
Copy link
Member

mfocko commented Aug 1, 2025

Tests are probably failing because of missing .yaml files that should have been generated by recording tests. They are passing locally when using tmt. Will look into how to get these files generated.

I was a bit afraid that this might happen, cause tmt copies the repo over, so you are generating the responses, but they are not copied back to the repo from where you run the tmt.

To not get off-topic, you should be able to get the path to the latest tmt run without running it1

I've been able to get:

/var/tmp/tmt/run-013
warn: Plan '/plans/packit-integration/requre' defines both 'execute' and 'import', ignoring the 'execute' step.
warn: Plan '/plans/packit-integration/tests' defines both 'execute' and 'import', ignoring the 'execute' step.
    warn: /plans/packit-integration/requre: - {'discover': {'how': 'fmf'}, 'execute': {'how': 'tmt'}, 'summary': 'Cassette tests run through requre', 'plan': {'import': {'url': 'https://github.com/packit/packit', 'name': '/plans/session-recording'}}} is valid under each of {'required': ['plan']}, {'required': ['execute']}
    warn: /plans/packit-integration/tests: - {'discover': {'how': 'fmf'}, 'execute': {'how': 'tmt'}, 'summary': 'Full set of tests (unit, integration, and functional)', 'plan': {'import': {'url': 'https://github.com/packit/packit', 'name': '/plans/full'}}} is valid under each of {'required': ['plan']}, {'required': ['execute']}

/plans/full
    report
        how: display
            00:09:19 pass /tests/full
                logs:
                    output.txt (/var/tmp/tmt/run-013/plans/full/execute/data/guest/default-0/tests/full-1/output.txt)
                    failures.yaml (/var/tmp/tmt/run-013/plans/full/execute/data/guest/default-0/tests/full-1/failures.yaml)
        summary: 1 test passed

/plans/rpmlint
    report
        how: display
            00:00:00 pass /rpmlint
                logs:
                    output.txt (/var/tmp/tmt/run-013/plans/rpmlint/execute/data/guest/default-0/rpmlint-1/output.txt)
                    failures.yaml (/var/tmp/tmt/run-013/plans/rpmlint/execute/data/guest/default-0/rpmlint-1/failures.yaml)
        summary: 1 test passed

/plans/smoke
    report
        how: display
            00:00:00 pass /tests/smoke
                logs:
                    output.txt (/var/tmp/tmt/run-013/plans/smoke/execute/data/guest/default-0/tests/smoke-1/output.txt)
                    failures.yaml (/var/tmp/tmt/run-013/plans/smoke/execute/data/guest/default-0/tests/smoke-1/failures.yaml)
        summary: 1 test passed

/plans/packit-integration/requre
    report
        how: display
            00:00:14 pass /tests_recording
                logs:
                    output.txt (/var/tmp/tmt/run-013/plans/packit-integration/requre/execute/data/guest/default-0/tests_recording-1/output.txt)
                    failures.yaml (/var/tmp/tmt/run-013/plans/packit-integration/requre/execute/data/guest/default-0/tests_recording-1/failures.yaml)
        summary: 1 test passed

/plans/packit-integration/tests
    report
        how: display
            00:00:35 pass /tests/full/unit
                logs:
                    output.txt (/var/tmp/tmt/run-013/plans/packit-integration/tests/execute/data/guest/default-0/tests/full/unit-1/output.txt)
                    failures.yaml (/var/tmp/tmt/run-013/plans/packit-integration/tests/execute/data/guest/default-0/tests/full/unit-1/failures.yaml)
            00:06:39 pass /tests/full/integration
                logs:
                    output.txt (/var/tmp/tmt/run-013/plans/packit-integration/tests/execute/data/guest/default-0/tests/full/integration-2/output.txt)
                    failures.yaml (/var/tmp/tmt/run-013/plans/packit-integration/tests/execute/data/guest/default-0/tests/full/integration-2/failures.yaml)
            00:04:13 pass /tests/full/functional
                logs:
                    output.txt (/var/tmp/tmt/run-013/plans/packit-integration/tests/execute/data/guest/default-0/tests/full/functional-3/output.txt)
                    failures.yaml (/var/tmp/tmt/run-013/plans/packit-integration/tests/execute/data/guest/default-0/tests/full/functional-3/failures.yaml)
        summary: 3 tests passed

total: 7 tests passed

with

$ tmt run -l report -h display -vv

And given the path to the logs (/var/tmp/tmt/run-013/plans/full/execute/data/guest/default-0/tests/full-1/output.txt), I've been able to get to the sources at /var/tmp/tmt/run-013/plans/full/tree. Hope it helps a bit.

Footnotes

  1. given that it wasn't cleaned up already (by either tmt or systemd, cause it generates temporary directories in /var)

@betulependule
Copy link
Contributor Author

Tests are probably failing because of missing .yaml files that should have been generated by recording tests. They are passing locally when using tmt. Will look into how to get these files generated.

I was a bit afraid that this might happen, cause tmt copies the repo over, so you are generating the responses, but they are not copied back to the repo from where you run the tmt.

To not get off-topic, you should be able to get the path to the latest tmt run without running it1

I've been able to get:

with

$ tmt run -l report -h display -vv

And given the path to the logs (/var/tmp/tmt/run-013/plans/full/execute/data/guest/default-0/tests/full-1/output.txt), I've been able to get to the sources at /var/tmp/tmt/run-013/plans/full/tree. Hope it helps a bit.

Footnotes

1. given that it wasn't cleaned up already (by either tmt or systemd, cause it generates temporary directories in `/var`) [↩](#user-content-fnref-1-5dcb54bcb0110183569eb76f7ad14f11)

Thank you. I'll try it today. :)

@softwarefactory-project-zuul
Copy link
Contributor

mfocko added a commit to mfocko/ogr that referenced this pull request Aug 6, 2025
mfocko added a commit to mfocko/ogr that referenced this pull request Aug 6, 2025
mfocko added a commit to mfocko/ogr that referenced this pull request Aug 6, 2025
mfocko added a commit to mfocko/ogr that referenced this pull request Aug 11, 2025
softwarefactory-project-zuul bot added a commit that referenced this pull request Aug 13, 2025
docs: extend the tmt documentation based on #936

TODO:

 Mention the possibility of using an environment file.

Reviewed-by: gemini-code-assist[bot]
Reviewed-by: Matej Focko
Reviewed-by: Alzbeta Kucerova
@softwarefactory-project-zuul
Copy link
Contributor

@betulependule betulependule marked this pull request as ready for review August 18, 2025 07:28
Implement support for forgejo commit statuses in ogr/services/forgejo/flag.py.
Add 'warning' status to CommitStatus in ogr/abstract.py applicable forgejo commits.
@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

@betulependule betulependule added the mergeit Merge via Zuul label Aug 19, 2025
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).
https://softwarefactory-project.io/zuul/t/packit-service/buildset/f45313cf1cd647b181d24dae94f6e798

✔️ pre-commit SUCCESS in 3m 05s

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 6efda99 into packit:main Aug 19, 2025
38 of 46 checks passed
@github-project-automation github-project-automation bot moved this from in-review to done in Packit Kanban Board Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mergeit Merge via Zuul

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Implement support for Forgejo commit statuses

2 participants