Skip to content

fix: workflow permissions#18

Merged
spalmurray merged 3 commits into
mainfrom
spalmurray/workflow-permissions-fix
May 16, 2025
Merged

fix: workflow permissions#18
spalmurray merged 3 commits into
mainfrom
spalmurray/workflow-permissions-fix

Conversation

@spalmurray
Copy link
Copy Markdown
Collaborator

@spalmurray spalmurray commented May 12, 2025

Fixes a bunch of errors in https://github.com/getsentry/prevent-cli/security/code-scanning

also tweaks the pre-commit hook to work with new command dump

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2025

❌ 10 Tests Failed:

Tests completed Failed Passed Skipped
7070 10 7060 0
View the top 3 failed test(s) by shortest run time
api.temp.calculator.test_calculator::test_divide
Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError
api.temp.calculator.test_calculator::test_divide
Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError
api.temp.calculator.test_calculator::test_divide
Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@spalmurray spalmurray marked this pull request as ready for review May 12, 2025 18:23
Comment thread hooks/pre-commit

python command_dump.py
git add codecovcli_commands
./command_dump.py
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

In a previous commit I made this directly executable. Locally the hook won't run without this change for me. I think my PATH is bad for whatever reason when running this hook. Could probably fix that, but this is easier and shouldn't break for anyone else 🙈

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.

You need to change the file to be executable before committing (chmod u+x command_dump.py) I believe

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.

hmmm, even with that, it throws an error

--> ./command_dump.py
./command_dump.py: line 1: import: command not found
./command_dump.py: line 4: syntax error near unexpected token `('
./command_dump.py: line 4: `def command_dump(commands):'

I assume because it's not in a python shell

Copy link
Copy Markdown
Collaborator Author

@spalmurray spalmurray May 12, 2025

Choose a reason for hiding this comment

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

command_dump.py has a shebang for python and is already executable - do you have latest main on this repo?

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.

strange, getting this error

tomhu@WLRW6YXHR9 [~/src/github/getsentry/prevent-cli] (main *)
--> ./command_dump.py
Dumping codecovcli
Dumping codecovcli create-commit
Dumping codecovcli create-report
Dumping codecovcli do-upload
Dumping codecovcli empty-upload
Dumping codecovcli pr-base-picking
Dumping codecovcli process-test-results
Dumping codecovcli send-notifications
Dumping codecovcli upload-coverage
Dumping codecovcli upload-process
Dumping sentry-prevent-cli
Traceback (most recent call last):
  File "/Users/tomhu/src/github/getsentry/prevent-cli/./command_dump.py", line 35, in <module>
    command_dump(["sentry-prevent-cli"], "prevent-cli/preventcli_commands")
  File "/Users/tomhu/src/github/getsentry/prevent-cli/./command_dump.py", line 7, in command_dump
    command_docs = subprocess.run(
                   ^^^^^^^^^^^^^^^
  File "/Users/tomhu/.pyenv/versions/3.11.5/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomhu/.pyenv/versions/3.11.5/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/tomhu/.pyenv/versions/3.11.5/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'sentry-prevent-cli'

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 guess are we assuming someone already has sentry-prevent-cli installed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes I guess it does assume that. It also assumes you have the codecov-cli installed. I'll add a check to the start of the script that checks for the executables and gives installation instructions otherwise.

@spalmurray spalmurray force-pushed the spalmurray/workflow-permissions-fix branch from 9f2dfc5 to fd92550 Compare May 14, 2025 20:51
@spalmurray spalmurray merged commit 1987577 into main May 16, 2025
27 checks passed
@spalmurray spalmurray deleted the spalmurray/workflow-permissions-fix branch May 16, 2025 16:12
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.

2 participants