8000 [PATCH] Cleanup from automated review in PR #6176 · RustPython/RustPython@1960425 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1960425

Browse files
[PATCH] Cleanup from automated review in PR #6176
* implemented fallback on Env logic for select inputs (override still prefered) Ref GHI #5974
1 parent b87cb8a commit 1960425

File tree

2 files changed

+50
-9
lines changed

2 files changed

+50
-9
lines changed

.github/actions/CI-5974-Fetch-CPython/action.yaml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ inputs:
1111
The GitHub repository to clone CPython from. When running this action on github.com,
1212
the default value is sufficient. Useful for Forks.
1313
required: true
14-
# keep it simple
1514
default: 'python/cpython'
1615
override-rustpython-path:
1716
description: |
1817
override value for path to the Python Lib. The default is to use the value of the environment
1918
variable 'RUSTPYTHONPATH'. Most users will find the default 'Lib' sufficient.
2019
required: true
21-
default: ${{ github.server_url == 'https://github.com' && env.RUSTPYTHONPATH || 'Lib' }}
20+
default: ''
2221
override-path:
2322
description: |
2423
Path to setup. When running this action on github.com, the default value
@@ -31,7 +30,7 @@ inputs:
3130
environment variable 'PYTHONPLATLIBDIR'. Most users will find the default 'Lib' sufficient.
3231
See https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPLATLIBDIR for more.
3332
required: true
34-
default: ${{ github.server_url == 'https://github.com' && env.PYTHONPLATLIBDIR || 'Lib' }}
33+
default: ''
3534
match:
3635
description: |
3736
Glob-style pattern of files or directories to match and integrate.
@@ -86,6 +85,34 @@ runs:
8685
printf "python-version=%s\n" "${PYTHON_VERSION}" >> "$GITHUB_OUTPUT"
8786
fi
8887
printf "%s\n" "PYTHON_VERSION=${PYTHON_VERSION}" >> "$GITHUB_ENV"
88+
- name: "Setup RustPython Lib Path"
89+
id: output_rpython_path
90+
env:
91+
RUST_PYTHON_LIB_PATH_INPUT: ${{ inputs.override-rustpython-path }}
92+
shell: bash
93+
run: |
94+
if [[ -n $RUST_PYTHON_LIB_PATH_INPUT ]]; then
95+
printf "::debug:: Initializing rust-python-path as ${RUST_PYTHON_LIB_PATH_INPUT}"
96+
printf "rust-python-path=%s\n" "${RUST_PYTHON_LIB_PATH_INPUT:-${RUSTPYTHONPATH:-Lib}}" >> "$GITHUB_OUTPUT"
97+
else
98+
printf "::debug:: Initializing rust-python-path as ${RUSTPYTHONPATH:-Lib}"
99+
printf "rust-python-path=%s\n" "${RUSTPYTHONPATH:-Lib}" >> "$GITHUB_OUTPUT"
100+
fi
101+
printf "%s\n" "RUSTPYTHONPATH=${RUST_PYTHON_LIB_PATH_INPUT:-${RUSTPYTHONPATH:-Lib}}" >> "$GITHUB_ENV"
102+
- name: "Setup cPython Lib Path"
103+
id: output_cpython_path
104+
env:
105+
PYTHONPLATLIBDIR_INPUT: ${{ inputs.override-cpython-lib-path }}
106+
shell: bash
107+
run: |
108+
if [[ -n $PYTHONPLATLIBDIR_INPUT ]]; then
109+
printf "::debug:: Initializing cpython-lib-path as ${PYTHONPLATLIBDIR_INPUT}"
110+
printf "cpython-lib-path=%s\n" "${PYTHONPLATLIBDIR_INPUT:-${PYTHONPLATLIBDIR:-Lib}}" >> "$GITHUB_OUTPUT"
111+
else
112+
printf "::debug:: Initializing cpython-lib-path as ${PYTHONPLATLIBDIR:-Lib}"
113+
printf "cpython-lib-path=%s\n" "${PYTHONPLATLIBDIR:-Lib}" >> "$GITHUB_OUTPUT"
114+
fi
115+
printf "%s\n" "PYTHONPLATLIBDIR=${PYTHONPLATLIBDIR_INPUT:-${PYTHONPLATLIBDIR:-Lib}}" >> "$GITHUB_ENV"
89116
- name: Fetch Reference Cpython ${{ matrix.python-version }} on ${{ matrix.os }}
90117
id: cpython
91118
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -94,7 +121,7 @@ runs:
94121
path: ${{ inputs.override-path }}
95122
fetch-tags: true
96123
sparse-checkout: |
97-
${{ inputs.override-cpython-lib-path }}
124+
${{ steps.output_cpython_path.outputs.cpython-lib-path }}
98125
ref: ${{ steps.output_python.outputs.python-version }}
99126
repository: ${{ inputs.override-repository }}
100127
# fixed settings
@@ -147,7 +174,7 @@ runs:
147174
cd ${{ inputs.override-path }} || exit 14 ;
148175
FILES=$(git ls-files --exclude-standard -- ${{ env.TEST_MATCH_PATTERN }} )
149176
if [ -z "$FILES" ]; then
150-
printf "%s\n" "::warning file=.github/actions/:: No ${{ inputs.override-cpython-lib-path }} Reference files found for Cpython ${{ inputs.python-version }} on ${{ runner.os }}." ;
177+
printf "%s\n" "::warning file=.github/actions/:: No ${{ steps.output_cpython_path.outputs.cpython-lib-path }} Reference files found for Cpython ${{ inputs.python-version }} on ${{ runner.os }}." ;
151178
printf "%s\n" "files=" >> "$GITHUB_OUTPUT"
152179
else
153180
printf "%s\n" "Reference files found:"

