Skip to content

Commit e747c60

Browse files
committed
adjust pipelines and scripts
1 parent 247e120 commit e747c60

File tree

7 files changed

+63
-11
lines changed

7 files changed

+63
-11
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Generate SDK
2+
description: "Generates the Python SDK"
3+
inputs:
4+
python-version:
5+
description: "Python version to install"
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Download OAS
11+
shell: bash
12+
run: make download-oas
13+
- name: Generate SDK
14+
shell: bash
15+
run: make generate-sdk LANGUAGE=python

.github/workflows/ci.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
matrix:
1414
os: [ubuntu-latest, macos-latest]
1515
go-version: ["1.18", "1.19", "1.20", "1.21", "1.22"]
16+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
1617
runs-on: ${{ matrix.os }}
1718
steps:
1819
- name: Install SSH Key
@@ -31,16 +32,28 @@ jobs:
3132
uses: ./.github/actions/build
3233
with:
3334
go-version: ${{ env.GO_VERSION_BUILD }}
34-
- name: Generate SDK
35-
uses: ./.github/actions/generate-sdk
35+
- name: Generate Go SDK
36+
uses: ./.github/actions/generate-sdk/go
3637
- name: Install Go ${{ matrix.go-version }}
3738
uses: actions/setup-go@v5
3839
with:
3940
go-version: ${{ matrix.go-version }}
40-
- name: Lint
41+
- name: Lint Go SDK
4142
if: ${{ matrix.go-version == '1.19' || matrix.go-version == '1.20' || matrix.go-version == '1.21' || matrix.go-version == '1.22'}}
4243
working-directory: ./sdk-repo-updated
4344
run: make lint skip-non-generated-files=true
44-
- name: Test
45+
- name: Test Go SDK
4546
working-directory: ./sdk-repo-updated
4647
run: make test skip-non-generated-files=true
48+
- name: Generate Python SDK
49+
uses: ./.github/actions/generate-sdk/python
50+
- name: Install Python ${{ matrix.python-version }}
51+
uses: actions/setup-python@v5
52+
with:
53+
python-version: ${{ matrix.python-version }}
54+
- name: Lint Python SDK
55+
working-directory: ./sdk-repo-updated
56+
run: make lint
57+
- name: Test Python SDK
58+
working-directory: ./sdk-repo-updated
59+
run: make test

.github/workflows/sdk-pr.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@ jobs:
3131
uses: ./.github/actions/build
3232
with:
3333
go-version: ${{ env.GO_VERSION }}
34-
- name: Generate SDK
35-
uses: ./.github/actions/generate-sdk
36-
- name: Push SDK
34+
- name: Generate Go SDK
35+
uses: ./.github/actions/generate-sdk/go
36+
- name: Push Go SDK
3737
env:
3838
GH_REPO: 'stackitcloud/stackit-sdk-go'
3939
GH_TOKEN: ${{ secrets.SDK_PR_TOKEN }}
4040
run: |
41-
scripts/sdk-create-pr.sh "generator-bot-${{ github.run_id }}" "Generated from GitHub run [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
41+
scripts/sdk-create-pr.sh "generator-bot-${{ github.run_id }}" "Generated from GitHub run [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
42+
- name: Generate Python SDK
43+
uses: ./.github/actions/generate-sdk/python
44+
- name: Push Python SDK
45+
env:
46+
GH_REPO: 'stackitcloud/stackit-sdk-python'
47+
GH_TOKEN: ${{ secrets.SDK_PR_TOKEN }}
48+
run: |
49+
scripts/sdk-create-pr.sh "generator-bot-${{ github.run_id }}" "Generated from GitHub run [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" "[email protected]:stackitcloud/stackit-sdk-python.git" "python"

scripts/generate-sdk/.openapi-generator-ignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ git_push.sh
55
README.md
66
response.go
77
api/openapi.yaml
8-
.openapi-generator/*
8+
.openapi-generator/*
9+
.gitlab-ci.yml
10+
setup.cfg
11+
setup.py
12+
test-requirements.txt
13+
requirements.txt
14+
tox.ini
15+
*/.github/*

scripts/generate-sdk/languages/python.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
set -eo pipefail
55

66
ROOT_DIR=$(git rev-parse --show-toplevel)
7-
SDK_REPO_LOCAL_PATH="${ROOT_DIR}/python-sdk-repo-updated"
7+
SDK_REPO_LOCAL_PATH="${ROOT_DIR}/sdk-repo-updated"
88

99
OAS_REPO=https://github.com/stackitcloud/stackit-api-specifications
1010

@@ -113,6 +113,8 @@ generate_python_sdk() {
113113
rm "${SERVICES_FOLDER}/${service}/.openapi-generator-ignore"
114114
rm -r "${SERVICES_FOLDER}/${service}/.openapi-generator/"
115115
rm "${SERVICES_FOLDER}/${service}/stackit/__init__.py"
116+
rm "${SERVICES_FOLDER}/${service}/.github/workflows/python.yml"
117+
116118

117119
# If the service has a wait package files, move them inside the service folder
118120
if [ -d ${sdk_services_backup_dir}/${service}/wait ]; then

scripts/sdk-create-pr.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ else
3333
REPO_URL_SSH=$3
3434
fi
3535

36+
if [[ -z $4 ]]; then
37+
echo "LANGUAGE not specified, default will be used."
38+
LANGUAGE="go"
39+
else
40+
LANGUAGE="python"
41+
fi
42+
3643
# Create temp directory to work on
3744
work_dir=$(mktemp -d)
3845
if [[ ! ${work_dir} || -d {work_dir} ]]; then
@@ -83,7 +90,7 @@ for service_path in ${work_dir}/sdk_to_push/services/*; do
8390
fi
8491

8592
git add services/${service}/
86-
if [ ! -d "${work_dir}/sdk_backup/services/${service}/" ]; then # Check if it is a newly added SDK module
93+
if [ "${LANGUAGE}" == "go" ] && [ ! -d "${work_dir}/sdk_backup/services/${service}/" ]; then # Check if it is a newly added SDK module
8794
# go work use -r adds a use directive to the go.work file for dir, if it exists, and removes the use directory if the argument directory doesn’t exist
8895
# the -r flag examines subdirectories of dir recursively
8996
# this prevents errors if there is more than one new module in the SDK generation

0 commit comments

Comments
 (0)