diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c974f3a45..90f7d3fd5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -22,11 +22,11 @@ jobs: sphinx: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4.2.2 + - uses: actions/checkout@v6.0.1 - name: Set up Python - uses: actions/setup-python@v5.6.0 + uses: actions/setup-python@v6.1.0 with: - python-version: "3.13" + python-version: "3.14" - name: Install dependencies run: pip install tox - name: Build docs @@ -37,11 +37,11 @@ jobs: twine-check: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4.2.2 + - uses: actions/checkout@v6.0.1 - name: Set up Python - uses: actions/setup-python@v5.6.0 + uses: actions/setup-python@v6.1.0 with: - python-version: "3.13" + python-version: "3.14" - name: Install dependencies run: pip install tox twine wheel - name: Check twine readme rendering diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d16f7fe09..01bee8a33 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,12 +22,12 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.2.2 + - uses: actions/checkout@v6.0.1 with: fetch-depth: 0 - - uses: actions/setup-python@v5.6.0 + - uses: actions/setup-python@v6.1.0 with: - python-version: "3.13" + python-version: "3.14" - run: pip install --upgrade tox - name: Run commitizen (https://commitizen-tools.github.io/commitizen/) run: tox -e cz diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 05e21065c..f6f1c6229 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -15,6 +15,6 @@ jobs: action: runs-on: ubuntu-latest steps: - - uses: dessant/lock-threads@v5.0.1 + - uses: dessant/lock-threads@v6.0.0 with: process-only: 'issues' diff --git a/.github/workflows/pre_commit.yml b/.github/workflows/pre_commit.yml index 9fadeca81..4be228d66 100644 --- a/.github/workflows/pre_commit.yml +++ b/.github/workflows/pre_commit.yml @@ -29,10 +29,10 @@ jobs: pre_commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.2.2 - - uses: actions/setup-python@v5.6.0 + - uses: actions/checkout@v6.0.1 + - uses: actions/setup-python@v6.1.0 with: - python-version: "3.13" + python-version: "3.14" - name: install tox run: pip install tox==3.26.0 - name: pre-commit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 72f22f125..ff04716dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,14 +14,14 @@ jobs: id-token: write environment: pypi.org steps: - - uses: actions/checkout@v4.2.2 + - uses: actions/checkout@v6.0.1 with: fetch-depth: 0 token: ${{ secrets.RELEASE_GITHUB_TOKEN }} - name: Python Semantic Release id: release - uses: python-semantic-release/python-semantic-release@v10.0.2 + uses: python-semantic-release/python-semantic-release@v10.5.3 with: github_token: ${{ secrets.RELEASE_GITHUB_TOKEN }} @@ -32,7 +32,7 @@ jobs: if: steps.release.outputs.released == 'true' - name: Publish package distributions to GitHub Releases - uses: python-semantic-release/upload-to-gh-release@0a92b5d7ebfc15a84f9801ebd1bf706343d43711 # v9.8.9 + uses: python-semantic-release/publish-action@v10.5.3 if: steps.release.outputs.released == 'true' with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.RELEASE_GITHUB_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index cdfaee27b..e4fd014a5 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -3,10 +3,12 @@ name: 'Close stale issues and PRs' on: schedule: - cron: '30 1 * * *' + workflow_dispatch: # For manual runs permissions: issues: write pull-requests: write + actions: write concurrency: group: lock @@ -15,21 +17,66 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v9.1.0 + - uses: actions/stale@v10.1.1 with: + operations-per-run: 500 stale-issue-label: "stale" stale-pr-label: "stale" - any-of-labels: 'need info,Waiting for response,stale' - stale-issue-message: > - This issue was marked stale because it has been open 60 days with no - activity. Please remove the stale label or comment on this issue. Otherwise, - it will be closed in 15 days. + # If an issue/PR has an assignee it won't be marked as stale + exempt-all-assignees: true + stale-issue-message: | + This issue was marked stale because it has been open 60 days with + no activity. Please remove the stale label or comment on this + issue. Otherwise, it will be closed in 15 days. + + As an open-source project, we rely on community contributions to + address many of the reported issues. Without a proposed fix or + active work towards a solution it is our policy to close inactive + issues. This is documented in CONTRIBUTING.rst + + **How to keep this issue open:** + * If you are still experiencing this issue and are willing to + investigate a fix, please comment and let us know. + * If you (or someone else) can propose a pull request with a + solution, that would be fantastic. + * Any significant update or active discussion indicating progress + will also prevent closure. + + We value your input. If you can help provide a fix, we'd be happy + to keep this issue open and support your efforts. + + This is documented in CONTRIBUTING.rst + https://github.com/python-gitlab/python-gitlab/blob/main/CONTRIBUTING.rst + days-before-issue-stale: 60 days-before-issue-close: 15 - close-issue-message: > - This issue was closed because it has been marked stale for 15 days with no - activity. If this issue is still valid, please re-open. + close-issue-message: | + This issue was closed because it has been marked stale for 15 days + with no activity. + + This open-source project relies on community contributions, and + while we value all feedback, we have a limited capacity to address + every issue without a clear path forward. + + Currently, this issue hasn't received a proposed fix, and there + hasn't been recent active discussion indicating someone is planning + to work on it. To maintain a manageable backlog and focus our + efforts, we will be closing this issue for now. + + **This doesn't mean the issue isn't valid or important.** If you or + anyone else in the community is willing to investigate and propose + a solution (e.g., by submitting a pull request), please do. + + We believe that those who feel a bug is important enough to fix + should ideally be part of the solution. Your contributions are + highly welcome. + + Thank you for your understanding and potential future + contributions. + + This is documented in CONTRIBUTING.rst + https://github.com/python-gitlab/python-gitlab/blob/main/CONTRIBUTING.rst stale-pr-message: > This Pull Request (PR) was marked stale because it has been open 90 days @@ -40,4 +87,3 @@ jobs: close-pr-message: > This PR was closed because it has been marked stale for 15 days with no activity. If this PR is still valid, please re-open. - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17d514b11..0f2af115e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,8 +26,6 @@ jobs: matrix: os: [ubuntu-latest] python: - - version: "3.9" - toxenv: py39,smoke - version: "3.10" toxenv: py310,smoke - version: "3.11" @@ -36,21 +34,21 @@ jobs: toxenv: py312,smoke - version: "3.13" toxenv: py313,smoke - - version: "3.14.0-alpha - 3.14" # SemVer's version range syntax + - version: "3.14" toxenv: py314,smoke include: - os: macos-latest python: - version: "3.13" - toxenv: py313,smoke + version: "3.14" + toxenv: py314,smoke - os: windows-latest python: - version: "3.13" - toxenv: py313,smoke + version: "3.14" + toxenv: py314,smoke steps: - - uses: actions/checkout@v4.2.2 + - uses: actions/checkout@v6.0.1 - name: Set up Python ${{ matrix.python.version }} - uses: actions/setup-python@v5.6.0 + uses: actions/setup-python@v6.1.0 with: python-version: ${{ matrix.python.version }} - name: Install dependencies @@ -67,11 +65,11 @@ jobs: matrix: toxenv: [api_func_v4, cli_func_v4] steps: - - uses: actions/checkout@v4.2.2 + - uses: actions/checkout@v6.0.1 - name: Set up Python - uses: actions/setup-python@v5.6.0 + uses: actions/setup-python@v6.1.0 with: - python-version: "3.13" + python-version: "3.14" - name: Install dependencies run: pip install tox - name: Run tests @@ -79,7 +77,7 @@ jobs: TOXENV: ${{ matrix.toxenv }} run: tox -- --override-ini='log_cli=True' - name: Upload codecov coverage - uses: codecov/codecov-action@v5.4.3 + uses: codecov/codecov-action@v5.5.2 with: files: ./coverage.xml flags: ${{ matrix.toxenv }} @@ -89,11 +87,11 @@ jobs: coverage: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4.2.2 + - uses: actions/checkout@v6.0.1 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5.6.0 + uses: actions/setup-python@v6.1.0 with: - python-version: "3.13" + python-version: "3.14" - name: Install dependencies run: pip install tox - name: Run tests @@ -102,7 +100,7 @@ jobs: TOXENV: cover run: tox - name: Upload codecov coverage - uses: codecov/codecov-action@v5.4.3 + uses: codecov/codecov-action@v5.5.2 with: files: ./coverage.xml flags: unit @@ -113,16 +111,16 @@ jobs: runs-on: ubuntu-latest name: Python wheel steps: - - uses: actions/checkout@v4.2.2 - - uses: actions/setup-python@v5.6.0 + - uses: actions/checkout@v6.0.1 + - uses: actions/setup-python@v6.1.0 with: - python-version: "3.13" + python-version: "3.14" - name: Install dependencies run: | pip install -r requirements-test.txt - name: Build package run: python -m build -o dist/ - - uses: actions/upload-artifact@v4.6.2 + - uses: actions/upload-artifact@v6.0.0 with: name: dist path: dist @@ -131,12 +129,12 @@ jobs: runs-on: ubuntu-latest needs: [dist] steps: - - uses: actions/checkout@v4.2.2 + - uses: actions/checkout@v6.0.1 - name: Set up Python - uses: actions/setup-python@v5.6.0 + uses: actions/setup-python@v6.1.0 with: - python-version: '3.13' - - uses: actions/download-artifact@v4.3.0 + python-version: '3.14' + - uses: actions/download-artifact@v7.0.0 with: name: dist path: dist diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b1094aa9a..8a396443b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: python:3.13 +image: python:3.14 stages: - build diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aef5e4908..3b93e8655 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,24 +3,24 @@ default_language_version: repos: - repo: https://github.com/psf/black - rev: 25.1.0 + rev: 25.12.0 hooks: - id: black - repo: https://github.com/commitizen-tools/commitizen - rev: v4.8.2 + rev: v4.10.1 hooks: - id: commitizen stages: [commit-msg] - repo: https://github.com/pycqa/flake8 - rev: 7.2.0 + rev: 7.3.0 hooks: - id: flake8 - repo: https://github.com/pycqa/isort - rev: 6.0.1 + rev: 7.0.0 hooks: - id: isort - repo: https://github.com/pycqa/pylint - rev: v3.3.7 + rev: v4.0.4 hooks: - id: pylint additional_dependencies: @@ -32,7 +32,7 @@ repos: - requests-toolbelt==1.0.0 files: 'gitlab/' - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.15.0 + rev: v1.19.1 hooks: - id: mypy args: [] @@ -51,6 +51,6 @@ repos: - id: rst-directive-colons - id: rst-inline-touching-normal - repo: https://github.com/maxbrunet/pre-commit-renovate - rev: 40.31.0 + rev: 42.64.1 hooks: - id: renovate-config-validator diff --git a/.readthedocs.yml b/.readthedocs.yml index 2d561b88b..facdbd3f9 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,7 +3,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.11" + python: "3.13" sphinx: configuration: docs/conf.py diff --git a/CHANGELOG.md b/CHANGELOG.md index c4cf99cd4..de7c0d113 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,205 @@ # CHANGELOG +All versions below are listed in reverse chronological order. + +## v7.0.0 (2025-10-29) + +### Features + +- Drop Python 3.9 support and add Python 3.14 + ([`22941ac`](https://github.com/python-gitlab/python-gitlab/commit/22941acc3f331d5b683599c014ec962ece5d4b76)) + +### Breaking Changes + +- As of python-gitlab 7.0.0, Python 3.9 is no longer supported. Python 3.10 or higher is required. + + +## v6.5.0 (2025-10-17) + +### Bug Fixes + +- **semantic-release**: Enable CHANGELOG.md generation + ([`fb9693b`](https://github.com/python-gitlab/python-gitlab/commit/fb9693bf1e6798149196e57fed87bf2588ad3b47)) + +### Continuous Integration + +- **stale**: Fix permission for stale action and allow manual run + ([`9357a37`](https://github.com/python-gitlab/python-gitlab/commit/9357a374702dcc8049a6d8af636f48c736d3f160)) + +### Documentation + +- **pull_mirror**: Fix incorrect start() method usage example + ([`2acac19`](https://github.com/python-gitlab/python-gitlab/commit/2acac19356c8624def90c7e54237b256bceece18)) + +### Features + +- **api**: Add content_ref and dry_run_ref parameters to ProjectCiLintManager + ([`e8d2538`](https://github.com/python-gitlab/python-gitlab/commit/e8d2538cdf85a7c57babbc00074efbdab97548cd)) + +- **users**: Implement 'skip_confirmation' in users 'emails' creation + ([`2981730`](https://github.com/python-gitlab/python-gitlab/commit/298173017be387f26aa0828cae1e9a48e3cce328)) + + +## v6.4.0 (2025-09-28) + +### Features + +- **users**: Implement missing arguments in users 'list' + ([`99923d4`](https://github.com/python-gitlab/python-gitlab/commit/99923d40dcb4f32f02bcbc5e8ef5ec4b77e3cb02)) + +- **users**: Sort 'user list' arguments against documentation + ([`99923d4`](https://github.com/python-gitlab/python-gitlab/commit/99923d40dcb4f32f02bcbc5e8ef5ec4b77e3cb02)) + + +## v6.3.0 (2025-08-28) + +### Features + +- Add sync method to force remote mirror updates + ([`f3c6678`](https://github.com/python-gitlab/python-gitlab/commit/f3c6678482b7ca35b1dd1e3bc49fc0c56cd03639)) + +- **api**: Add missing ProjectJob list filters + ([`5fe0e71`](https://github.com/python-gitlab/python-gitlab/commit/5fe0e715448b00a666f76cdce6db321686f6a271)) + +- **api**: Add missing ProjectPackageManager list filters + ([`b1696be`](https://github.com/python-gitlab/python-gitlab/commit/b1696be5fb223028755e303069e23e42a11cab42)) + +- **users**: Implement support for 'admins' in administrators 'list' + ([`aaed51c`](https://github.com/python-gitlab/python-gitlab/commit/aaed51cdec65c8acabe8b9a39fd18c7e1e48519c)) + + +## v6.2.0 (2025-07-28) + +### Build System + +- **release**: Use correct python-semantic-release/publish-action + ([`2f20634`](https://github.com/python-gitlab/python-gitlab/commit/2f20634b9700bc802177278ffdd7bdf83ef1605a)) + +### Continuous Integration + +- **stale**: Improve formatting of stale message + ([`0ef20d1`](https://github.com/python-gitlab/python-gitlab/commit/0ef20d1b0ee6cd82c4e34003aca4c0c72935f4d9)) + +- **stale**: Increase `operations-per-run` to 500 + ([`326e1a4`](https://github.com/python-gitlab/python-gitlab/commit/326e1a46881467f41dc3de5f060ac654924fbe40)) + +### Features + +- **api**: Add ListMixin to ProjectIssueDiscussionNoteManager + ([`f908f0e`](https://github.com/python-gitlab/python-gitlab/commit/f908f0e82840a5df374e8fbfb1298608d23f02bd)) + +- **api**: Add ListMixin to ProjectMergeRequestDiscussionNoteManager + ([`865339a`](https://github.com/python-gitlab/python-gitlab/commit/865339ac037fb125280180b05a2c4e44067dc5e9)) + + +## v6.1.0 (2025-06-28) + +### Chores + +- Update to mypy 1.16.0 and resolve issues found + ([`f734c58`](https://github.com/python-gitlab/python-gitlab/commit/f734c586e3fe5a0e866bcf60030107ca142fa763)) + +### Documentation + +- Update CONTRIBUTING.rst with policy on issue management + ([`45dda50`](https://github.com/python-gitlab/python-gitlab/commit/45dda50ff4c0e01307480befa86498600563f818)) + +### Features + +- **api**: Add listing user contributed projects + ([`98c1307`](https://github.com/python-gitlab/python-gitlab/commit/98c13074127ae46d85545498746d55c8b75aef48)) + +- **api**: Add support for project tag list filters + ([`378a836`](https://github.com/python-gitlab/python-gitlab/commit/378a836bf5744ca6c9409dd60899e5d2f90b55be)) + +- **api**: Pipeline inputs support + ([#3194](https://github.com/python-gitlab/python-gitlab/pull/3194), + [`306c4b1`](https://github.com/python-gitlab/python-gitlab/commit/306c4b1931e2b03d7cbcef5773668e876d5644b1)) + +- **const**: Add PLANNER_ACCESS constant + ([`ba6f174`](https://github.com/python-gitlab/python-gitlab/commit/ba6f174896f908ba711e1e3e8ebf4692c86bd3d4)) + +- **groups**: Add protectedbranches to group class + ([#3164](https://github.com/python-gitlab/python-gitlab/pull/3164), + [`bfd31a8`](https://github.com/python-gitlab/python-gitlab/commit/bfd31a867547dffb2c2d54127e184fefa058cb30)) + + +## v6.0.0 (2025-06-04) + +### Chores + +- Add reformat code commit to .git-blame-ignore-revs + ([`a6ac939`](https://github.com/python-gitlab/python-gitlab/commit/a6ac9392b0e543df32adf9058f9808d199149982)) + +- Reformat code with skip_magic_trailing_comma = true + ([`2100aa4`](https://github.com/python-gitlab/python-gitlab/commit/2100aa458ba4f1c084bc97b00f7ba1693541d68a)) + +- Remove trivial get methods in preparation for generic Get mixin + ([`edd01a5`](https://github.com/python-gitlab/python-gitlab/commit/edd01a57aa8c45e6514e618263003beaa0fb68e8)) + +- Upgrade to sphinx 8.2.1 and resolve issues + ([`d0b5ae3`](https://github.com/python-gitlab/python-gitlab/commit/d0b5ae36bd0bc06f1f338adbd93d76a83a0fa459)) + +- **ci**: Replace docs artifact with readthedocs previews + ([`193c5de`](https://github.com/python-gitlab/python-gitlab/commit/193c5de9b443193da3f87d664a777f056d920146)) + +### Documentation + +- Use get_all keyword arg instead of all in docstrings + ([`f62dda7`](https://github.com/python-gitlab/python-gitlab/commit/f62dda7fa44e3bc46f03bd6402eba3f641f365eb)) + +- Use list(get_all=True) in documentation examples + ([`f36614f`](https://github.com/python-gitlab/python-gitlab/commit/f36614f1ce5a873ed1bbb8618ced39fa80f13ee6)) + +- **api-usage**: Fix GitLab API links to the publicly accessible URLs + ([`f55fa15`](https://github.com/python-gitlab/python-gitlab/commit/f55fa152cdccc0dd4815f17df9ff80628115667d)) + +- **api-usage-graphql**: Fix the example graphql query string + ([`8dbdd7e`](https://github.com/python-gitlab/python-gitlab/commit/8dbdd7e75447d01a457ac55f18066ebd355e4dbf)) + +- **job_token_scope**: Fix typo/inconsistency + ([`203bd92`](https://github.com/python-gitlab/python-gitlab/commit/203bd92e524845a3e1287439d78c167133347a69)) + +### Features + +- Adds member role methods + ([`055557e`](https://github.com/python-gitlab/python-gitlab/commit/055557efe9de9d4ab7b8237f7de7e033a6b02cd9)) + +- **api**: Add iteration_id as boards create attribute + ([#3191](https://github.com/python-gitlab/python-gitlab/pull/3191), + [`938b0d9`](https://github.com/python-gitlab/python-gitlab/commit/938b0d9c188bcffc6759184325bf292131307556)) + +- **api**: Add support for adding instance deploy keys + ([`22be96c`](https://github.com/python-gitlab/python-gitlab/commit/22be96cbe698f5d8b18be388edf9b01d6008d1dd)) + +- **api**: Add support for avatar removal + ([`5edd2e6`](https://github.com/python-gitlab/python-gitlab/commit/5edd2e66cd5d4cd48fcf5f996d4ad4c3d495b3fa)) + +- **api**: Add support for token self-rotation + ([`da40e09`](https://github.com/python-gitlab/python-gitlab/commit/da40e09498277467878b810aa44f86b48813d832)) + +- **api**: ListMixin.list typing overload + ([`6eee494`](https://github.com/python-gitlab/python-gitlab/commit/6eee494749ccc5387a0d3af7ce331cfb1e95308b)) + +- **api**: Make RESTManager generic on RESTObject class + ([`91c4f18`](https://github.com/python-gitlab/python-gitlab/commit/91c4f18dc49a7eed101ce5f004f396436c6ef7eb)) + +- **api**: Make RESTObjectList typing generic + ([`befba35`](https://github.com/python-gitlab/python-gitlab/commit/befba35a16c5543c5f270996a9bf7a4277482915)) + +- **settings**: Implement support for 'silent_mode_enabled' + ([`a9163a9`](https://github.com/python-gitlab/python-gitlab/commit/a9163a9775b3f9a7b729048fab83bb0bca7228b5)) + +### Refactoring + +- Use more python3.9 syntax + ([`4e90c11`](https://github.com/python-gitlab/python-gitlab/commit/4e90c113f1af768b8b049f4a64c5978a1bfbf323)) + +### Testing + +- **functional**: Switch to new runner registration API + ([`cbc613d`](https://github.com/python-gitlab/python-gitlab/commit/cbc613d0f2ccd8ec021bf789b337104489a3e5f1)) + ## v5.6.0 (2025-01-28) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 90c6c1e70..9b07ada11 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -9,6 +9,42 @@ You can contribute to the project in multiple ways: * Add unit and functional tests * Everything else you can think of +Issue Management and Our Approach to Contributions +-------------------------------------------------- + +We value every contribution and bug report. However, as an open-source project +with limited maintainer resources, we rely heavily on the community to help us +move forward. + +**Our Policy on Inactive Issues:** + +To keep our issue tracker manageable and focused on actionable items, we have +the following approach: + +* **We encourage reporters to propose solutions:** If you report an issue, we + strongly encourage you to also think about how it might be fixed and try to + implement that fix. +* **Community interest is key:** Issues that garner interest from the community + (e.g., multiple users confirming, discussions on solutions, offers to help) + are more likely to be addressed. +* **Closing inactive issues:** If an issue report doesn't receive a proposed + fix from the original reporter or anyone else in the community, and there's + no active discussion or indication that someone is willing to work on it + after a reasonable period, it may be closed. + + * When closing such an issue, we will typically leave a comment explaining + that it's being closed due to inactivity and a lack of a proposed fix. + +* **Reopening issues:** This doesn't mean the issue isn't valid. If you (or + someone else) are interested in working on a fix for a closed issue, please + comment on the issue. We are more than happy to reopen it and discuss your + proposed pull request or solution. We greatly appreciate it when community + members take ownership of fixing issues they care about. + +We believe this approach helps us focus our efforts effectively and empowers +the community to contribute directly to the areas they are most passionate +about. + Development workflow -------------------- diff --git a/README.rst b/README.rst index 101add1eb..1b7b7ce48 100644 --- a/README.rst +++ b/README.rst @@ -53,7 +53,7 @@ Features Installation ------------ -As of 5.0.0, ``python-gitlab`` is compatible with Python 3.9+. +As of 7.0.0, ``python-gitlab`` is compatible with Python 3.10+. Use ``pip`` to install the latest stable version of ``python-gitlab``: diff --git a/docs/gl_objects/ci_lint.rst b/docs/gl_objects/ci_lint.rst index b44b09486..69a403eac 100644 --- a/docs/gl_objects/ci_lint.rst +++ b/docs/gl_objects/ci_lint.rst @@ -46,6 +46,18 @@ Lint a project's CI configuration:: assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid print(lint_result.merged_yaml) # Print the merged YAML file +Lint a project's CI configuration from a specific branch or tag:: + + lint_result = project.ci_lint.get(content_ref="main") + assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid + print(lint_result.merged_yaml) # Print the merged YAML file + +Lint a project's CI configuration with dry run simulation:: + + lint_result = project.ci_lint.get(dry_run=True, dry_run_ref="develop") + assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid + print(lint_result.merged_yaml) # Print the merged YAML file + Lint a CI YAML configuration with a namespace:: lint_result = project.ci_lint.create({"content": gitlab_ci_yml}) diff --git a/docs/gl_objects/protected_branches.rst b/docs/gl_objects/protected_branches.rst index ce5e300db..a1b1ef5c5 100644 --- a/docs/gl_objects/protected_branches.rst +++ b/docs/gl_objects/protected_branches.rst @@ -2,8 +2,8 @@ Protected branches ################## -You can define a list of protected branch names on a repository. Names can use -wildcards (``*``). +You can define a list of protected branch names on a repository or group. +Names can use wildcards (``*``). References ---------- @@ -13,19 +13,24 @@ References + :class:`gitlab.v4.objects.ProjectProtectedBranch` + :class:`gitlab.v4.objects.ProjectProtectedBranchManager` + :attr:`gitlab.v4.objects.Project.protectedbranches` + + :class:`gitlab.v4.objects.GroupProtectedBranch` + + :class:`gitlab.v4.objects.GroupProtectedBranchManager` + + :attr:`gitlab.v4.objects.Group.protectedbranches` * GitLab API: https://docs.gitlab.com/api/protected_branches#protected-branches-api Examples -------- -Get the list of protected branches for a project:: +Get the list of protected branches for a project or group:: - p_branches = project.protectedbranches.list(get_all=True) + p_branches = project.protectedbranches.list() + p_branches = group.protectedbranches.list() Get a single protected branch:: p_branch = project.protectedbranches.get('main') + p_branch = group.protectedbranches.get('main') Update a protected branch:: diff --git a/docs/gl_objects/pull_mirror.rst b/docs/gl_objects/pull_mirror.rst index bc83ba36d..19e8a1946 100644 --- a/docs/gl_objects/pull_mirror.rst +++ b/docs/gl_objects/pull_mirror.rst @@ -33,6 +33,6 @@ Update an existing remote mirror's attributes:: mirror.only_protected_branches = True mirror.save() -Start an sync of the pull mirror:: +Start a sync of the pull mirror:: - mirror.start() + project.pull_mirror.start() diff --git a/docs/gl_objects/remote_mirrors.rst b/docs/gl_objects/remote_mirrors.rst index b4610117d..c672ca5bb 100644 --- a/docs/gl_objects/remote_mirrors.rst +++ b/docs/gl_objects/remote_mirrors.rst @@ -36,3 +36,7 @@ Update an existing remote mirror's attributes:: Delete an existing remote mirror:: mirror.delete() + +Force push mirror update:: + + mirror.sync() diff --git a/docs/gl_objects/users.rst b/docs/gl_objects/users.rst index 185167f92..5ebfa296b 100644 --- a/docs/gl_objects/users.rst +++ b/docs/gl_objects/users.rst @@ -107,6 +107,10 @@ Get the followings of a user:: user.following_users.list(get_all=True) +List a user's contributed projects:: + + user.contributed_projects.list(get_all=True) + List a user's starred projects:: user.starred_projects.list(get_all=True) diff --git a/gitlab/_version.py b/gitlab/_version.py index 695245ebb..e7817062d 100644 --- a/gitlab/_version.py +++ b/gitlab/_version.py @@ -3,4 +3,4 @@ __email__ = "gauvainpocentek@gmail.com" __license__ = "LGPL3" __title__ = "python-gitlab" -__version__ = "5.6.0" +__version__ = "7.0.0" diff --git a/gitlab/cli.py b/gitlab/cli.py index a3ff5b5b4..ca4734190 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -107,7 +107,7 @@ def gitlab_resource_to_cls( return class_type -def cls_to_gitlab_resource(cls: RESTObject) -> str: +def cls_to_gitlab_resource(cls: type[RESTObject]) -> str: dasherized_uppercase = camel_upperlower_regex.sub(r"\1-\2", cls.__name__) dasherized_lowercase = camel_lowerupper_regex.sub(r"\1-\2", dasherized_uppercase) return dasherized_lowercase.lower() diff --git a/gitlab/const.py b/gitlab/const.py index 9e0b766ea..7a0492e64 100644 --- a/gitlab/const.py +++ b/gitlab/const.py @@ -93,6 +93,7 @@ class PipelineStatus(GitlabEnum): NO_ACCESS = AccessLevel.NO_ACCESS.value MINIMAL_ACCESS = AccessLevel.MINIMAL_ACCESS.value GUEST_ACCESS = AccessLevel.GUEST.value +PLANNER_ACCESS = AccessLevel.PLANNER.value REPORTER_ACCESS = AccessLevel.REPORTER.value DEVELOPER_ACCESS = AccessLevel.DEVELOPER.value MAINTAINER_ACCESS = AccessLevel.MAINTAINER.value @@ -151,6 +152,7 @@ class PipelineStatus(GitlabEnum): "NOTIFICATION_LEVEL_PARTICIPATING", "NOTIFICATION_LEVEL_WATCH", "OWNER_ACCESS", + "PLANNER_ACCESS", "REPORTER_ACCESS", "SEARCH_SCOPE_BLOBS", "SEARCH_SCOPE_COMMITS", diff --git a/gitlab/utils.py b/gitlab/utils.py index bf37e09a5..cf1b5b7b0 100644 --- a/gitlab/utils.py +++ b/gitlab/utils.py @@ -133,7 +133,7 @@ def handle_retry_on_status( if "Retry-After" in headers: wait_time = int(headers["Retry-After"]) elif "RateLimit-Reset" in headers: - wait_time = int(headers["RateLimit-Reset"]) - time.time() + wait_time = max(0, int(headers["RateLimit-Reset"]) - time.time()) self.cur_retries += 1 time.sleep(wait_time) return True diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index 067a0a155..87fcaf261 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -394,7 +394,7 @@ def extend_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser: subparsers.required = True # populate argparse for all Gitlab Object - classes = set() + classes: set[type[gitlab.base.RESTObject]] = set() for cls in gitlab.v4.objects.__dict__.values(): if not isinstance(cls, type): continue diff --git a/gitlab/v4/objects/branches.py b/gitlab/v4/objects/branches.py index 0724476a6..12dbf8848 100644 --- a/gitlab/v4/objects/branches.py +++ b/gitlab/v4/objects/branches.py @@ -49,3 +49,27 @@ class ProjectProtectedBranchManager(CRUDMixin[ProjectProtectedBranch]): ), ) _update_method = UpdateMethod.PATCH + + +class GroupProtectedBranch(SaveMixin, ObjectDeleteMixin, RESTObject): + _id_attr = "name" + + +class GroupProtectedBranchManager(CRUDMixin[GroupProtectedBranch]): + _path = "/groups/{group_id}/protected_branches" + _obj_cls = GroupProtectedBranch + _from_parent_attrs = {"group_id": "id"} + _create_attrs = RequiredOptional( + required=("name",), + optional=( + "push_access_level", + "merge_access_level", + "unprotect_access_level", + "allow_force_push", + "allowed_to_push", + "allowed_to_merge", + "allowed_to_unprotect", + "code_owner_approval_required", + ), + ) + _update_method = UpdateMethod.PATCH diff --git a/gitlab/v4/objects/ci_lint.py b/gitlab/v4/objects/ci_lint.py index 01d38373d..9bbe9f7e4 100644 --- a/gitlab/v4/objects/ci_lint.py +++ b/gitlab/v4/objects/ci_lint.py @@ -51,7 +51,14 @@ class ProjectCiLintManager( _path = "/projects/{project_id}/ci/lint" _obj_cls = ProjectCiLint _from_parent_attrs = {"project_id": "id"} - _optional_get_attrs = ("dry_run", "include_jobs", "ref") + _optional_get_attrs = ( + "content_ref", + "dry_run", + "dry_run_ref", + "include_jobs", + "ref", + ) + _create_attrs = RequiredOptional( required=("content",), optional=("dry_run", "include_jobs", "ref") ) diff --git a/gitlab/v4/objects/groups.py b/gitlab/v4/objects/groups.py index 473b40391..7a1767817 100644 --- a/gitlab/v4/objects/groups.py +++ b/gitlab/v4/objects/groups.py @@ -24,6 +24,7 @@ from .audit_events import GroupAuditEventManager # noqa: F401 from .badges import GroupBadgeManager # noqa: F401 from .boards import GroupBoardManager # noqa: F401 +from .branches import GroupProtectedBranchManager # noqa: F401 from .clusters import GroupClusterManager # noqa: F401 from .container_registry import GroupRegistryRepositoryManager # noqa: F401 from .custom_attributes import GroupCustomAttributeManager # noqa: F401 @@ -102,6 +103,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): packages: GroupPackageManager projects: GroupProjectManager shared_projects: SharedProjectManager + protectedbranches: GroupProtectedBranchManager pushrules: GroupPushRulesManager registry_repositories: GroupRegistryRepositoryManager runners: GroupRunnerManager diff --git a/gitlab/v4/objects/jobs.py b/gitlab/v4/objects/jobs.py index 6aa6fc460..f0062c989 100644 --- a/gitlab/v4/objects/jobs.py +++ b/gitlab/v4/objects/jobs.py @@ -346,5 +346,5 @@ class ProjectJobManager(RetrieveMixin[ProjectJob]): _path = "/projects/{project_id}/jobs" _obj_cls = ProjectJob _from_parent_attrs = {"project_id": "id"} - _list_filters = ("scope",) + _list_filters = ("scope", "order_by", "sort") _types = {"scope": ArrayAttribute} diff --git a/gitlab/v4/objects/notes.py b/gitlab/v4/objects/notes.py index f104c3f5d..3e83d9be1 100644 --- a/gitlab/v4/objects/notes.py +++ b/gitlab/v4/objects/notes.py @@ -128,12 +128,7 @@ class ProjectIssueDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass -class ProjectIssueDiscussionNoteManager( - GetMixin[ProjectIssueDiscussionNote], - CreateMixin[ProjectIssueDiscussionNote], - UpdateMixin[ProjectIssueDiscussionNote], - DeleteMixin[ProjectIssueDiscussionNote], -): +class ProjectIssueDiscussionNoteManager(CRUDMixin[ProjectIssueDiscussionNote]): _path = ( "/projects/{project_id}/issues/{issue_iid}/discussions/{discussion_id}/notes" ) @@ -164,10 +159,7 @@ class ProjectMergeRequestDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject class ProjectMergeRequestDiscussionNoteManager( - GetMixin[ProjectMergeRequestDiscussionNote], - CreateMixin[ProjectMergeRequestDiscussionNote], - UpdateMixin[ProjectMergeRequestDiscussionNote], - DeleteMixin[ProjectMergeRequestDiscussionNote], + CRUDMixin[ProjectMergeRequestDiscussionNote] ): _path = ( "/projects/{project_id}/merge_requests/{mr_iid}/" diff --git a/gitlab/v4/objects/packages.py b/gitlab/v4/objects/packages.py index 1a59c7ec7..99edd2f83 100644 --- a/gitlab/v4/objects/packages.py +++ b/gitlab/v4/objects/packages.py @@ -220,6 +220,9 @@ class GroupPackageManager(ListMixin[GroupPackage]): "sort", "package_type", "package_name", + "package_version", + "include_versionless", + "status", ) @@ -234,7 +237,15 @@ class ProjectPackageManager( _path = "/projects/{project_id}/packages" _obj_cls = ProjectPackage _from_parent_attrs = {"project_id": "id"} - _list_filters = ("order_by", "sort", "package_type", "package_name") + _list_filters = ( + "order_by", + "sort", + "package_type", + "package_name", + "package_version", + "include_versionless", + "status", + ) class ProjectPackageFile(ObjectDeleteMixin, RESTObject): diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py index 0eaceb5a6..035b9b861 100644 --- a/gitlab/v4/objects/projects.py +++ b/gitlab/v4/objects/projects.py @@ -429,6 +429,7 @@ def trigger_pipeline( ref: str, token: str, variables: dict[str, Any] | None = None, + inputs: dict[str, Any] | None = None, **kwargs: Any, ) -> ProjectPipeline: """Trigger a CI build. @@ -439,6 +440,7 @@ def trigger_pipeline( ref: Commit to build; can be a branch name or a tag token: The trigger token variables: Variables passed to the build script + inputs: Inputs passed to the build script **kwargs: Extra options to send to the server (e.g. sudo) Raises: @@ -446,8 +448,14 @@ def trigger_pipeline( GitlabCreateError: If the server failed to perform the request """ variables = variables or {} + inputs = inputs or {} path = f"/projects/{self.encoded_id}/trigger/pipeline" - post_data = {"ref": ref, "token": token, "variables": variables} + post_data = { + "ref": ref, + "token": token, + "variables": variables, + "inputs": inputs, + } attrs = self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) if TYPE_CHECKING: assert isinstance(attrs, dict) @@ -1225,7 +1233,20 @@ def create(self, data: dict[str, Any] | None = None, **kwargs: Any) -> ProjectFo class ProjectRemoteMirror(ObjectDeleteMixin, SaveMixin, RESTObject): - pass + @cli.register_custom_action(cls_names="ProjectRemoteMirror") + @exc.on_http_error(exc.GitlabCreateError) + def sync(self, **kwargs: Any) -> dict[str, Any] | requests.Response: + """Force push mirror update. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabCreateError: If the server cannot perform the request + """ + path = f"{self.manager.path}/{self.encoded_id}/sync" + return self.manager.gitlab.http_post(path, **kwargs) class ProjectRemoteMirrorManager( diff --git a/gitlab/v4/objects/registry_protection_repository_rules.py b/gitlab/v4/objects/registry_protection_repository_rules.py index 19d4bdf59..2a457a024 100644 --- a/gitlab/v4/objects/registry_protection_repository_rules.py +++ b/gitlab/v4/objects/registry_protection_repository_rules.py @@ -1,5 +1,12 @@ from gitlab.base import RESTObject -from gitlab.mixins import CreateMixin, ListMixin, SaveMixin, UpdateMethod, UpdateMixin +from gitlab.mixins import ( + CreateMixin, + DeleteMixin, + ListMixin, + SaveMixin, + UpdateMethod, + UpdateMixin, +) from gitlab.types import RequiredOptional __all__ = [ @@ -16,6 +23,7 @@ class ProjectRegistryRepositoryProtectionRuleManager( ListMixin[ProjectRegistryRepositoryProtectionRule], CreateMixin[ProjectRegistryRepositoryProtectionRule], UpdateMixin[ProjectRegistryRepositoryProtectionRule], + DeleteMixin[ProjectRegistryRepositoryProtectionRule], ): _path = "/projects/{project_id}/registry/protection/repository/rules" _obj_cls = ProjectRegistryRepositoryProtectionRule diff --git a/gitlab/v4/objects/tags.py b/gitlab/v4/objects/tags.py index 7a559daa7..ad04b4928 100644 --- a/gitlab/v4/objects/tags.py +++ b/gitlab/v4/objects/tags.py @@ -19,6 +19,7 @@ class ProjectTagManager(NoUpdateMixin[ProjectTag]): _path = "/projects/{project_id}/repository/tags" _obj_cls = ProjectTag _from_parent_attrs = {"project_id": "id"} + _list_filters = ("order_by", "sort", "search") _create_attrs = RequiredOptional( required=("tag_name", "ref"), optional=("message",) ) diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py index 2c7c28a2c..be0e36529 100644 --- a/gitlab/v4/objects/users.py +++ b/gitlab/v4/objects/users.py @@ -68,6 +68,8 @@ "UserMembershipManager", "UserProject", "UserProjectManager", + "UserContributedProject", + "UserContributedProjectManager", ] @@ -182,6 +184,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject): memberships: UserMembershipManager personal_access_tokens: UserPersonalAccessTokenManager projects: UserProjectManager + contributed_projects: UserContributedProjectManager starred_projects: StarredProjectManager status: UserStatusManager @@ -397,16 +400,29 @@ class UserManager(CRUDMixin[User]): _obj_cls = User _list_filters = ( + "username", + "public_email", + "search", "active", + "external", "blocked", - "username", + "humans", + "created_after", + "created_before", + "exclude_active", + "exclude_external", + "exclude_humans", + "exclude_internal", + "without_project_bots", "extern_uid", "provider", - "external", - "search", + "two_factor", + "without_projects", + "admins", + "auditors", + "skip_ldap", "custom_attributes", "status", - "two_factor", ) _create_attrs = RequiredOptional( optional=( @@ -486,7 +502,9 @@ class UserEmailManager( _path = "/users/{user_id}/emails" _obj_cls = UserEmail _from_parent_attrs = {"user_id": "id"} - _create_attrs = RequiredOptional(required=("email",)) + _create_attrs = RequiredOptional( + required=("email",), optional=("skip_confirmation",) + ) class UserActivities(RESTObject): @@ -665,6 +683,17 @@ def list( return super().list(path=path, iterator=iterator, **kwargs) +class UserContributedProject(RESTObject): + _id_attr = "id" + _repr_attr = "path_with_namespace" + + +class UserContributedProjectManager(ListMixin[UserContributedProject]): + _path = "/users/{user_id}/contributed_projects" + _obj_cls = UserContributedProject + _from_parent_attrs = {"user_id": "id"} + + class StarredProject(RESTObject): pass diff --git a/pyproject.toml b/pyproject.toml index 5104c2b16..7b8510b94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ maintainers = [ {name = "Nejc Habjan", email="nejc.habjan@siemens.com"}, {name = "Roger Meier", email="r.meier@siemens.com"} ] -requires-python = ">=3.9.0" +requires-python = ">=3.10.0" dependencies = [ "requests>=2.32.0", "requests-toolbelt>=1.0.0", @@ -30,11 +30,11 @@ classifiers = [ "Operating System :: Microsoft :: Windows", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] keywords = ["api", "client", "gitlab", "python", "python-gitlab", "wrapper"] license = {text = "LGPL-3.0-or-later"} @@ -101,6 +101,13 @@ version_variables = [ ] commit_message = "chore: release v{version}" +[tool.semantic_release.changelog] +exclude_commit_patterns = [ + '''chore\(deps\): .+''', # Exclude dependency updates from the changelog +] +mode = "update" +insertion_flag = "All versions below are listed in reverse chronological order." + [tool.pylint.messages_control] max-line-length = 88 jobs = 0 # Use auto-detected number of multiple processes to speed up Pylint. diff --git a/requirements-docker.txt b/requirements-docker.txt index 98b70440c..123a4438a 100644 --- a/requirements-docker.txt +++ b/requirements-docker.txt @@ -1,3 +1,3 @@ -r requirements.txt -r requirements-test.txt -pytest-docker==3.2.1 +pytest-docker==3.2.5 diff --git a/requirements-docs.txt b/requirements-docs.txt index c951d81d5..8d756d4f1 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -1,7 +1,7 @@ -r requirements.txt -furo==2024.8.6 +furo==2025.12.19 jinja2==3.1.6 myst-parser==4.0.1 sphinx==8.2.3 sphinxcontrib-autoprogram==0.1.9 -sphinx-autobuild==2024.10.3 +sphinx-autobuild==2025.8.25 diff --git a/requirements-lint.txt b/requirements-lint.txt index 0620fc57d..5006460d1 100644 --- a/requirements-lint.txt +++ b/requirements-lint.txt @@ -1,14 +1,14 @@ -r requirements.txt argcomplete==2.0.0 -black==25.1.0 -commitizen==4.8.2 -flake8==7.2.0 -isort==6.0.1 -mypy==1.15.0 -pylint==3.3.7 -pytest==8.3.5 -responses==0.25.7 +black==25.12.0 +commitizen==4.10.1 +flake8==7.3.0 +isort==7.0.0 +mypy==1.19.1 +pylint==4.0.4 +pytest==9.0.2 +responses==0.25.8 respx==0.22.0 -types-PyYAML==6.0.12.20250516 -types-requests==2.32.0.20250515 -types-setuptools==80.8.0.20250521 +types-PyYAML==6.0.12.20250915 +types-requests==2.32.4.20250913 +types-setuptools==80.9.0.20251221 diff --git a/requirements-precommit.txt b/requirements-precommit.txt index d5c247795..fc2379223 100644 --- a/requirements-precommit.txt +++ b/requirements-precommit.txt @@ -1 +1 @@ -pre-commit==4.2.0 +pre-commit==4.5.1 diff --git a/requirements-test.txt b/requirements-test.txt index cfe179bf3..b06434452 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,13 +1,13 @@ -r requirements.txt -anyio==4.9.0 -build==1.2.2.post1 -coverage==7.8.2 +anyio==4.12.0 +build==1.3.0 +coverage==7.13.0 pytest-console-scripts==1.4.1 -pytest-cov==6.1.1 +pytest-cov==7.0.0 pytest-github-actions-annotate-failures==0.3.0 -pytest==8.3.5 -PyYaml==6.0.2 -responses==0.25.7 +pytest==9.0.2 +PyYaml==6.0.3 +responses==0.25.8 respx==0.22.0 -trio==0.30.0 +trio==0.32.0 wheel==0.45.1 diff --git a/requirements.txt b/requirements.txt index 5166aa6ee..6930e5d2c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ gql==3.5.3 httpx==0.28.1 -requests==2.32.3 +requests==2.32.5 requests-toolbelt==1.0.0 diff --git a/tests/functional/api/test_epics.py b/tests/functional/api/test_epics.py index a4f6765da..b61e23776 100644 --- a/tests/functional/api/test_epics.py +++ b/tests/functional/api/test_epics.py @@ -15,18 +15,20 @@ def test_epics(group): assert group.epics.list() -@pytest.mark.xfail(reason="404 on issue.id") def test_epic_issues(epic, issue): assert not epic.issues.list() + # FYI: Creating an issue causes a note to be created epic_issue = epic.issues.create({"issue_id": issue.id}) assert epic.issues.list() + # FYI: Deleting an issue causes a note to be created epic_issue.delete() def test_epic_notes(epic): - assert not epic.notes.list() + notes = epic.notes.list(get_all=True) epic.notes.create({"body": "Test note"}) - assert epic.notes.list() + new_notes = epic.notes.list(get_all=True) + assert len(new_notes) == (len(notes) + 1), f"{new_notes} {notes}" diff --git a/tests/functional/api/test_groups.py b/tests/functional/api/test_groups.py index 2485ac660..301fea6a2 100644 --- a/tests/functional/api/test_groups.py +++ b/tests/functional/api/test_groups.py @@ -312,6 +312,31 @@ def test_group_hooks(group): hook.delete() +def test_group_protected_branches(group, gitlab_version): + # Updating a protected branch at the group level is possible from Gitlab 15.9 + # https://docs.gitlab.com/api/group_protected_branches/ + can_update_prot_branch = gitlab_version.major > 15 or ( + gitlab_version.major == 15 and gitlab_version.minor >= 9 + ) + + p_b = group.protectedbranches.create( + {"name": "*-stable", "allow_force_push": False} + ) + assert p_b.name == "*-stable" + assert not p_b.allow_force_push + assert p_b in group.protectedbranches.list() + + if can_update_prot_branch: + p_b.allow_force_push = True + p_b.save() + + p_b = group.protectedbranches.get("*-stable") + if can_update_prot_branch: + assert p_b.allow_force_push + + p_b.delete() + + def test_group_transfer(gl, group): transfer_group = gl.groups.create( {"name": "transfer-test-group", "path": "transfer-test-group"} diff --git a/tests/functional/api/test_keys.py b/tests/functional/api/test_keys.py index 359649bef..6a2d660ed 100644 --- a/tests/functional/api/test_keys.py +++ b/tests/functional/api/test_keys.py @@ -38,6 +38,14 @@ def test_keys_deploy(gl, project, DEPLOY_KEY): key_by_fingerprint = gl.keys.get(fingerprint=fingerprint) assert key_by_fingerprint.title == key.title assert key_by_fingerprint.key == key.key - assert len(key_by_fingerprint.deploy_keys_projects) == 1 + + if not any( + key_project.get("project_id") == project.id + for key_project in key_by_fingerprint.deploy_keys_projects + ): + raise AssertionError( + f"Project {project} not found in 'deploy_keys_projects' " + f"{key_by_fingerprint.pformat()}" + ) key.delete() diff --git a/tests/functional/api/test_project_job_token_scope.py b/tests/functional/api/test_project_job_token_scope.py index 0d0466182..b1de0a7b2 100644 --- a/tests/functional/api/test_project_job_token_scope.py +++ b/tests/functional/api/test_project_job_token_scope.py @@ -1,3 +1,6 @@ +import pytest + + # https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html#allow-any-project-to-access-your-project def test_enable_limit_access_to_this_project(gl, project): scope = project.job_token_scope.get() @@ -10,6 +13,7 @@ def test_enable_limit_access_to_this_project(gl, project): assert scope.inbound_enabled +@pytest.mark.xfail(reason="https://gitlab.com/gitlab-org/gitlab/-/issues/582271") def test_disable_limit_access_to_this_project(gl, project): scope = project.job_token_scope.get() diff --git a/tests/functional/api/test_projects.py b/tests/functional/api/test_projects.py index 760f95336..c56b23ec7 100644 --- a/tests/functional/api/test_projects.py +++ b/tests/functional/api/test_projects.py @@ -26,9 +26,9 @@ def test_create_project(gl, user): sudo_project = gl.projects.create({"name": "sudo_project"}, sudo=user.id) - created = gl.projects.list() + created = gl.projects.list(get_all=True) created_gen = gl.projects.list(iterator=True) - owned = gl.projects.list(owned=True) + owned = gl.projects.list(owned=True, get_all=True) assert admin_project in created and sudo_project in created assert admin_project in owned and sudo_project not in owned diff --git a/tests/functional/api/test_registry.py b/tests/functional/api/test_registry.py index 91fdceacc..d234128ca 100644 --- a/tests/functional/api/test_registry.py +++ b/tests/functional/api/test_registry.py @@ -26,3 +26,8 @@ def test_project_protected_registry(project: Project): protected_registry.minimum_access_level_for_push = "owner" protected_registry.save() assert protected_registry.minimum_access_level_for_push == "owner" + + protected_registry.delete() + + rules = project.registry_protection_repository_rules.list() + assert rules == [] diff --git a/tests/functional/fixtures/.env b/tests/functional/fixtures/.env index e85f85e6f..f33c35752 100644 --- a/tests/functional/fixtures/.env +++ b/tests/functional/fixtures/.env @@ -1,4 +1,4 @@ GITLAB_IMAGE=gitlab/gitlab-ee -GITLAB_TAG=17.8.2-ee.0 +GITLAB_TAG=18.7.0-ee.0 GITLAB_RUNNER_IMAGE=gitlab/gitlab-runner GITLAB_RUNNER_TAG=96856197 diff --git a/tests/functional/fixtures/docker-compose.yml b/tests/functional/fixtures/docker-compose.yml index f36f3d2fd..17562d5be 100644 --- a/tests/functional/fixtures/docker-compose.yml +++ b/tests/functional/fixtures/docker-compose.yml @@ -34,7 +34,7 @@ services: entrypoint: - /bin/sh - -c - - ruby /create_license.rb && /assets/wrapper + - ruby /create_license.rb && /assets/init-container volumes: - ${PWD}/tests/functional/fixtures/create_license.rb:/create_license.rb ports: diff --git a/tests/functional/helpers.py b/tests/functional/helpers.py index 090673bf7..9d313e540 100644 --- a/tests/functional/helpers.py +++ b/tests/functional/helpers.py @@ -9,6 +9,7 @@ import gitlab import gitlab.base import gitlab.exceptions +import gitlab.v4.objects SLEEP_INTERVAL = 0.5 TIMEOUT = 60 # seconds before timeout will occur @@ -37,6 +38,11 @@ def safe_delete(object: gitlab.base.RESTObject) -> None: object = manager.get(object.get_id()) # type: ignore[attr-defined] except gitlab.exceptions.GitlabGetError: return + # If object is already marked for deletion we have succeeded + if getattr(object, "marked_for_deletion_on", None) is not None: + # 'Group' and 'Project' objects have a 'marked_for_deletion_on' attribute + logging.info(f"{object!r} is marked for deletion.") + return if index: logging.info(f"Attempt {index + 1} to delete {object!r}.") @@ -52,22 +58,16 @@ def safe_delete(object: gitlab.base.RESTObject) -> None: # we shouldn't cause test to fail if it still exists return elif isinstance(object, gitlab.v4.objects.Project): - # Immediately delete rather than waiting for at least 1day - # https://docs.gitlab.com/ee/api/projects.html#delete-project - object.delete(permanently_remove=True) - pass + # Starting in GitLab 18, projects can't be immediately deleted. + # So this will mark it for deletion. + object.delete() else: # We only attempt to delete parent groups to prevent dangling sub-groups - # However parent groups can only be deleted on a delay in Gl 16 + # However parent groups can only be deleted on a delay in GitLab 16 # https://docs.gitlab.com/ee/api/groups.html#remove-group object.delete() except gitlab.exceptions.GitlabDeleteError: - logging.info(f"{object!r} already deleted or scheduled for deletion.") - if isinstance(object, gitlab.v4.objects.Group): - # Parent groups can never be immediately deleted in GL 16, - # so don't cause test to fail if it still exists - return - pass + logging.exception(f"Error attempting to delete: {object.pformat()}") time.sleep(SLEEP_INTERVAL) pytest.fail(f"{object!r} was not deleted") diff --git a/tests/unit/objects/test_registry_protection_rules.py b/tests/unit/objects/test_registry_protection_rules.py index 3078278f5..3e9db414a 100644 --- a/tests/unit/objects/test_registry_protection_rules.py +++ b/tests/unit/objects/test_registry_protection_rules.py @@ -58,6 +58,17 @@ def resp_update_protected_registry(): yield rsps +@pytest.fixture +def resp_delete_protected_registry(): + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.DELETE, + url="http://localhost/api/v4/projects/1/registry/protection/repository/rules/1", + status=204, + ) + yield rsps + + def test_list_project_protected_registries(project, resp_list_protected_registries): protected_registry = project.registry_protection_repository_rules.list()[0] assert isinstance(protected_registry, ProjectRegistryRepositoryProtectionRule) @@ -80,3 +91,7 @@ def test_update_project_protected_registry(project, resp_update_protected_regist 1, {"repository_path_pattern": "abc*"} ) assert updated["repository_path_pattern"] == "abc*" + + +def test_delete_project_protected_registry(project, resp_delete_protected_registry): + project.registry_protection_repository_rules.delete(1) diff --git a/tests/unit/objects/test_remote_mirrors.py b/tests/unit/objects/test_remote_mirrors.py index f493032e8..be2aaaaba 100644 --- a/tests/unit/objects/test_remote_mirrors.py +++ b/tests/unit/objects/test_remote_mirrors.py @@ -54,6 +54,12 @@ def resp_remote_mirrors(): url="http://localhost/api/v4/projects/1/remote_mirrors/1", status=204, ) + + rsps.add( + method=responses.POST, + url="http://localhost/api/v4/projects/1/remote_mirrors/1/sync", + status=204, + ) yield rsps @@ -81,3 +87,9 @@ def test_update_project_remote_mirror(project, resp_remote_mirrors): def test_delete_project_remote_mirror(project, resp_remote_mirrors): mirror = project.remote_mirrors.create({"url": "https://example.com"}) mirror.delete() + + +def test_sync_project_remote_mirror(project, resp_remote_mirrors): + mirror = project.remote_mirrors.create({"url": "https://example.com"}) + response = mirror.sync() + assert response.status_code == 204 diff --git a/tests/unit/objects/test_users.py b/tests/unit/objects/test_users.py index c120581fe..ff8c4479d 100644 --- a/tests/unit/objects/test_users.py +++ b/tests/unit/objects/test_users.py @@ -7,7 +7,13 @@ import pytest import responses -from gitlab.v4.objects import StarredProject, User, UserMembership, UserStatus +from gitlab.v4.objects import ( + StarredProject, + User, + UserContributedProject, + UserMembership, + UserStatus, +) from .test_projects import project_content @@ -242,6 +248,19 @@ def resp_starred_projects(): yield rsps +@pytest.fixture +def resp_contributed_projects(): + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.GET, + url="http://localhost/api/v4/users/1/contributed_projects", + json=[project_content], + content_type="application/json", + status=200, + ) + yield rsps + + @pytest.fixture def resp_runner_create(): with responses.RequestsMock() as rsps: @@ -314,6 +333,12 @@ def test_list_followers(user, resp_followers_following): assert followings[1].id == 4 +def test_list_contributed_projects(user, resp_contributed_projects): + projects = user.contributed_projects.list() + assert isinstance(projects[0], UserContributedProject) + assert projects[0].id == project_content["id"] + + def test_list_starred_projects(user, resp_starred_projects): projects = user.starred_projects.list() assert isinstance(projects[0], StarredProject) diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py index af3dd3380..cad27afba 100644 --- a/tests/unit/test_cli.py +++ b/tests/unit/test_cli.py @@ -161,7 +161,7 @@ def error(self, message): "Raise error instead of exiting on invalid arguments, to make testing easier" raise ValueError(message) - class Fake: + class Fake(gitlab.base.RESTObject): _id_attr = None class FakeManager(CreateMixin, UpdateMixin, gitlab.base.RESTManager): diff --git a/tox.ini b/tox.ini index 05a15c6c4..0ba295692 100644 --- a/tox.ini +++ b/tox.ini @@ -2,14 +2,14 @@ minversion = 4.0 skipsdist = True skip_missing_interpreters = True -envlist = py313,py312,py311,py310,py39,black,isort,flake8,mypy,twine-check,cz,pylint +envlist = py314,py313,py312,py311,py310,black,isort,flake8,mypy,twine-check,cz,pylint # NOTE(jlvillal): To use a label use the `-m` flag. # For example to run the `func` label group of environments do: # tox -m func labels = lint = black,isort,flake8,mypy,pylint,cz - unit = py313,py312,py311,py310,py39,py38 + unit = py314,py313,py312,py311,py310 # func is the functional tests. This is very time consuming. func = cli_func_v4,api_func_v4