Skip to content

Commit

Permalink
chore: test
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarAlJarrah committed Sep 3, 2024
1 parent 26b5f8b commit 9ee9b80
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 12 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/selfserve-service-mock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: PR Check Tests Run
on:
workflow_call:
inputs:
repository:
description: 'Repository to checkout'
type: string
required: true
ref:
description: 'Branch or tag to checkout'
type: string
required: true
specs_path:
description: 'Path of the artifact to persist to'
type: string
default: ''

jobs:
upload-specs:
uses: ./.github/workflows/selfserve-checkout-and-upload.yaml
with:
repository: ${{ inputs.repository }}
ref: "${{ github.head_ref || github.ref_name }}"
artifact_key: 'specs'
artifact_path: ${{ inputs.specs_path }}
mock:
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: specs
path: specs
- name: Download Latest Specmatic Executable
working-directory: specs
run: |
curl -s https://api.github.com/repos/znsio/specmatic/releases/latest \
| grep "browser_download_url.*specmatic.jar" \
| cut -d : -f 2,3 \
| tr -d \" \
| xargs curl -L -o specmatic.jar
- uses: actions/setup-node@v4
with:
node-version: 18.18.2
- uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
- name: Parse Specs
working-directory: specs
run: |
spec=$(find . -maxdepth 1 -type f \( -name "*.yaml" -o -name "*.yml" \) | head -n 1)
if [ ! -f $spec ]; then
echo "Specs not found!"
fi
echo "spec=$spec" >> $GITHUB_ENV
- name: Transform Specs
working-directory: specs
run: npx --yes -p @expediagroup/spec-transformer cli -i ${{ env.spec }} -o ${{ env.spec }} -to
- name: Run Mock Server
working-directory: specs
run: java -jar specmatic.jar stub ${{ env.spec }} --port 8080 & disown
- name: Wait for Mock Server to Start
run: sleep 10
- name: Verify Server is Running
run: |
status=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/$(uuidgen))
if [ $status -e 000 ]; then
echo "Server not running!"
exit 1
fi
9 changes: 9 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
on: push
jobs:
main:
uses: ./.github/workflows/selfserve-service-mock.yaml
with:
repository: ${{ github.repository }}
ref: "${{ github.head_ref || github.ref_name }}"
specs_path: 'release/rapid/src/specs.yaml'

Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@
*/
package com.expediagroup.sdk.test.contract.extension

import io.specmatic.conversions.EnvironmentAndPropertiesConfiguration
import io.specmatic.conversions.OpenApiSpecification
import io.specmatic.core.Feature
import io.specmatic.core.Hook
import io.specmatic.core.OPENAPI_FILE_EXTENSIONS
import io.specmatic.core.PassThroughHook
import io.specmatic.core.SecurityConfiguration
import io.specmatic.core.unsupportedFileExtensionContractException
import io.specmatic.core.*
import java.io.File

/**
Expand All @@ -34,7 +28,6 @@ import java.io.File
* @param sourceRepositoryBranch optional branch of source repository.
* @param specificationPath optional path to the specification file.
* @param securityConfiguration optional security configuration.
* @param environmentAndPropertiesConfiguration configuration for environment and properties, default is EnvironmentAndPropertiesConfiguration.
* @throws unsupportedFileExtensionContractException if the file extension is not supported.
* @return converted Feature object.
*/
Expand All @@ -45,7 +38,7 @@ fun File.toSpecmaticFeature(
sourceRepositoryBranch: String? = null,
specificationPath: String? = null,
securityConfiguration: SecurityConfiguration? = null,
environmentAndPropertiesConfiguration: EnvironmentAndPropertiesConfiguration = EnvironmentAndPropertiesConfiguration()
specmaticConfig: SpecmaticConfig = SpecmaticConfig()
): Feature =
when (extension) {
in OPENAPI_FILE_EXTENSIONS ->
Expand All @@ -57,7 +50,7 @@ fun File.toSpecmaticFeature(
sourceRepositoryBranch = sourceRepositoryBranch,
specificationPath = specificationPath,
securityConfiguration = securityConfiguration,
environmentAndPropertiesConfiguration = environmentAndPropertiesConfiguration
specmaticConfig = specmaticConfig
).toFeature()

else -> throw unsupportedFileExtensionContractException(path, extension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class Main {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<name>Rapid Java SDK Tests</name>
<description>Expedia Group Rapid Java SDK Tests</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.3</version>
</parent>

<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down Expand Up @@ -104,7 +110,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<source>
1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Expand Down

0 comments on commit 9ee9b80

Please sign in to comment.