Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: workflows: pin python dependencies #87609

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nashif
Copy link
Member

@nashif nashif commented Mar 25, 2025

Pin python dependencies to hashes and cleanup/unify python setup steps in
various workflows.

We now have one dependency file containing all requirements for github
actions that is managed centrally with hashes. No direct pip installs
are needed in workflow files and everything shall go via the
requirements file.

Pinning to specific version and hashes helps with preventing supply
chain attacks.

Signed-off-by: Anas Nashif anas.nashif@intel.com

@nashif nashif force-pushed the topic/ci/pin_deps branch 2 times, most recently from e13a855 to 68c2a9b Compare March 25, 2025 08:41
@nashif nashif force-pushed the topic/ci/pin_deps branch 2 times, most recently from 18b79c3 to 374367f Compare March 25, 2025 08:59
@nashif
Copy link
Member Author

nashif commented Mar 25, 2025

hmm, not sure about this one:

 Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.9/x64/bin/gitlint", line 5, in <module>
    from gitlint.cli import cli
  File "/opt/hostedtoolcache/Python/3.12.9/x64/lib/python3.12/site-packages/gitlint/cli.py", line 3, in <module>
    from gitlint.config import LintConfig, LintConfigError
  File "/opt/hostedtoolcache/Python/3.12.9/x64/lib/python3.12/site-packages/gitlint/config.py", line 2, in <module>
    import ConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
Compliance error, check for error messages in the "Run Compliance Tests" st

I have not seen this during testing :(

@pdgendt
Copy link
Collaborator

pdgendt commented Mar 25, 2025

hmm, not sure about this one:

 Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.9/x64/bin/gitlint", line 5, in <module>
    from gitlint.cli import cli
  File "/opt/hostedtoolcache/Python/3.12.9/x64/lib/python3.12/site-packages/gitlint/cli.py", line 3, in <module>
    from gitlint.config import LintConfig, LintConfigError
  File "/opt/hostedtoolcache/Python/3.12.9/x64/lib/python3.12/site-packages/gitlint/config.py", line 2, in <module>
    import ConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
Compliance error, check for error messages in the "Run Compliance Tests" st

I have not seen this during testing :(

Can we update the gitlint package? Also for the requirements.in file, we could specify gitlint-core instead.

@nashif nashif force-pushed the topic/ci/pin_deps branch 2 times, most recently from f7b1d2e to 4ebcffb Compare March 26, 2025 02:24
pdgendt
pdgendt previously approved these changes Mar 26, 2025
@kartben
Copy link
Collaborator

kartben commented Mar 27, 2025

I think you will need to update dependabot configuration as well dependabot/dependabot-core#10040 (comment)

hmm, is this reallyneeded? we do have a requirements.txt file in this case. Anyways, one step at a time, I do not think we need to change depandabot workflow for this to go in, no?

Well I would argue we do. This effectively freezes all dependencies (duh!) so should any one of them be affected by a CVE 1/ we won't know about it and 2/, and more importantly, we will never get the fix that may come in a later version and will just be hard-stuck with the vulnerable version, where the current approach would at least have had the benefit to always give us the latest version of the package (for better or worse, too).

So what I'm saying is that basically we will need dependabot eventually if we are to pin dependencies ; and while it can be added in a PR coming shortly after this one, we do need to at least test it works and be confident it will be happy with managing uv compiled requirements before introducing this change in the first place.

In any case, CI seems to be failing so maybe that'll be the opportunity to add this to the next update :)

@nashif
Copy link
Member Author

nashif commented Mar 27, 2025

In any case, CI seems to be failing so maybe that'll be the opportunity to add this to the next update :)

maybe, but I prefer to do that later because tbh I have no idea what needs to be done.

Re this CI failure, I am not sure why the twister thing is failing with this version of python. @LukaszMrugala any idea?

@cfriedt
Copy link
Member

cfriedt commented Mar 27, 2025

Should help with caching / false positives as well.

@pdgendt
Copy link
Collaborator

pdgendt commented Mar 28, 2025

Why was the "Checkout source code" step skipped in the failed "Publish Unit Tests Results"? 🤔

@nashif nashif force-pushed the topic/ci/pin_deps branch from 30216ea to 81f8987 Compare March 28, 2025 10:19
@nashif
Copy link
Member Author

nashif commented Mar 28, 2025

Why was the "Checkout source code" step skipped in the failed "Publish Unit Tests Results"? 🤔

this is fixed now

@pdgendt
Copy link
Collaborator

pdgendt commented Mar 28, 2025

The commit to temporarily disable the failing test also touches the .github/workflows/twister.yaml file to checkout the pull request head. Is this intentional?

@nashif
Copy link
Member Author

nashif commented Mar 28, 2025

The commit to temporarily disable the failing test also touches the .github/workflows/twister.yaml file to checkout the pull request head. Is this intentional?

no, will fix, thanks.

@nashif nashif force-pushed the topic/ci/pin_deps branch from 81f8987 to fb12ef5 Compare March 28, 2025 19:05
@nashif
Copy link
Member Author

nashif commented Mar 28, 2025

The commit to temporarily disable the failing test also touches the .github/workflows/twister.yaml file to checkout the pull request head. Is this intentional?

no, will fix, thanks.

ok, fixed

@nashif nashif assigned nashif and stephanosio and unassigned aescolar Mar 28, 2025
@@ -178,7 +178,6 @@ jobs:
- name: Merge Test Results
run: |
pip install junitparser junit2html
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like you just dropped them as I can't see any step where you install the requirements?

Copy link
Member Author

Choose a reason for hiding this comment

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

those are already in the docker image, no need to install them

cache: pip
cache-dependency-path: scripts/requirements-actions.txt

- name: install-packages
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you have a chance to do a s/install-packages/Install Python packages/g so that steps have consistent naming that would be great (non blocking obviously)

Comment on lines 40 to 53
- name: Rebase
continue-on-error: true
env:
BASE_REF: ${{ github.base_ref }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
run: |
git config --global user.email "actions@zephyrproject.org"
git config --global user.name "Github Actions"
rm -fr ".git/rebase-apply"
rm -fr ".git/rebase-merge"
git rebase origin/${BASE_REF}
git clean -f -d
git log --graph --oneline HEAD...${PR_HEAD}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unrelated change?

nashif added 3 commits March 28, 2025 18:25
Pin python dependencies to hashes and cleanup/unify python setup steps in
various workflows.

We now have one dependency file containing all requirements for github
actions that is managed centrally with hashes. No direct pip installs
are needed in workflow files and everything shall go via the
requirements file.

Pinning to specific version and hashes helps with preventing supply
chain attacks.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Pin dependencies on the workflow and move it from using docker to the
zephyr setup action.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This test fails on older python versions (3.10) and only on CI.
Disabling it while we investigate. The test itself verifies inline logs
options, so the functionality test is not impacted.

Tracked in zephyrproject-rtos#87769

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
@nashif nashif force-pushed the topic/ci/pin_deps branch from 9b43181 to fc7e570 Compare March 28, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants