-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate Java API Client for Intelligence Service's OpenAPI Specifica…
…tions (#106) Co-authored-by: Felix T.J. Dietrich <[email protected]> Co-authored-by: Felix T.J. Dietrich <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8206fa9
commit 32dfb6d
Showing
30 changed files
with
2,484 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
.github/workflows/generate-intelligence-service-client.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: OpenAPI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, labeled, reopened] | ||
paths: | ||
- 'server/application-server/**' | ||
- '.github/workflows/generate-intelligence-service-client.yml' | ||
push: | ||
paths: | ||
- 'server/intelligence-service/openapi.yaml' | ||
- 'server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/**' | ||
branches: [develop] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
generate-api-client: | ||
name: Verify API Specs and Client of the Intelligence Service (add autocommit-openapi label to PR to auto-commit changes) | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '21' | ||
|
||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
virtualenvs-path: .venv | ||
installer-parallel: true | ||
|
||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- name: Install Python dependencies | ||
working-directory: server/intelligence-service | ||
run: poetry install --no-interaction --no-root | ||
|
||
- name: Generate API client for the application server | ||
working-directory: server/intelligence-service | ||
run: poetry run npm run generate:api:intelligence-service | ||
|
||
- name: Check for changes in the API | ||
id: check_changes | ||
run: | | ||
echo "Checking for changes in the API client directory..." | ||
git add . | ||
if git diff --cached --quiet; then | ||
echo "No changes detected in the API client directory." | ||
echo "NO_CHANGES_DETECTED=true" >> $GITHUB_ENV | ||
else | ||
echo "Changes detected in the API client directory." | ||
echo "NO_CHANGES_DETECTED=false" >> $GITHUB_ENV | ||
exit 1 | ||
fi | ||
- name: Commit files | ||
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') }} | ||
run: | | ||
echo "Committing and pushing changes..." | ||
git config --local user.name "github-actions[bot]" | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git commit -a -m "chore: update API specs and client" | ||
- name: Push changes | ||
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') }} | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GH_PAT }} | ||
branch: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Remove autocommit-openapi label | ||
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') }} | ||
run: | | ||
echo "Removing the autocommit-openapi label..." | ||
curl --silent --fail-with-body -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/autocommit-openapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.