Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Kiota generated Java SDK #50

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/build-java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "Generate Java SDK"

on:
pull_request:
workflow_dispatch:
schedule:
# Run generation nightly on latest OpenAPI spec
- cron: '0 0 * * *'

jobs:
build:
strategy:
fail-fast: false
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: maven

- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x'
Comment on lines +27 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x'
- uses: microsoft/[email protected]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to go in the direction you are proposing, but, currently, the installation of the tools is based on dotnet tool install, if we move to the specific GH Action it would be best to update all of the jobs.
Looking for the maintainers of this project guidance here.


- uses: actions/[email protected]
with:
go-version: '1.21.5'

- name: Install kiota
run: dotnet tool install --global Microsoft.OpenApi.Kiota --prerelease

Comment on lines +35 to +37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Install kiota
run: dotnet tool install --global Microsoft.OpenApi.Kiota --prerelease

- name: Clone the existing dotnet-sdk
run: |
cd ../
git clone https://github.com/octokit/java-sdk.git

- name: Download latest schema
run: go run schemas/main.go --schema-next=false

- name: Run generation
run: kiota generate -l java --ll trace -o $(pwd)/../java-sdk/src/main/java/com/github/api -c GitHubClient -n com.github.api -d schemas/downloaded.json --serializer none --deserializer none --ebc

- name: Build generated and processed SDK
run: |
cd ../java-sdk
mvn clean install

- uses: gr2m/create-or-update-pull-request-action@cd-path
if: github.event_name != 'pull_request' # do not update the SDK on PR builds
env:
GITHUB_TOKEN: ${{ secrets.OCTOKITBOT_PAT }}
with:
title: "Changes in generated code"
body: >
The latest OpenAPI spec resulted in changes to the generated code. Please review, set an applicable
commit message, merge, and tag a release as appropriate.
branch: "generated-code-update"
author: "Octokit Bot <[email protected]>"
commit-message: "New updates to generated code"
repository: "octokit/java-sdk"
path-to-cd-to: "../java-sdk"
8 changes: 8 additions & 0 deletions scripts/generate-java.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

./scripts/install-tools.sh

go run schemas/main.go --schema-next=false

# Execute generation
kiota generate -l java --ll trace -o generated/Java/src/main/java/com/github/api -c GitHubClient -n com.github.api -d schemas/downloaded.json --serializer none --deserializer none --co --ebc
2 changes: 1 addition & 1 deletion scripts/install-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
KIOTA_TOOL_NAME="microsoft.openapi.kiota"
# This version can only increase, never decrease. If you want to use a lower version, you need to uninstall the tool first.
# dotnet tool uninstall Microsoft.OpenApi.Kiota --global
KIOTA_TOOL_VERSION="v1.9.0-preview.202311300001"
KIOTA_TOOL_VERSION="v1.11.1"

# Check if the tool is installed globally
if dotnet tool list -g | grep -q $KIOTA_TOOL_NAME; then
Expand Down