OH2-388 | mutate exam with rows #367
Workflow file for this run
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
# This workflow will build and run the application for oasdiff/oasdiff-action/breaking@main | |
# For more information see: https://github.com/oasdiff/oasdiff-action | |
name: OpenAPI breaking changes check | |
on: [push, pull_request] | |
env: | |
MAVEN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' | |
jobs: | |
opeanpi: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Determine PR source branch | |
id: extract_branch | |
run: echo "BRANCH_NAME=${GITHUB_HEAD_REF:-develop}" >> $GITHUB_ENV | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
java-package: jdk | |
- name: Checkout core | |
run: | | |
git clone --depth=50 https://github.com/informatici/openhospital-core.git openhospital-core | |
cd openhospital-core | |
git fetch origin ${{ env.BRANCH_NAME }} || git fetch origin develop | |
git checkout ${{ env.BRANCH_NAME }} || git checkout develop | |
cd .. | |
- name: Install core | |
run: cd openhospital-core && mvn install -DskipTests=true && cd .. | |
- name: Generate JWT Token | |
id: jwt | |
run: echo "token=7DlyD1SHR5pCa4HGgTLWSYm8YQ7oRL1wpPbxyjWyHU44vUrqrooRu3lHVFSXWChesc" >> $GITHUB_OUTPUT | |
- name: Build with Maven | |
run: | | |
cp rsc/database.properties.dist rsc/database.properties | |
cp rsc/log4j2-spring.properties.dist rsc/log4j2-spring.properties | |
cp rsc/settings.properties.dist rsc/settings.properties | |
sed -e "s/JWT_TOKEN_SECRET/${{ steps.jwt.outputs.token }}/g" -e "s/API_HOST/localhost/g" -e "s/API_PORT/8080/g" rsc/application.properties.dist > rsc/application.properties | |
mvn install -DskipTests=true | |
- name: Run API | |
run: | | |
cd target | |
java -cp "openhospital-api-0.1.0.jar:rsc/:static/" org.springframework.boot.loader.launch.JarLauncher & | |
sleep 60 | |
cd .. | |
- name: Generate OpenAPI yaml | |
run: mvn springdoc-openapi:generate -Dspringdoc.outputFileName=oh_rev.yaml | |
# Step 1: Check if oh_rev.yaml differs from the committed version | |
- name: Install yq | |
run: | | |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq | |
sudo chmod +x /usr/bin/yq | |
- name: Install jq | |
run: sudo apt-get install -y jq | |
- name: Convert to JSON and sort | |
run: | | |
yq eval -o=json openapi/oh_rev.yaml > oh_rev.json | |
yq eval -o=json openapi/oh.yaml > oh.json | |
jq --sort-keys . oh_rev.json > sorted_oh_rev.json | |
jq --sort-keys . oh.json > sorted_oh.json | |
- name: Compare JSON files | |
if: github.event_name == 'pull_request' | |
run: | | |
if diff sorted_oh_rev.json sorted_oh.json; then | |
echo "No changes in OpenAPI spec. Everything is up to date." | |
else | |
echo "The OpenAPI spec has changed. Please update the committed version." | |
exit 1 | |
fi | |
# Step 2: Check for breaking changes between destination branch oh.yaml and the generated oh_rev.yaml | |
- name: Checkout Base Branch | |
run: | | |
git fetch origin ${{ github.event.pull_request.base.ref }}:base_branch | |
git checkout base_branch | |
- name: Run OpenAPI Spec breaking action | |
id: oasdiff | |
uses: oasdiff/oasdiff-action/breaking@main | |
with: | |
base: openapi/oh.yaml # destination branch oh.yaml | |
revision: openapi/oh_rev.yaml # generated oh_rev.yaml | |
format: detailed | |
# fail-on-diff: false | |
- name: Show breaking changes output | |
run: | | |
echo "Breaking changes output: ${{ steps.oasdiff.outputs.breaking }}" | |
if [[ "${{ steps.oasdiff.outputs.breaking }}" != "No breaking changes" ]]; then | |
echo "Warning: Breaking changes detected." | |
exit 1 | |
fi |