.github/actions/CI-5974-Fetch-RustPython/action.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ inputs:
2424
override value for path to the Python Lib. The default is to use the value of the environment
2525
variable 'RUSTPYTHONPATH'. Most users will find the default 'Lib' sufficient.
2626
required: true
27-
default: ${{ github.server_url == 'https://github.com' && env.RUSTPYTHONPATH || 'Lib' }}
27+
default: ''
2828
override-path:
2929
description: |
3030
Path to setup. When running this action on github.com, the default value
@@ -46,14 +46,28 @@ outputs:
4646
sha:
4747
description: "The SHA of the commit checked-out."
4848
value: ${{ steps.output_sha.outputs.sha || 'HEAD' }}
49-
rustpython-version:
49+
# rustpython-version:
5050
rustpython-lib-path:
5151
description: "The python version that was used in the run."
5252
value: ${{ steps.output_rpython_path.outputs.rustpython-lib-path }}
5353

5454
runs:
5555
using: composite
5656
steps:
57+
- name: "Setup RustPython Lib Path"
58+
id: setup_rpython_path
59+
env:
60+
RUST_PYTHON_LIB_PATH_INPUT: ${{ inputs.override-rustpython-path }}
61+
shell: bash
62+
run: |
63+
if [[ -n $RUST_PYTHON_LIB_PATH_INPUT ]]; then
64+
printf "::debug:: Initializing rust-python-path as ${RUST_PYTHON_LIB_PATH_INPUT}"
65+
printf "rust-python-path=%s\n" "${RUST_PYTHON_LIB_PATH_INPUT:-${RUSTPYTHONPATH:-Lib}}" >> "$GITHUB_OUTPUT"
66+
else
67+
printf "::debug:: Initializing rust-python-path as ${RUSTPYTHONPATH:-Lib}"
68+
printf "rust-python-path=%s\n" "${RUSTPYTHONPATH:-Lib}" >> "$GITHUB_OUTPUT"
69+
fi
70+
printf "%s\n" "RUSTPYTHONPATH=${RUST_PYTHON_LIB_PATH_INPUT:-${RUSTPYTHONPATH:-Lib}}" >> "$GITHUB_ENV"
5771
- name: Checkout repository
5872
id: rpython
5973
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -115,15 +129,15 @@ runs:
115129
if [[ "$RUNNER_DEBUG" == "true" ]] || [[ "$ACTIONS_STEP_DEBUG" == "true" ]]; then printf "::debug::Now Building '%s'\n" "RustPython" ; fi ;
116130
# Execute the testing command in a subshell
117131
(
118-
RUSTPYTHONPATH=${{ inputs.override-rustpython-path }} cargo run $CARGO_ARGS -- --version || printf "::error title='build failure':: Could not pass build step for version check on ${OS}.\n" ;
132+
RUSTPYTHONPATH=${{ steps.setup_rpython_path.outputs.rust-python-path }} cargo run $CARGO_ARGS -- --version || printf "::error title='build failure':: Could not pass build step for version check on ${OS}.\n" ;
119133
) ;
120134
printf "::endgroup::%s\n" ;
121135
cd ${{ steps.store_old_path.outputs.initial-path }} || exit 15 ;
122136
- id: output_rpython_path
123137
shell: bash
124138
run: |
125139
cd ${{ inputs.override-path }} || exit 13 ; # in case it is relative
126-
cd ${{ inputs.override-rustpython-path }} || exit 13 ;
140+
cd ${{ steps.setup_rpython_path.outputs.rust-python-path }} || exit 13 ;
127141
printf "RUSTPYTHONPATH=%s\n" $(pwd) >> "$GITHUB_ENV" ;
128142
printf "rustpython-lib-path=%s\n" $(pwd) >> "$GITHUB_OUTPUT" ;
129143
cd ${{ steps.store_old_path.outputs.initial-path }} || exit 15 ;

0 commit comments

Comments
 (0)
0