Skip to content

add dependency-update workflow template (fixes #683)#756

Draft
Rimsha2535 wants to merge 5 commits intomainfrom
feature/dependency-update-workflow
Draft

add dependency-update workflow template (fixes #683)#756
Rimsha2535 wants to merge 5 commits intomainfrom
feature/dependency-update-workflow

Conversation

@Rimsha2535
Copy link
Copy Markdown

@Rimsha2535 Rimsha2535 commented Mar 19, 2026

Fixes #683

Checklist

Note: If any of the items in the checklist are not relevant to your PR, just check the box.

For any Pull Request

Is the following correct:

  • the title of the Pull Request?
  • the title of the corresponding issue?
  • there are no other open [Pull Requests](../../../../pulls) for the same update/change?
  • that the issue which this Pull Request fixes ("Fixes...") is mentioned?

When Changes Were Made

Did you:

  • update the changelog?
  • update the cookiecutter-template?
  • update the implementation?
  • check coverage and add tests: unit tests and, if relevant, integration tests?
  • update the User Guide & other documentation?
  • resolve any failing CI criteria (incl. Sonar quality gate)?

When Preparing a Release

Have you:

  • thought about version number (major, minor, patch)?
  • checked Exasol packages for updates and resolved open vulnerabilities, if easily possible?

Notes

  • Changelog was not updated because this is an internal workflow/template change.
  • No separate cookiecutter-template update was needed because the workflow template itself was updated.
  • CI checks are currently failing and will be fixed.

@Rimsha2535 Rimsha2535 requested a review from kratz00 March 19, 2026 14:30
@kratz00 kratz00 changed the title add dependency-update workflow template add dependency-update workflow template (fixes #683) Mar 19, 2026
@Rimsha2535 Rimsha2535 requested a review from ArBridgeman March 30, 2026 12:41
Comment thread .github/workflows/dependency-update.yml
Comment thread exasol/toolbox/templates/github/workflows/dependency-update.yml

- name: Audit Dependencies
id: audit-dependencies
run: poetry run -- nox -s dependency:audit
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can ask the users of the python-toolbox what they'd prefer.

When I'd written that we perform a check by running poetry run -- nox -s dependency:audit, I had thought we could check to see if there are vulnerabilities detected or not. If there were vulnerabilities, then we'd proceed with updating the dependencies. Otherwise, we would skip the update.

One way to do this would be to check the length of the produced JSON;

# this will both print the results & output them to a json file
poetry run -- nox -s dependency:audit | tee vulnerabilities.json

LENGTH=$(jq 'length' vulnerabilities.json)
echo "count=$LENGTH" >> $GITHUB_OUTPUT

In the next step, where we run update-dependencies, we can add an if-statement

if: steps.audit-dependencies.outputs.count > 0

Comment thread exasol/toolbox/templates/github/workflows/dependency-update.yml Outdated
Comment thread .github/workflows/dependency-update.yml
Comment thread doc/github_actions/dependency_update.rst Outdated
Comment thread doc/github_actions/dependency_update.rst Outdated
Comment thread exasol/toolbox/templates/github/workflows/dependency-update.yml Outdated
Comment thread test/integration/project-template/nox_test.py
Comment thread exasol/toolbox/templates/github/workflows/dependency-update.yml Outdated
Comment thread exasol/toolbox/templates/github/workflows/dependency-update.yml Outdated
Comment thread exasol/toolbox/templates/github/workflows/dependency-update.yml
@Rimsha2535 Rimsha2535 requested a review from ArBridgeman April 14, 2026 14:35
@sonarqubecloud
Copy link
Copy Markdown

``report.yml``. See :ref:`ci_yml` for a graph of workflow calls.
* - ``dependency-update.yml``
- Weekly and manual
- Audits project dependencies for known vulnerabilities, updates them with Poetry when needed, and creates a pull request if ``poetry.lock`` changes.
Copy link
Copy Markdown
Collaborator

@ArBridgeman ArBridgeman Apr 15, 2026

Choose a reason for hiding this comment

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

Suggested change
- Audits project dependencies for known vulnerabilities, updates them with Poetry when needed, and creates a pull request if ``poetry.lock`` changes.
- Audits project dependencies for known vulnerabilities, updates them with Poetry when needed, and creates a pull request if the ``poetry.lock`` was changed.

It can be triggered manually and is also scheduled to run weekly.

The workflow first audits dependencies for known vulnerabilities. If vulnerabilities
are detected, it updates the dependencies using Poetry. When ``poetry.lock`` changes,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
are detected, it updates the dependencies using Poetry. When ``poetry.lock`` changes,
are detected, it updates the dependencies using Poetry. When the ``poetry.lock`` is changed,


The workflow first audits dependencies for known vulnerabilities. If vulnerabilities
are detected, it updates the dependencies using Poetry. When ``poetry.lock`` changes,
it creates a pull request with the update.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
it creates a pull request with the update.
then it creates a pull request with the update.

Dependency Update
^^^^^^^^^^^^^^^^^

The ``dependency-update.yml`` workflow helps keep project dependencies up to date.
Copy link
Copy Markdown
Collaborator

@ArBridgeman ArBridgeman Apr 15, 2026

Choose a reason for hiding this comment

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

Suggested change
The ``dependency-update.yml`` workflow helps keep project dependencies up to date.
The ``dependency-update.yml`` workflow is used to resolve vulnerabilities by updating our project dependencies.


.. _ci_yml:

Pull Request
Copy link
Copy Markdown
Collaborator

@ArBridgeman ArBridgeman Apr 15, 2026

Choose a reason for hiding this comment

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

You should also add a changelog entry for this in doc/changes/unreleased.md.
You can check out doc/changes/changes_6.3.0.md for inspiration.

For adding it to the changelog:

  1. Add an entry under the section Features. We tend to keep these to a short sentence description that follows the format:
  • #<GitHub issue number>: <Past tense verb> <clause describing the changes>
  1. Depending on the change, we add a longer description under Summary. In this case, I think it's worthwhile to add a few sentences and link to the documentation . This is because the CI will change for other projects due to this.

@@ -0,0 +1,93 @@
name: Dependency Update
Copy link
Copy Markdown
Collaborator

@ArBridgeman ArBridgeman Apr 15, 2026

Choose a reason for hiding this comment

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

We also need to add documentation to:
https://exasol.github.io/python-toolbox/main/user_guide/configuration.html

To do that, we typically create a sub-page in the relevant area. In this case, we have a nice page that we can add to:
https://exasol.github.io/python-toolbox/main/user_guide/features/github_workflows/github_project_configuration.html#

Under the section Secret, we should add the Slack token name, similar to how the PYPI_TOKEN was done. Maybe then, we should also provide a link using RST (not a hyperlink) to your Dependency Update section you wrote, but we could also leave that away.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The Slack token name is INTEGRATION_TEAM_SECURITY_UPDATES_WEBHOOK,
and it's used for the SLACK_WEBHOOK_URL. We don't need to put SLACK_WEBHOOK_URL in the description, but it might be helpful to know that for what you're writing 😉

@ArBridgeman
Copy link
Copy Markdown
Collaborator

ArBridgeman commented Apr 15, 2026

The GitHub workflow code looked good, but it's always good test, so here are those tests done via
another branch (nearly identical to this one):

Use cases:

  1. ✅ No vulnerability detected, so no update
    https://github.com/exasol/python-toolbox/actions/runs/24443525540/job/71414050584
  2. ✅ Vulnerability detected, do an update, & create PR
    https://github.com/exasol/python-toolbox/actions/runs/24444147768/job/71416082184

Example PR:
#780

Like @ckunki said, we likely need to modify this text more to tell the user what to do. But it sounds like this would be done in a later effort.


- name: Create branch
id: create-branch
if: steps.check-for-poetry-lock-changes.outputs.changed == 'true' && github.ref == 'refs/heads/main'
Copy link
Copy Markdown
Collaborator

@ArBridgeman ArBridgeman Apr 15, 2026

Choose a reason for hiding this comment

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

From Create Branch and down, we should adapt the if-statements.
I think it might be best if we introduced a check earlier on and set one variable for it.
Then, we don't need to do each of them in full again.

Discussion

Like I said, the default branch can differ for our projects between main and master

          format('refs/heads/{0}', github.event.repository.default_branch)

We mostly want to check if it's the default branch as we allow manual execution with workflow_dispatch. Perhaps in the future, we'll expand that, but we don't need that for now.

Suggested Execution Plan

  1. Add a step under Check out Repository where we check the default_branch. This would pass or fail and look similar to the following code. The output and such should be adapted so the default branch value is shown as well as the branch it's being executed on.
      - name: Fail if not running on the default branch
        id: check-branch
        if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch
        uses: actions/github-script@v8
        with:
          script: |
            core.setFailed('Not running on the default branch, github.ref is ${{ github.ref }}. Please start this workflow only on the default branch.')
  1. Then, we can simplify the later if-statements by removing the branch checks for these steps:
  • Create branch
  • Commit changes & push
  • Create pull request


gh pr create \
--base "$BASE_BRANCH" \
--title "Update poetry.lock" \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
--title "Update poetry.lock" \
--title "Update dependencies to fix vulnerabilities" \

Copy link
Copy Markdown
Contributor

@ckunki ckunki Apr 15, 2026

Choose a reason for hiding this comment

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

I assume the PRs to accumulate quite quick.
Should we assign a unique ID to the PR's title?

E.g.

  • the date, or
  • the dependencies, or vulnerabilities (probably too long and fuzzy)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like that idea. We could include the date, as we've also got it in the branch name


This PR was created by the dependency update workflow after running:
- \`poetry run -- nox -s dependency:audit\`
- \`poetry update\`"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Copy Markdown
Contributor

@ckunki ckunki left a comment

Choose a reason for hiding this comment

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

Added 2 comments

Comment on lines +37 to +50
assert "build-and-publish" in result.output
assert "cd" in result.output
assert "check-release-tag" in result.output
assert "checks" in result.output
assert "ci" in result.output
assert "dependency-update" in result.output
assert "gh-pages" in result.output
assert "matrix-all" in result.output
assert "matrix-exasol" in result.output
assert "matrix-python" in result.output
assert "merge-gate" in result.output
assert "pr-merge" in result.output
assert "report" in result.output
assert "slow-checks" in result.output
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert "build-and-publish" in result.output
assert "cd" in result.output
assert "check-release-tag" in result.output
assert "checks" in result.output
assert "ci" in result.output
assert "dependency-update" in result.output
assert "gh-pages" in result.output
assert "matrix-all" in result.output
assert "matrix-exasol" in result.output
assert "matrix-python" in result.output
assert "merge-gate" in result.output
assert "pr-merge" in result.output
assert "report" in result.output
assert "slow-checks" in result.output
expected_substrings = """
build-and-publish
cd
check-release-tag
checks
ci
dependency-update
gh-pages
matrix-all
matrix-exasol
matrix-python
merge-gate
pr-merge
report
slow-checks
"""
actual = set(result.output.split())
expected = set(expected_substrings.split())
assert expected.issubset(actual)

run: |
branch_name="dependency-update/$(date "+%Y%m%d%H%M%S")"
echo "Creating branch $branch_name"
git checkout -b "$branch_name"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
git checkout -b "$branch_name"
git switch -C "$branch_name"

Switch is recommended instead of checkout for creating and changing branches

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.

Create a template workflow to execute poetry update

4 participants