Giter VIP home page Giter VIP logo

run-python-script-action's People

Contributors

bibo-joshi avatar jannekem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

run-python-script-action's Issues

Add access to context information

Is it possible to add support for accessing context information, like the github instance? I need to access data in it that is too large to store in an environment variable and that might contain characters that aren't escaped, so it's really difficult to deal with the data in a shell script (I.e. in run).

Provide functions to set outputs and environment variables

Just an idea that would make run-python-script-action even better.

I think the main use case is to set output or environment variables. run-python-script-action could provide functions to make this easier. You can prepend import gha to the script (perhaps controlled by an option) which provides these functions:

def set_output(name, value):
    print(f'::set-output {name}=stable::{value}')

def set_env(name, value):
    with open(os.getenv('GITHUB_ENV'), 'a') as env:
        print(f'{name}={value}', file=env)

So then a user could do something like:

- name: Find path to wheel
  uses: jannekem/run-python-script-action@v1
  with:
    script: |
      import os
      from pathlib import Path
      wheel_path = str(next(Path('dist').glob('*.whl')))
      gha.set_env('WHEEL_PATH', wheel_path)

Even better would be to also collect all output and environment variables and (optionally) print their names/values to the log, which can help with debugging.

Failing scripts should stop the job

Currently, when the Python script fails, due to an unhandled exception for example, the workflow will continue executing the next step.

Thanks for this useful action!

Warning: The `set-output` command is deprecated and will be disabled soon.

GitHub started printing this warning on set-output commands:

Warning: The set-output command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

You should change the set_output and save_state functions in util.py to print to the files pointed to by the GITHUB_OUTPUT and GITHUB_STATE environment variables instead of stdout.

python installation step failing

getting below error in workflow run

Run actions/setup-python@v[2](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:2)
  with:
    python-version: [3](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:3).x
    token: ***
  env:
    git_commit_count: 29182
  
Version 3.x was not found in the local cache
Version 3.x is available for downloading
Download from "https://github.com/actions/python-versions/releases/download/3.10.[4](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:4)-2268648287/python-3.10.4-win32-x64.zip"
Extract downloaded archive
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\git\_work\_temp\81a0a7f[5](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:5)-be12-44d[6](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:6)-96f6-241b9685fa98', 'C:\git\_work\_temp\3229e638-8a2[7](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:7)-495b-b49d-26a6b41a8d25')"
Execute installation script
Check if Python hostedtoolcache folder exist...

Create Python toolcache folder

Check if current Python version is installed...

No Python3.10.* found

Remove registry entries for Python 3.10(x64)...

Create Python 3.10.4 folder in C:\git\_work\_tool\Python

Copy Python binaries to C:\git\_work\_tool\Python\3.10.4\x64

Install Python 3.10.4 in C:\git\_work\_tool\Python...

Error: Error happened during Python installation
At C:\git\_work\_temp\3229e638-8a2[7](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:8)-495b-b49d-26a6b41a[8](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:9)d25\setup.ps1:[12](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:13)5 char:5
+     Throw "Error happened during Python installation"
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: + CategoryInfo          : OperationStopped: (Error happened ...on installation:String) [], RuntimeException
    + FullyQualifiedErrorId : Error happened during Python installation
Error: The process 'C:\Windows\System[32](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:33)\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1

Feature request, ability to run python file

Description

Ability to specify a file to run instead of the pure python script

Example:

- uses: actions/setup-python@v4
  with:
    python-version: '3.x'
- uses: jannekem/run-python-script-action@v1
  with:
    file: path/to/script.py

Seggestion

  • Ability to run python file
  • Ability to run python files on a specific branch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.