Skip to content

Support multiple files (#19449) #6

Support multiple files (#19449)

Support multiple files (#19449) #6

name: OpenAPI Generator
on:
push:
branches:
- master
- '[5-9]+.[0-9]+.x'
pull_request:
branches:
- master
- '[5-9]+.[0-9]+.x'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v4
env:
cache-name: cache-maven-repository
with:
path: |
~/.m2/repository
~/.gradle
!~/.gradle/caches/*/plugin-resolution/
!~/.m2/repository/org/openapitools/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
- name: Run maven
run: ./mvnw clean --no-snapshot-updates --batch-mode --quiet install -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=error
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- run: ls -la modules/openapi-generator-cli/target
- name: Upload openapi-generator-cli.jar artifact
uses: actions/upload-artifact@v4
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target/openapi-generator-cli.jar
retention-days: 1
test:
name: Unit tests
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v4
env:
cache-name: cache-maven-repository
with:
path: |
~/.m2/repository
~/.gradle
!~/.gradle/caches/*/plugin-resolution/
!~/.m2/repository/org/openapitools/
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
- name: Run unit tests
run: ./mvnw clean --no-snapshot-updates --batch-mode --quiet --fail-at-end test -Dorg.slf4j.simpleLogger.defaultLogLevel=error
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: Publish unit test reports
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'
documentation:
name: Docs up-to-date
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
- name: Download openapi-generator-cli.jar artifact
uses: actions/download-artifact@v4
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target
- name: Generate docs
run: |
bash bin/meta-codegen.sh
bash bin/utils/export_docs_generators.sh
bash bin/utils/copy-to-website.sh
bash bin/utils/export_generators_readme.sh
- name: Verify git status
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
echo "UNCOMMITTED CHANGES ERROR"
echo "There are uncommitted changes in working tree after execution of 'bin/ensure-up-to-date'"
echo "Perform git diff"
git --no-pager diff
echo "Perform git status"
git status
echo -e "\nThis script runs in pull requests against the anticipated merge commit (as if the PR was merged now)."
echo "When you see unexpected files here, it likely means that there are newer commits in master that you need to "
echo -e "rebase or merge into your branch.\n"
echo "Please run 'bin/utils/ensure-up-to-date' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
exit 1
fi
samples:
name: Samples up-to-date
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
- name: Download openapi-generator-cli.jar artifact
uses: actions/download-artifact@v4
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target
- name: Delete samples that are entirely generated
run: |
rm -rf samples/client/petstore/csharp/generichost/net8/AllOf
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net8/FormModels
rm -rf samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
rm -rf samples/client/petstore/csharp/generichost/net8/OneOf
rm -rf samples/client/petstore/csharp/generichost/net8/Petstore
rm -rf samples/client/petstore/csharp/generichost/net8/SourceGeneration
rm -rf samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
rm -rf samples/client/petstore/csharp/generichost/standard2.0/Petstore
rm -rf samples/client/petstore/csharp/generichost/net4.8/AllOf
rm -rf samples/client/petstore/csharp/generichost/net4.8/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net4.8/FormModels
rm -rf samples/client/petstore/csharp/generichost/net4.8/OneOf
rm -rf samples/client/petstore/csharp/generichost/net4.8/Petstore
rm -rf samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate
rm -rf samples/client/petstore/csharp/generichost/net4.7/AllOf
rm -rf samples/client/petstore/csharp/generichost/net4.7/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net4.7/FormModels
rm -rf samples/client/petstore/csharp/generichost/net4.7/OneOf
rm -rf samples/client/petstore/csharp/generichost/net4.7/Petstore
rm -rf samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate
- name: Generate samples
run: |
bash bin/generate-samples.sh
# when a sample is deleted, you have to generate it twice for all files to get created
bash bin/generate-samples.sh
- name: Verify git status
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
echo "UNCOMMITTED CHANGES ERROR"
echo "There are uncommitted changes in working tree after execution of 'bin/generate-samples.sh'"
echo "Perform git diff"
git --no-pager diff
echo "Perform git status"
git status
echo -e "\nThis script runs in pull requests against the anticipated merge commit (as if the PR was merged now)."
echo "When you see unexpected files here, it likely means that there are newer commits in master that you need to "
echo -e "rebase or merge into your branch.\n"
echo "Please run 'bin/generate-samples.sh' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
exit 1
fi