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

Repository Migration #1

Merged
merged 12 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 20 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Context

AI/ai-sdk-java-backlog#ISSUENUMBER.

Please provide a short description of what your change does and why it is needed.

### Feature scope:

- [ ] Task1
- [ ] Task2
- [ ] SubTask1

## Definition of Done

- [ ] Functionality scope stated & covered
- [ ] Tests cover the scope above
- [ ] ~Error handling created / updated & covered by the tests above~
- [ ] ~Aligned changes with the JavaScript SDK~
- [ ] ~Documentation updated~
- [ ] ~Release notes updated~
101 changes: 101 additions & 0 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: "Continuous Integration"
on:
pull_request:
branches: [ "*" ]

env:
MVN_MULTI_THREADED_ARGS: --batch-mode --no-transfer-progress --fail-at-end --show-version --threads 1C
MVN_SKIP_CI_PLUGINS: -DskipFormatting -Denforcer.skip -Djacoco.skip -Dmdep.analyze.skip
JAVA_VERSION: 17

jobs:

continous-integration:
# https://wiki.one.int.sap/wiki/display/DevFw/SUGAR
runs-on: ubuntu-latest
steps:

- name: "Checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.ref }}

- name: "Setup java"
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ env.JAVA_VERSION }}
cache: 'maven'

- name: "Format code"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} spotless:apply"
mvn $MVN_ARGS

- name: "Commit formatting changes if necessary"
run: |
diff=`git diff`
if [ ! -z "$diff" ]; then
git config --global user.email "[email protected]"
git config --global user.name "SAP Cloud SDK Bot"
git commit -am "Formatting"
git push
fi

- name: "Build SDK"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} clean install -DskipTests -DskipFormatting"
mvn $MVN_ARGS

- name: "Verify Local Changes"
run: |
CHANGED_FILES="$(git --no-pager diff --name-only)"
if [[ ! -z "$CHANGED_FILES" ]]; then
echo "There are local changes in the following files:"
echo "$CHANGED_FILES"
echo "Printing the git diff:"
git --no-pager diff
exit 1
fi

- name: "Checkstyle"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} ${{ env.MVN_SKIP_CI_PLUGINS }} -P!build-test-modules org.apache.maven.plugins:maven-checkstyle-plugin:checkstyle"
mvn $MVN_ARGS
python .pipeline/scripts/print-checkstyle.py

- name: "PMD"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} ${{ env.MVN_SKIP_CI_PLUGINS }} org.apache.maven.plugins:maven-pmd-plugin:pmd"
mvn $MVN_ARGS
python .pipeline/scripts/print-pmd.py

- name: "Spotbugs"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} ${{ env.MVN_SKIP_CI_PLUGINS }} com.github.spotbugs:spotbugs-maven-plugin:spotbugs"
mvn $MVN_ARGS
python .pipeline/scripts/print-spotbugs.py

- name: "Run Unit Tests"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} org.jacoco:jacoco-maven-plugin:prepare-agent surefire:test org.jacoco:jacoco-maven-plugin:report"
mvn $MVN_ARGS

- name: "Coverage Report"
run: python .pipeline/scripts/print-coverage.py --jacoco-report-pattern "**/target/site/jacoco/jacoco.csv"

- name: "Slack Notification"
## currently disabled, as there are no main builds yet
if: false
uses: slackapi/[email protected]
with:
payload: |
{
"text": "🚨 Main Build Failed! 😬 Please inspect & fix by clicking <https://github.com/SAP/ai-sdk-java/actions/runs/${{ github.run_id }}|here>"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
#TODO: CodeQL step
#TODO: Blackduck and security rating steps
39 changes: 39 additions & 0 deletions .github/workflows/deploy-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy Snapshot to internal SAP Artifactory

on:
workflow_dispatch:
schedule:
- cron: 0 20 * * 1-5

jobs:
deploy-snapshot:
name: Deploy Snapshot
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4

- name: "Setup java"
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
server-id: artifactory-snapshots
server-username: DEPLOYMENT_USER
server-password: DEPLOYMENT_PASS

- name: "Publish Snapshot"
run: >
mvn
--batch-mode
--no-transfer-progress
--threads 1C
--show-version
-DrepositoryId=artifactory-snapshots
-Dmaven.compiler.showCompilationChanges
-Dhttp.keepAlive=false
clean package deploy
env:
DEPLOYMENT_USER: ${{ secrets.ARTIFACTORY_COMMON_USER }}
DEPLOYMENT_PASS: ${{ secrets.ARTIFACTORY_COMMON_PASSWORD }}
72 changes: 72 additions & 0 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: "End-to-end Tests"
on:
workflow_dispatch:
schedule:
- cron: 0 22 * * *

env:
MVN_MULTI_THREADED_ARGS: --batch-mode --no-transfer-progress --fail-at-end --show-version --threads 1C
JAVA_VERSION: 17

jobs:

end-to-end-tests:
# https://wiki.one.int.sap/wiki/display/DevFw/SUGAR
runs-on: ubuntu-latest
steps:

- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Setup java"
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ env.JAVA_VERSION }}
cache: 'maven'

