Skip to content

Commit

Permalink
Run tests based on examples in CI/CD
Browse files Browse the repository at this point in the history
The tests are run after building images
The tests are run only on branches, they are not run for tags.
  • Loading branch information
ashashev authored and danslapman committed Oct 21, 2023
1 parent a714120 commit 9c8457f
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 4 deletions.
134 changes: 133 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
tags:
- '*'

env:
MOCKINGBIRD_TEST_IMAGE_JVM: "ghcr.io/leviysoft/mockingbird:${{ github.run_number }}"
MOCKINGBIRD_TEST_IMAGE_NATIVE: "ghcr.io/leviysoft/mockingbird:${{ github.run_number }}-native"

jobs:
front-build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -90,6 +94,14 @@ jobs:
cd backend
sbt "project mockingbird-api;clean;fixCheck;test;missinglinkCheck;Docker / stage;"
- name: Build docker image for test
uses: docker/build-push-action@v3
with:
context: ./backend/mockingbird-api/target/docker/stage
push: false
tags: ${{ env.MOCKINGBIRD_TEST_IMAGE_JVM }}
if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }}

- name: ZIP stages files
uses: montudor/action-zip@v1
with:
Expand Down Expand Up @@ -121,6 +133,19 @@ jobs:
tag: ${{ github.ref_name }}
if: ${{ github.ref_type == 'tag' }}

- name: Save docker image to file
run: |
docker save -o /tmp/image-jvm.tar ${{ env.MOCKINGBIRD_TEST_IMAGE_JVM }}
gzip /tmp/image-jvm.tar
if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }}

- name: Upload image with JVM mockingbird
uses: actions/upload-artifact@v3
with:
name: image-jvm
path: /tmp/image-jvm.tar.gz
if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }}

back-build-native:
needs: [front-build]

Expand Down Expand Up @@ -165,6 +190,14 @@ jobs:
cd backend
sbt "project mockingbird-native;clean;fixCheck;test;GraalVMNativeImage / packageBin;Docker / stage;"
- name: Build docker image for test
uses: docker/build-push-action@v3
with:
context: ./backend/mockingbird-native/target/docker/stage
push: false
tags: ${{ env.MOCKINGBIRD_TEST_IMAGE_NATIVE }}
if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }}

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
Expand All @@ -179,4 +212,103 @@ jobs:
context: ./backend/mockingbird-native/target/docker/stage
push: true
tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }}-native
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }}
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }}

- name: Save docker image to file
run: |
docker save -o /tmp/image-native.tar ${{ env.MOCKINGBIRD_TEST_IMAGE_NATIVE }}
gzip /tmp/image-native.tar
if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }}

- name: Upload image with native mockingbird
uses: actions/upload-artifact@v3
with:
name: image-native
path: /tmp/image-native.tar.gz
if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }}

test-jvm-image:
if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }}
needs: [back-build]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: image-jvm
path: /tmp

- name: Load docker image
run: |
gzip -d /tmp/image-jvm.tar.gz
docker load --input /tmp/image-jvm.tar
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
check-latest: true

- name: Test docker image
env:
MOCKINGBIRD_IMAGE: ${{ env.MOCKINGBIRD_TEST_IMAGE_JVM }}
run: |
cd backend
envsubst < compose-test.yml.jvm.tmpl > compose-test.yml
sbt "project examples; clean; fixCheck; test"
test-native-image:
if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }}
needs: [back-build-native]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: image-native
path: /tmp

- name: Load docker image
run: |
gzip -d /tmp/image-native.tar.gz
docker load --input /tmp/image-native.tar
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
check-latest: true

- name: Test docker image
env:
MOCKINGBIRD_IMAGE: ${{ env.MOCKINGBIRD_TEST_IMAGE_NATIVE }}
run: |
cd backend
envsubst < compose-test.yml.native.tmpl > compose-test.yml
sbt "project examples; clean; fixCheck; test"
test-example-dsl:
if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
check-latest: true

- name: Run
run: |
cd backend
sbt "project edsl; clean; fixCheck; test"
3 changes: 0 additions & 3 deletions backend/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ val edsl = (project in file("edsl"))
)

val examples = (project in file("examples"))
.enablePlugins(
JavaAppPackaging
)
.dependsOn(edsl)
.settings(Settings.common)
.settings(
Expand Down

0 comments on commit 9c8457f

Please sign in to comment.