From 7e79a887a9cd90919a158fe7b556b28cabadc03d Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Wed, 6 Oct 2021 20:30:42 -0600 Subject: [PATCH 1/5] fix: Black and isort would not run properly. --- .gitignore | 1 + entrypoint.sh | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/entrypoint.sh b/entrypoint.sh index 226dbf5..aaca9f2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,6 @@ #!/bin/bash +set -euo pipefail +IFS=$'\n\t' openapi_python_client_version=$1 openapi_file_path=$2 @@ -6,20 +8,21 @@ openapi_url=$3 config_file_path=$4 if [[ "$openapi_python_client_version" != "NOT_SPECIFIED" ]]; then - version_arg="--spec openapi-python-client==${openapi_python_client_version}" + version_arg="openapi-python-client==${openapi_python_client_version}" else - version_arg="" + version_arg="openapi-python-client" fi if [[ "$config_file_path" != "NOT_SPECIFIED" ]]; then - config_arg="--config ${config_file_path}" + config_arg="--config=${config_file_path}" else config_arg="" fi -openapi_document_path_or_url_arg="--path ${openapi_file_path}" +openapi_document_path_or_url_arg="--path=${openapi_file_path}" if [[ "$openapi_url" != "NOT_SPECIFIED" ]]; then - openapi_document_path_or_url_arg="--url ${openapi_url}" + openapi_document_path_or_url_arg="--url=${openapi_url}" fi -pipx run ${version_arg} openapi-python-client generate ${config_arg} ${openapi_document_path_or_url_arg} +pipx install "${version_arg}" --include-deps +openapi-python-client generate ${config_arg} ${openapi_document_path_or_url_arg} From eb6e513f1d8705d3d5e582a9357baee5c3f08f21 Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Wed, 6 Oct 2021 20:53:37 -0600 Subject: [PATCH 2/5] docs: Update README with new GitHub org. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c0365c..6b628a0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # openapi-python-client-action -The official GitHub Action for [openapi-python-client](https://github.com/triaxtec/openapi-python-client) - generates a modern Python client package from an OpenAPI document +The official GitHub Action for [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) - generates a modern Python client package from an OpenAPI document ## Inputs @@ -17,7 +17,7 @@ The url of the OpenAPI document. Overrides `openapi-file` - If unspecified the v ### `config-file` -The path (with respect to the current directory/the workspace) to the config.yml to be used with openapi-python-client. Configuaration is not required so if this is unspecified then no configuration will be passed along. See [openapi-python-client's README](https://github.com/triaxtec/openapi-python-client#configuration) for available configuration +The path (with respect to the current directory/the workspace) to the config.yml to be used with openapi-python-client. Configuaration is not required so if this is unspecified then no configuration will be passed along. See [openapi-python-client's README](https://github.com/openapi-generators/openapi-python-client#configuration) for available configuration ## Outputs @@ -41,7 +41,7 @@ jobs: # Use the action to generate a client package # This uses all defaults (latest version, openapi.json in the current workspace, no configuration) - name: Generate Python Client - uses: triaxtec/openapi-python-client-action@v2 + uses: openapi-generators/openapi-python-client-action@v2 # Do something with the generated client (likely publishing it somewhere) # Here we assume that the info/title in the openapi document was "example-project" From c3221cb1ec89a71664769a28adab37306a608920 Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Wed, 6 Oct 2021 20:54:04 -0600 Subject: [PATCH 3/5] refactor: Switch to python:3.9-slim image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8b47312..0f9a3ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9 +FROM python:3.9-slim RUN python -m pip install --upgrade pip RUN pip install pipx From a25cb9c648f5a953343617348b061b303f9f5a84 Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Wed, 6 Oct 2021 20:55:49 -0600 Subject: [PATCH 4/5] ci: Add GitHub Actions smoke test --- .github/workflows/checks.yml | 13 +++++++++++++ Dockerfile | 3 +-- entrypoint.sh | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/checks.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..eef4892 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,13 @@ +name: Run Checks + +on: + push + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: openapi-generators/openapi-python-client-action@updates + with: + openapi-url: https://raw.githubusercontent.com/openapi-generators/openapi-python-client/main/end_to_end_tests/openapi.json diff --git a/Dockerfile b/Dockerfile index 0f9a3ba..e22f801 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ FROM python:3.9-slim RUN python -m pip install --upgrade pip -RUN pip install pipx # Sets the user to the same user that the workflow runner uses so that it can access the generated client -USER 1001 +USER 1001 COPY entrypoint.sh /entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh index aaca9f2..dc98ef2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -24,5 +24,6 @@ if [[ "$openapi_url" != "NOT_SPECIFIED" ]]; then openapi_document_path_or_url_arg="--url=${openapi_url}" fi -pipx install "${version_arg}" --include-deps +PATH=$PATH:/github/home/.local/bin +pip install "${version_arg}" openapi-python-client generate ${config_arg} ${openapi_document_path_or_url_arg} From 58cf278ec5933c3867503056edcfceb028dda69e Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Wed, 6 Oct 2021 21:30:05 -0600 Subject: [PATCH 5/5] feat: Add extra-args arg (closes #4) --- .github/workflows/checks.yml | 2 +- README.md | 4 ++++ action.yml | 5 +++++ entrypoint.sh | 4 +++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index eef4892..08d824b 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -8,6 +8,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: openapi-generators/openapi-python-client-action@updates + - uses: openapi-generators/openapi-python-client-action@v2 with: openapi-url: https://raw.githubusercontent.com/openapi-generators/openapi-python-client/main/end_to_end_tests/openapi.json diff --git a/README.md b/README.md index 6b628a0..447d01e 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ The url of the OpenAPI document. Overrides `openapi-file` - If unspecified the v The path (with respect to the current directory/the workspace) to the config.yml to be used with openapi-python-client. Configuaration is not required so if this is unspecified then no configuration will be passed along. See [openapi-python-client's README](https://github.com/openapi-generators/openapi-python-client#configuration) for available configuration +### `extra-args` + +This is a catch-all to allow you to pass additional arguments to `openapi-python-client`. + ## Outputs No outputs are returned. diff --git a/action.yml b/action.yml index 8762f3a..0ce9d43 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,10 @@ inputs: description: Path to the config file to be passed along to openapi-python-client required: false default: NOT_SPECIFIED + extra-args: + description: Any additional arguments to forward to openapi-python-client + required: false + default: "" runs: using: "docker" @@ -30,3 +34,4 @@ runs: - ${{ inputs.openapi-file }} - ${{ inputs.openapi-url }} - ${{ inputs.config-file }} + - ${{ inputs.extra-args }} diff --git a/entrypoint.sh b/entrypoint.sh index dc98ef2..3a74825 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,6 +6,7 @@ openapi_python_client_version=$1 openapi_file_path=$2 openapi_url=$3 config_file_path=$4 +extra_args=$5 if [[ "$openapi_python_client_version" != "NOT_SPECIFIED" ]]; then version_arg="openapi-python-client==${openapi_python_client_version}" @@ -26,4 +27,5 @@ fi PATH=$PATH:/github/home/.local/bin pip install "${version_arg}" -openapi-python-client generate ${config_arg} ${openapi_document_path_or_url_arg} +# shellcheck disable=SC2086 +openapi-python-client generate $config_arg $openapi_document_path_or_url_arg $extra_args