- name: "Build SDK"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} clean install -DskipTests -DskipFormatting"
mvn $MVN_ARGS

- name: "Run tests"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} surefire:test -pl :e2e-test-app -DskipTests=false"
mvn $MVN_ARGS
env:
# See "End-to-end test application instructions" on the README.md to update the secret
aicore: ${{ secrets.AICORE_SERVICE_KEY }}

- name: "Start Application Locally"
run: |
cd e2e-test-app
.mvn spring-boot:run &
timeout=15
while ! nc -z localhost 8080; do
sleep 1
timeout=$((timeout - 1))
if [ $timeout -le 0 ]; then
echo "Server did not start within 15 seconds."
exit 1
fi
done
env:
# See "End-to-end test application instructions" on the README.md to update the secret
aicore: ${{ secrets.AICORE_SERVICE_KEY }}

- name: "Health Check"
# print response body with headers to stdout. q:body only O:print -:stdout S:headers
run: wget -qO- -S localhost:8080

- name: "Slack Notification"
if: failure()
uses: slackapi/[email protected]
with:
payload: |
{
"text": "⚠️ End-to-end tests failed! 😬 Please inspect & fix by clicking <https://github.com/SAP/ai-sdk-java/actions/runs/${{ github.run_id }}|here>"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
111 changes: 111 additions & 0 deletions .github/workflows/update-aicore-specfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: "Weekly AI Core specification file update"

# Every Sunday at 00:00
on:
schedule:
- cron: "0 0 * * 0"
# also manually triggered
workflow_dispatch:

env:
MVN_MULTI_THREADED_ARGS: --batch-mode --no-transfer-progress --fail-at-end --show-version --threads 1C
SPECIFICATION_FILE_PATH: "core/src/main/resources/spec/aicore.yaml"
GENERATED_CLIENT_PATH: "core/src/main/java/com/sap/ai/sdk/core/client"
# https://cli.github.com/manual/gh_help_environment used for creating the pull request
GH_PUBLIC_TOKEN: ${{ secrets.PUBLIC_GITHUB_TOKEN }}
ASA1FINCLOUDOPER_WDF_TOKEN: ${{ secrets.ASA1FINCLOUDOPER_WDF_TOKEN }}
JAVA_VERSION: 17
MAVEN_VERSION: 3.9.8

jobs:
update-aicore-specification:
name: "Update AI Core specification"
runs-on: ubuntu-latest
steps:

- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Configure git"
run: |
git config --global user.email "[email protected]"
git config --global user.name "SAP Cloud SDK Bot"

- name: "Clone AI Core API repository"
run: |
git clone https://${{ env.ASA1FINCLOUDOPER_WDF_TOKEN }}@github.wdf.sap.corp/AI/apis.git

- name: "Copy AI Core specification file"
run: |
cp apis/aicore.yaml $SPECIFICATION_FILE_PATH
cat $SPECIFICATION_FILE_PATH

- name: "Exit if there are no changes"
run: |
! git diff --exit-code

- name: "Create branch"
run: |
git checkout -b update-aicore-specification

- name: "Commit specification file"
run: |
git add $SPECIFICATION_FILE_PATH
git commit -m "Update AI Core specification"
cat $SPECIFICATION_FILE_PATH

- name: "Push changes"
run: |
git push origin update-aicore-specification

create-pull-request:
name: "Create pull request"
runs-on: ubuntu-latest
needs: update-aicore-specification
steps:

- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Create pull request"
run: |
gh pr create --base main --head update-aicore-specification --title "Update AI Core specification" --body "
The AI Core [specification](https://github.wdf.sap.corp/AI/apis/blob/master/aicore.yaml) was updated | [release notes](https://github.wdf.sap.corp/AI/apis/blob/master/ai_api.changelog.txt)
Fixes were also automatically applied to the specification."

- name: "Handle failure"
if: ${{ failure() }}
run: |
git push origin --delete update-aicore-specification

generate-client:
name: "Generate AI Core client and push"
runs-on: ubuntu-latest
needs: create-pull-request
steps:

- name: "Checkout repository"
uses: actions/checkout@v4
with:
ref: update-aicore-specification

- name: "Setup java"
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ env.JAVA_VERSION }}
cache: 'maven'

- name: "Re-generate AI Core client"
run: |
rm -rf $GENERATED_CLIENT_PATH
mvn clean install -pl core -DskipTests ${{ env.MVN_MULTI_THREADED_ARGS }}

- name: "Commit generated client"
run: |
git add $GENERATED_CLIENT_PATH
git commit -m "Update AI Core client"

- name: "Push changes"
run: |
git push origin update-aicore-specification
11 changes: 11 additions & 0 deletions .pipeline/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">

<suppressions>
<!-- Suppress generated clients -->
<suppress files="[/\\]core/client[/\\]" checks=".*"/>
<suppress files="[/\\]orchestration/client[/\\]" checks=".*"/>
</suppressions>
Loading