From 786dc00d47be8366c1c99974cae2b09ce587b343 Mon Sep 17 00:00:00 2001 From: Paul Saunders Date: Mon, 2 Oct 2023 13:29:38 +0100 Subject: [PATCH] fix: Pipeline readiness fixes Signed-off-by: Paul Saunders --- Dockerfile | 6 +++--- Dockerfile.cicd | 4 ++-- generate/config-template.json | 2 ++ generate/generate.sh | 2 +- justfile | 26 ++++++++++++++++++++++---- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7c08e49..0d46ea9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM rust:latest as rust +FROM rust:slim-buster as rust RUN cargo install just -FROM openapitools/openapi-generator-cli:latest-release as maven +FROM openapitools/openapi-generator-cli:v7.0.0 as maven -RUN apt update && apt -y install jq git +RUN apt update && apt -y install jq git gettext-base libicu-dev # need to install the following for python RUN apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev liblzma-dev \ && cd tmp \ diff --git a/Dockerfile.cicd b/Dockerfile.cicd index b1a47e4..5ac0daf 100644 --- a/Dockerfile.cicd +++ b/Dockerfile.cicd @@ -2,9 +2,9 @@ FROM rust:slim-buster as rust RUN cargo install just -FROM openapitools/openapi-generator-cli:latest-release as maven +FROM openapitools/openapi-generator-cli:v7.0.0 as maven -RUN apt update && apt -y install jq git gettext-base +RUN apt update && apt -y install jq git gettext-base libicu-dev # need to install the following for python RUN apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev liblzma-dev \ && cd tmp \ diff --git a/generate/config-template.json b/generate/config-template.json index f4bcea6..87d8634 100644 --- a/generate/config-template.json +++ b/generate/config-template.json @@ -8,6 +8,8 @@ "licenseInfo": "MIT", "datetimeFormat": "%Y-%m-%dT%H:%M:%S.%fZ", "isLusidPackage": true, + "gitUserId": "${GIT_USER_ID}", + "gitRepoId": "${GIT_REPO_ID}", "files": { "extensions/api_client_builder.mustache": { "destinationFilename": "${PACKAGE_NAME}/extensions/api_client_builder.py" diff --git a/generate/generate.sh b/generate/generate.sh index deac810..d3b468e 100755 --- a/generate/generate.sh +++ b/generate/generate.sh @@ -62,7 +62,7 @@ echo "[INFO] generating sdk version: ${PACKAGE_VERSION}" # generate the SDK java ${JAVA_OPTS} -jar /opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \ -i $sdk_output_folder/swagger.json \ - -g python-nextgen \ + -g python \ -o $sdk_output_folder \ -t $gen_root/templates \ -c $config_file diff --git a/justfile b/justfile index 65dffed..1411d20 100644 --- a/justfile +++ b/justfile @@ -51,10 +51,29 @@ generate TARGET_DIR: cp -R generate/.output/* {{TARGET_DIR}} +# Generate an SDK from a swagger.json and copy the output to the TARGET_DIR +generate-cicd TARGET_DIR: + mkdir -p {{TARGET_DIR}} + mkdir -p ./generate/.output + envsubst < generate/config-template.json > generate/.config.json + cp ./generate/.openapi-generator-ignore ./generate/.output/.openapi-generator-ignore + + ./generate/generate.sh ./generate ./generate/.output {{swagger_path}} .config.json + rm -f generate/.output/.openapi-generator-ignore + + # need to remove the created content before copying over the top of it. + # this prevents deleted content from hanging around indefinitely. + rm -rf {{TARGET_DIR}}/sdk/${PACKAGE_NAME} + rm -rf {{TARGET_DIR}}/sdk/docs + + cp -R generate/.output/. {{TARGET_DIR}} + echo "copied output to {{TARGET_DIR}}" + ls {{TARGET_DIR}} + publish-only-local: docker run \ -v $(pwd)/generate/.output:/usr/src \ - finbourne/lusid-sdk-gen-python:latest -- "cd sdk; poetry build" + finbourne/lusid-sdk-gen-python:latest -- bash -ce "cd sdk; poetry build" mkdir -p ${PYPI_PACKAGE_LOCATION} cp generate/.output/sdk/dist/* ${PYPI_PACKAGE_LOCATION} @@ -62,12 +81,11 @@ publish-only: docker run \ -e POETRY_PYPI_TOKEN_PYPI:${PYPI_TOKEN} \ -v $(pwd)/generate/.output:/usr/src \ - finbourne/lusid-sdk-gen-python:latest -- "cd sdk; poetry publish" + finbourne/lusid-sdk-gen-python:latest -- bash -ce "cd sdk; poetry publish" publish-cicd SRC_DIR: echo "PACKAGE_VERSION to publish: ${PACKAGE_VERSION}" - cd {{SRC_DIR}}/sdk - poetry publish + poetry publish --build --repository ${REPOSITORY_NAME} --directory {{SRC_DIR}}/sdk publish-to SRC_DIR OUT_DIR: echo "PACKAGE_VERSION to publish: ${PACKAGE_VERSION}"