-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add environment variable check script (#126)
# Pull Request ## Description This change introduces a new Python script to check for required environment variables before the main execution. The script `check_environment_variables.py` is added to verify the presence of essential environment variables like `github_token` and `INPUT_REPOSITORY_OWNER`. The Dockerfile is updated to copy the new Python script and its `__init__.py` file to the root directory. The `run.sh` script now includes a step to execute this environment variable check before proceeding with the main execution. The Justfile is modified to include the new `python_scripts` directory in the ruff linting and formatting commands, ensuring code quality for the new additions. In the `pyproject.toml` file, a new rule is added to ignore the T201 (print statement) warning for files in the `python_scripts` directory, as printing is intentional for error reporting in the new script. These changes enhance the robustness of the execution environment by ensuring that all necessary variables are set before running the main process. fixes #125
- Loading branch information
1 parent
3ff9743
commit 2596b6f
Showing
10 changed files
with
113 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from os import getenv | ||
from sys import exit | ||
|
||
EXPECTED_ENVIRONMENT_VARIABLES = ["INPUT_GITHUB_TOKEN", "INPUT_REPOSITORY_OWNER"] | ||
|
||
for variable in EXPECTED_ENVIRONMENT_VARIABLES: | ||
if getenv(variable) is None: | ||
if "INPUT_" in variable: | ||
print(f'Error: Required environment variable {variable.removeprefix("INPUT_")} is not set') | ||
else: | ||
print(f"Error: Required environment variable {variable} is not set") | ||
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters