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 addon rest-api #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 0 additions & 135 deletions .github/workflows/build-addon.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: CC0-1.0
on:
push:
branches:
- main
- "*/v*.*.*" # Match version tags for releases
pull_request:
branches:
- main

jobs:
code-quality:
runs-on: ubuntu-latest
name: Check code quality
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install pre-commit
run: python -m pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files
146 changes: 146 additions & 0 deletions .github/workflows/setup-build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: CC0-1.0
on:
push:
tags: ["*/v*.*.*"] # tags must be <addon-name>/v<version>
pull_request:
branches: [main]
jobs:
setup-build-release:
name: Setup, build, and release
runs-on: ubuntu-latest
strategy:
matrix:
capella-version: [6.0.0, 7.0.0]
include:
- capella-version: 6.0.0
java-execution-environment: JavaSE-17
jdk-version: 17.0.6+10
- capella-version: 7.0.0
java-execution-environment: JavaSE-17
jdk-version: 17.0.11+9
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Checkout code
uses: actions/checkout@v4
- name: Set up `capella-addons` CLI tool
run: pip install . && pip show capella-addons
- name: Identify addon and version
id: identify_addon_and_version
run: |
echo "GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME}"
echo "GITHUB_REF_NAME=${GITHUB_REF_NAME}"
VERSION=""
if [ ${GITHUB_EVENT_NAME} = "pull_request" ]; then
ADDON=${GITHUB_HEAD_REF}
elif [ ${GITHUB_EVENT_NAME} = "push" ]; then
if [[ ${GITHUB_REF_TYPE} == "tag" ]]; then
echo "This push is a tag: ${GITHUB_REF_NAME}"
ADDON=$(echo "${GITHUB_REF_NAME}" | sed 's|/.*||') # `sed` with `|` as delimiter
VERSION=$(echo "${GITHUB_REF_NAME}" | sed 's|[^/.]*/v||')
else
echo "This push is not a tag."
ADDON=${GITHUB_REF_NAME}
VERSION=$(python -m capella_addons --version | cut -d' ' -f2)
fi
fi
echo "addon=${ADDON}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Identified addon: ${ADDON}"
echo "Identified version: ${VERSION}"
- name: Set addon version
if: github.event_name == 'push' && github.ref_type == 'tag'
run: |
sed -i \
's/^Bundle-Version.*/Bundle-Version: ${{ steps.identify_addon_and_version.outputs.version }}/' \
${{ steps.identify_addon_and_version.outputs.addon }}/META-INF/MANIFEST.MF
head -n 10 \
${{ steps.identify_addon_and_version.outputs.addon }}/META-INF/MANIFEST.MF
python - <<EOF
from lxml import etree # lxml has been installed as dependency of capella-addons above
tree = etree.parse("${{ steps.identify_addon_and_version.outputs.addon }}/pom.xml")
tree.find(".//{http://maven.apache.org/POM/4.0.0}version").text = "${{ steps.identify_addon_and_version.outputs.version }}"
tree.write("${{ steps.identify_addon_and_version.outputs.addon }}/pom.xml", xml_declaration=True, encoding="UTF-8")
EOF
grep --color -B10 \
"<version>${{ steps.identify_addon_and_version.outputs.version }}</version>" \
${{ steps.identify_addon_and_version.outputs.addon }}/pom.xml
exit $?
- name: Set up Capella from ghcr.io/dsd-dbs/capella-dockerimages/capella/remote:${{ matrix.capella-version }}-selected-dropins-main
run: |
docker pull ghcr.io/dsd-dbs/capella-dockerimages/capella/remote:${{ matrix.capella-version }}-selected-dropins-main
if [ ! -d /tmp/capella_${{ matrix.capella-version }} ]; then
docker run --platform=linux/x86_64 --rm -v /tmp:/tmp --entrypoint="" --user=root \
ghcr.io/dsd-dbs/capella-dockerimages/capella/remote:${{ matrix.capella-version }}-selected-dropins-main \
bash -c "cp -r /opt/capella /tmp/capella_${{ matrix.capella-version }}"
fi
- name: Build `.classpath` file
run: |
cd ${{ steps.identify_addon_and_version.outputs.addon }}
python -m capella_addons build-classpath \
--java-execution-environment=${{ matrix.java-execution-environment }} \
$(find src -type f -name "Main.java") \
/tmp/capella_${{ matrix.capella-version }}
- name: Set up OpenAPI generator
if: steps.identify_addon_and_version.outputs.addon == 'rest-api'
run: |
curl -Lo /opt/openapi-generator.jar \
https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar
echo "java -jar /opt/openapi-generator.jar \$@" > /usr/local/bin/openapi-generator
chmod +x /usr/local/bin/openapi-generator
- name: Run OpenAPI generator
if: steps.identify_addon_and_version.outputs.addon == 'rest-api'
run: |
cd ${{ steps.identify_addon_and_version.outputs.addon }}
bash bin/jaxrs-jersey.zsh
rm -rf /tmp/src; cp -r src /tmp
- name: Set up Eclipse Temurin JDK ${{ matrix.jdk-version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.jdk-version }}
distribution: 'temurin'
java-package: "jdk"
- name: Set up Eclipse JDT language server 1.40.0
run: |
if [ ! -d /tmp/jdtls ]; then mkdir /tmp/jdtls; fi
cd /tmp/jdtls
if [ ! -f jdtls.tar.gz ]; then
curl -Lo jdtls.tar.gz \
https://download.eclipse.org/jdtls/milestones/1.40.0/jdt-language-server-1.40.0-202409261450.tar.gz
fi
tar xzf jdtls.tar.gz
rm *.tar.gz
- name: Build workspace
run: |
cd ${{ steps.identify_addon_and_version.outputs.addon }}
rm -rf target
python -m capella_addons -v \
build-workspace \
--java-execution-environment=${{ matrix.java-execution-environment }} \
$JAVA_HOME /tmp/jdtls
- name: Package addon
run: |
cd ${{ steps.identify_addon_and_version.outputs.addon }}
python -m capella_addons -v \
package \
$JAVA_HOME \
/tmp/capella_${{ matrix.capella-version }}
- name: Include Capella version in JAR file name
run: |
cd ${{ steps.identify_addon_and_version.outputs.addon }}
for file in target/*.jar; do
mv "$file" "${file%.jar}_capella_${{ matrix.capella-version }}.jar"
done
- name: Create release
if: github.event_name == 'push' && github.ref_type == 'tag'
uses: ncipollo/[email protected]
with:
name: ${{ steps.identify_addon_and_version.outputs.addon }} ${{ steps.identify_addon_and_version.outputs.version }}
artifacts: ${{ steps.identify_addon_and_version.outputs.addon }}/target/*.jar
allowUpdates: true
tag: ${{ github.ref_name }}
draft: false
prerelease: false
19 changes: 0 additions & 19 deletions CONTRIBUTING.md

This file was deleted.

Loading
Loading