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

Response caching #273

Open
wants to merge 10 commits 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
63 changes: 22 additions & 41 deletions .github/workflows/mimock-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,23 @@ jobs:
MIMOCK_CURRENT_VERSION: ${{ secrets.MIMOCK_CURRENT_VERSION }}
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3

- uses: gradle/wrapper-validation-action@v1

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Gradle Cache
uses: burrunan/gradle-cache-action@v1

- name: Check format using checkstyle
working-directory: mimock-backend
run: ./mvnw -ntp -Drevision=$MIMOCK_CURRENT_VERSION checkstyle:check

- name: Generate checkstyle report
working-directory: mimock-backend
run: ./mvnw -ntp -Drevision=$MIMOCK_CURRENT_VERSION clean site
run: ./gradlew checkstyleMain

- name: Publish style report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: checkstyle-report
path: |
mimock-backend/target/site/css
mimock-backend/target/site/images
mimock-backend/target/site/checkstyle.html
mimock-backend/build/reports/checkstyle/*

test:
needs:
Expand All @@ -54,32 +45,27 @@ jobs:
MIMOCK_CURRENT_VERSION: ${{ secrets.MIMOCK_CURRENT_VERSION }}
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Gradle Cache
uses: burrunan/gradle-cache-action@v1

- name: Run mimock tests in CI mode
working-directory: mimock-backend
run: ./mvnw -ntp clean initialize verify -P startDatabase -P coverage -Drevision=$MIMOCK_CURRENT_VERSION -Dspring.config.location=classpath:/application.yml
run: ./gradlew clean startDatabase jacocoTestCoverageVerification -Drevision=$MIMOCK_CURRENT_VERSION -Dspring.config.location=classpath:/application.yml

- name: Publish coverage report codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
commit_parent: ${{ github.sha }}

- name: Publish coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: mimock-coverage-report
path: |
mimock-backend/target/site/jacoco/*
mimock-backend/build/reports/jacoco/test/html/*

package-app:
needs:
Expand All @@ -90,28 +76,23 @@ jobs:
MIMOCK_CURRENT_VERSION: ${{ secrets.MIMOCK_CURRENT_VERSION }}
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Gradle Cache
uses: burrunan/gradle-cache-action@v1

- name: Build Mimock JAR
working-directory: mimock-backend
run: ./mvnw -ntp clean package -P packageJar -Drevision=$MIMOCK_CURRENT_VERSION -Dmaven.test.skip=true
run: ./gradlew clean bootJar

- name: Publish JAR
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: mimock-jar
path: |
mimock-backend/target/mimock-*.jar
mimock-backend/build/libs/*

- name: Build mimock docker image
run: |
docker build -t mimock-backend:${{ github.sha }} . -f ./Dockerfile.min && echo "Docker image build validated"
docker build -t mimock-backend:${{ github.sha }} . -f ./Dockerfile.slim --build-arg MIMOCK_CURRENT_VERSION=$MIMOCK_CURRENT_VERSION && echo "Docker image build validated"
docker system prune && docker image prune --all
16 changes: 9 additions & 7 deletions .github/workflows/mimock-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ jobs:
MIMOCK_CURRENT_VERSION: ${{ secrets.MIMOCK_CURRENT_VERSION }}
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3

- uses: gradle/wrapper-validation-action@v1

- name: Build Mimock app
run: |
make bundle-app

- name: Build platform bundles
run: |
cp -p ./mimock-backend/target/mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}.jar ./installation/lib/mimock.jar
cp -p ./mimock-backend/build/libs/mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}.jar ./installation/lib/mimock.jar

cd ./installation
zip -r mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}.zip lib/*
Expand All @@ -28,21 +30,21 @@ jobs:
tar czf mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}.tar.gz --directory=installation lib start mimock.properties setup_database psql_setup.sql

- name: Publish JAR
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}-jar.zip
path: |
./mimock-backend/target/mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}.jar
./mimock-backend/build/libs/mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}.jar

- name: Publish Linux Bundle
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}.tar.gz
path: |
mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}.tar.gz

- name: Publish Windows Bundle
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: mimock-${{ secrets.MIMOCK_CURRENT_VERSION }}.zip
path: |
Expand Down Expand Up @@ -81,7 +83,7 @@ jobs:
docker build -t mimock/mimock:slim . -f ./Dockerfile.slim
docker tag mimock/mimock:slim mimock/mimock:${{ secrets.MIMOCK_CURRENT_VERSION }}-slim

docker build -t mimock/mimock:latest . -f ./Dockerfile.complete
docker build -t mimock/mimock:latest . -f ./Dockerfile.complete --build-arg MIMOCK_VERSION=${{ secrets.MIMOCK_CURRENT_VERSION }}
docker tag mimock/mimock:latest mimock/mimock:${{ secrets.MIMOCK_CURRENT_VERSION }}

- name: Log in to Docker Hub
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ RUN chmod 755 -R .
RUN apk add openjdk11
RUN apk add openjdk11-jre

RUN sed -i 's/\r$//' mvnw
RUN ./mvnw clean package -P packageJar -Dmaven.test.skip=true
RUN sed -i 's/\r$//' gradlew
RUN ./gradlew bootJar

EXPOSE 8080

ENTRYPOINT ["java","-jar","./target/mimock-0.0.1.jar"]
ENTRYPOINT ["java","-jar","./target/mimock-0.0.0.jar"]
4 changes: 3 additions & 1 deletion Dockerfile.complete
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ FROM alpine:3.15.0

WORKDIR /home/mimock

COPY ${PWD}/mimock-backend/target/mimock*.jar mimock.jar
ARG MIMOCK_CURRENT_VERSION=0.0.0

COPY ${PWD}/mimock-backend/build/libs/mimock-${MIMOCK_CURRENT_VERSION}.jar mimock.jar

RUN apk add openjdk11-jre
RUN apk add postgresql13
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ FROM eclipse-temurin:11.0.16.1_1-jre

WORKDIR /home/mimock

COPY ${PWD}/mimock-backend/target/mimock*.jar mimock.jar
ARG MIMOCK_CURRENT_VERSION=0.0.0

COPY ${PWD}/mimock-backend/build/libs/mimock-${MIMOCK_CURRENT_VERSION}.jar mimock.jar

EXPOSE 8080

Expand Down
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ STATIC_DIR := '../mimock-backend/src/main/resources/static/mimock-ui'
VERSION := $$MIMOCK_CURRENT_VERSION

ifdef SKIP_TESTS
BUILD_BACKEND := cd ./mimock-backend && ./mvnw -ntp clean package -Dmaven.test.skip=true -Drevision=$(VERSION) && cd ..
BUILD_BACKEND := cd ./mimock-backend && ./gradlew build -x test && cd ..
BUILD_UI := cd ./mimock-ui && yarn && NODE_NEV=production yarn build
else
BUILD_UI := cd ./mimock-ui && yarn && yarn test && NODE_NEV=production yarn build
BUILD_BACKEND := cd ./mimock-backend && ./mvnw -ntp clean package -Drevision=$(VERSION) && cd ..
BUILD_BACKEND := cd ./mimock-backend && ./gradlew build && cd ..
endif

cd_backend:
Expand All @@ -32,16 +32,13 @@ start-database: create-network
@docker inspect mimock-db --format "imageName: {{.Id}}" || docker run --name mimock-db -p 5432:5432 --network mimock-network -d mimock-pg-database

start-app-local: start-database
./mimock-backend/mvnw clean spring-boot:run -Dspring.config.location=$(APP_CONFIG_FILE) -Dspring.datasource.url=$(APP_DB_URL)
./mimock-backend/gradlew bootRun -Dspring.config.location=$(APP_CONFIG_FILE) -Dspring.datasource.url=$(APP_DB_URL)

format-check:
./mimock-backend/mvnw checkstyle:check

format-report:
./mimock-backend/mvnw clean site
./mimock-backend/gradlew checkstyleMain

test-local: start-database
./mimock-backend/mvnw clean test -Dspring.config.location=$(TEST_CONFIG_FILE) -Dspring.datasource.url=$(TEST_DB_URL) -P startDatabase
./mimock-backend/gradlew test -Dspring.config.location=$(TEST_CONFIG_FILE) -Dspring.datasource.url=$(TEST_DB_URL) -P startDatabase

test-ci:
docker-compose -f docker-compose.test.yml up --abort-on-container-exit --exit-code-from mimock-test
Expand All @@ -57,7 +54,7 @@ bundle-app: start-database build-app

build-docker-image:
@echo "Building docker image" && \
docker build -t mimock/mimock:$(VERSION) . -f ./Dockerfile.slim
docker build -t mimock/mimock:$(VERSION) . -f ./Dockerfile.slim --build-arg MIMOCK_CURRENT_VERSION=$(VERSION)

generate-keystore:
@echo "Generating keystore" && \
Expand Down
5 changes: 4 additions & 1 deletion mimock-backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ build/
/src/main/resources/keystore/*.p12

/src/main/resources/static/**/*
!/src/main/resources/static/.gitkeep
!/src/main/resources/static/.gitkeep
.mvn/
build/
.gradle/
11 changes: 0 additions & 11 deletions mimock-backend/.jpb/jpb-settings.xml

This file was deleted.

117 changes: 0 additions & 117 deletions mimock-backend/.mvn/wrapper/MavenWrapperDownloader.java

This file was deleted.

Binary file removed mimock-backend/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions mimock-backend/.mvn/wrapper/maven-wrapper.properties

This file was deleted.

Loading