Cart to micronaut 4.3.4 #238
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
name: Java CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
JAVA: '21' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
project-path: [ | |
'api', | |
'carts', | |
'catalogue', | |
'events', | |
'fulfillment', | |
'functions/newsletter-subscription', | |
'orders', | |
'payment', | |
'user', | |
'assets' | |
] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/[email protected] | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Setup GraalVM | |
uses: graalvm/[email protected] | |
with: | |
distribution: 'graalvm' | |
java-version: ${{ env.JAVA }} | |
- name: Build and test | |
working-directory: src/${{ matrix.project-path }} | |
run: | | |
if [ -f "mvnw" ]; then | |
./mvnw test --no-transfer-progress | |
elif [ -f "gradlew" ]; then | |
./gradlew check --no-daemon --continue | |
fi | |
env: | |
TESTCONTAINERS_RYUK_DISABLED: true | |
build-docker-compose-test-images: | |
if: success() | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
project-path: [ | |
'api', | |
'carts', | |
'catalogue', | |
'fulfillment', | |
'orders', | |
'payment', | |
'user', | |
'assets' | |
] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/[email protected] | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Setup GraalVM | |
uses: graalvm/[email protected] | |
with: | |
distribution: 'graalvm' | |
java-version: ${{ env.JAVA }} | |
- name: Login to OCIR | |
uses: docker/login-action@v1 | |
with: | |
registry: phx.ocir.io | |
username: ${{ secrets.OCI_USERNAME }} | |
password: ${{ secrets.OCI_TOKEN }} | |
# | |
# Build GraalVM docker image with SHA as tag for later use in docker-compose test job | |
- name: Build docker & push image - GraalVM | |
working-directory: src/${{ matrix.project-path }} | |
run: | | |
if [ -f "mvnw" ]; then | |
# Install only the `lib` module to the local repository so it can be used for building the `app` image | |
./mvnw install -Drevision=$GITHUB_SHA -pl -app,-aws,-oci | |
./mvnw deploy -Dpackaging=docker -Djib.from.image=ghcr.io/graalvm/native-image-community:21 -Ddocker.image.suffix=graalvm -Drevision=$GITHUB_SHA --no-transfer-progress -pl app | |
elif [ -f "gradlew" ]; then | |
./gradlew :app:dockerPush -Pversion=$GITHUB_SHA --no-daemon | |
fi | |
docker-compose-test: | |
if: success() | |
needs: build-docker-compose-test-images | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Login to OCIR | |
uses: docker/login-action@v1 | |
with: | |
registry: phx.ocir.io | |
username: ${{ secrets.OCI_USERNAME }} | |
password: ${{ secrets.OCI_TOKEN }} | |
logout: false | |
- name: Setup stack | |
working-directory: deploy/complete/docker-compose | |
run: | | |
# | |
# Configure higher timeouts | |
export DOCKER_CLIENT_TIMEOUT=120 | |
export COMPOSE_HTTP_TIMEOUT=120 | |
# | |
# Generate override docker compose so we use latest build docker images | |
grep -B 1 -e "services:" -e 'graalvm' docker-compose.yml | sed -E "s/(.*):(.*):(.*)/\1:\2:$GITHUB_SHA/g" | grep -v -e '--' > docker-compose.override.yml | |
cat docker-compose.override.yml | |
docker-compose pull | |
docker-compose up -d --renew-anon-volumes --force-recreate --remove-orphans | |
docker-compose ps | |
# | |
# wait 10 seconds to let the containers initalize | |
sleep 10 | |
docker-compose logs | |
- name: Run test | |
working-directory: src/load | |
run: | | |
docker build -t mushop/load:latest . | |
docker run --net=host mushop/load:latest -h localhost:81 -c 5 -r 60 | |
- name: Cleanup stack | |
if: ${{ always() }} | |
working-directory: deploy/complete/docker-compose | |
run: | | |
docker-compose down -t 300 | |
docker volume prune -f | |
docker image prune -f | |
push-docker-images: | |
if: success() && github.event_name == 'push' | |
needs: docker-compose-test | |
runs-on: self-hosted | |
strategy: | |
fail-fast: false | |
matrix: | |
project-path: [ | |
'api', | |
'carts', | |
'catalogue', | |
'events', | |
'fulfillment', | |
'functions/newsletter-subscription', | |
'orders', | |
'payment', | |
'user', | |
'assets' | |
] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/[email protected] | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Setup GraalVM | |
uses: graalvm/[email protected] | |
with: | |
distribution: 'graalvm' | |
java-version: ${{ env.JAVA }} | |
- name: Login to OCIR | |
uses: docker/login-action@v1 | |
with: | |
registry: phx.ocir.io | |
username: ${{ secrets.OCI_USERNAME }} | |
password: ${{ secrets.OCI_TOKEN }} | |
logout: false | |
- name: Push docker image - GraalVM Native Image | |
working-directory: src/${{ matrix.project-path }} | |
run: | | |
if [ -f "mvnw" ]; then | |
# Install only the `lib` module to the local repository so it can be used for building `app`, `aws` and `oci` GraalVM images | |
./mvnw install -pl -app,-aws,-oci | |
# Build and deploy `app`, `aws` and `oci` GraalVM images | |
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native-image-community:21 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl app | |
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native-image-community:21 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl aws | |
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native-image-community:21 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl oci | |
elif [ -f "gradlew" ]; then | |
./gradlew dockerPush --no-daemon | |
fi | |
- name: Cleanup images | |
if: ${{ always() }} | |
run: docker image prune -a -f |