I am trying to run a python script with custom args in a Github workflow.
When my script runs on a local machine it uses the package python-git-info to retreive the current git commit and pass it to the logger. But within the workflow, I can get the commit using $(git rev-parse "$GITHUB_SHA"). I want to pass that to my script as an arg.
But my script always ignores the passed arg and refers to the default value. What am I missing?
Github workflow:
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Performance Checker
on:
pull_request:
types: [ labeled ]
jobs:
build:
if: ${{ github.event.label.name == 'breaker' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test performance of all algorithms to ensure nothing broke
run: |
python train.py --git_commit=$(git rev-parse "$GITHUB_SHA") --load_config=configs/*
Relevant python arg:
parser.add_argument(
'--git_commit',
type=str,
default=gitinfo.get_git_info()['commit'],
help='current git commit')
Error from workflow:
Traceback (most recent call last):
File "train.py", line 74, in <module>
default=gitinfo.get_git_info()['commit'],
TypeError: 'NoneType' object is not subscriptable
This error mesasge indicates to me that the script ignores the passed args and refers to the default value. Any help or insight would be immensely appreciated.
git rev-parse "$GITHUB_SHA"as a separate step and check the output?echo "COMMIT $(git rev-parse "$GITHUB_SHA")"I getCOMMIT 9940feaa831a52380cf74a5dc69c12bf47bc56f9.set -vbefore running the script so you can see what exactly is executed