Migrate to Scala 3 #367
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: CI | |
on: | |
workflow_call: | |
pull_request: | |
push: | |
branches: | |
- main | |
- '**docker' | |
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 | |
env: | |
PORT: 3000 | |
APP_ID: mockingbird | |
NODE_ENV: production | |
RELATIVE_PATH: /mockingbird | |
ASSETS_FOLDER_NAME: /assets | |
ASSETS_PREFIX: /mockingbird/assets/ | |
MOCKINGBIRD_API: /api/internal/mockingbird | |
MOCKINGBIRD_EXEC_API: /api/mockingbird/exec | |
DEBUG_PLAIN: true | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Build | |
run: | | |
cd frontend | |
rm ./env.development.js | |
mkdir -p ./dist/out${ASSETS_FOLDER_NAME} | |
npm install | |
npm run build | |
- name: Copy output | |
run: | | |
cd frontend | |
cp -r ./dist/static${RELATIVE_PATH}/. ./dist/out | |
cp -a ./dist/client/. ./dist/out${ASSETS_FOLDER_NAME} | |
- name: Upload output directories | |
uses: actions/upload-artifact@v4 | |
with: | |
name: front-static | |
path: frontend/dist/out | |
back-missinglink-check: | |
runs-on: ubuntu-latest | |
env: | |
SBT_OPTS: > | |
-Xms6g | |
-Xmx6g | |
-XX:+AlwaysPreTouch | |
-XX:ReservedCodeCacheSize=192M | |
-Xss2m | |
-XX:+TieredCompilation | |
-XX:+UseParallelGC | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
check-latest: true | |
- name: Compile and test | |
run: | | |
cd backend | |
sbt "project mockingbird-api;clean;missinglinkCheck;" | |
back-build: | |
needs: [front-build] | |
runs-on: ubuntu-latest | |
outputs: | |
ref: ${{ steps.get-ref.outputs.tag }} | |
env: | |
SBT_OPTS: > | |
-Xms2048m | |
-Xmx2048m | |
-XX:+AlwaysPreTouch | |
-XX:ReservedCodeCacheSize=256M | |
-Xss2m | |
-XX:+TieredCompilation | |
-XX:+UseParallelGC | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download frontend | |
uses: actions/download-artifact@v4 | |
with: | |
name: front-static | |
path: frontend/dist/out | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
check-latest: true | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v3 | |
with: | |
version: "25.2" | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get the Ref | |
id: get-ref | |
uses: ankitvgupta/[email protected] | |
with: | |
ref: ${{ github.ref }} | |
head_ref: ${{ github.head_ref }} | |
- name: Compile and test | |
run: | | |
cd backend | |
sbt "project mockingbird-api;clean;fixCheck;test;Docker / stage;" | |
- name: Build docker image for test | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend/mockingbird-api/target/docker/stage | |
push: false | |
tags: ${{ env.MOCKINGBIRD_TEST_IMAGE_JVM }} | |
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: ${{ github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') }} | |
- name: Build and push docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend/mockingbird-api/target/docker/stage | |
push: true | |
tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }} | |
if: ${{ github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') }} | |
- 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' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }} | |
- name: Upload image with JVM mockingbird | |
uses: actions/upload-artifact@v4 | |
with: | |
name: image-jvm | |
path: /tmp/image-jvm.tar.gz | |
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }} | |
back-build-native: | |
needs: [front-build] | |
runs-on: ubuntu-22.04 | |
outputs: | |
ref: ${{ steps.get-ref.outputs.tag }} | |
env: | |
CI: true | |
SBT_OPTS: > | |
-Xms512m | |
-Xmx2048m | |
-XX:+AlwaysPreTouch | |
-XX:ReservedCodeCacheSize=192M | |
-Xss2m | |
-XX:+TieredCompilation | |
-XX:+UseParallelGC | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download frontend | |
uses: actions/download-artifact@v4 | |
with: | |
name: front-static | |
path: frontend/dist/out | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '21' | |
distribution: 'graalvm' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
native-image-job-reports: 'true' | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v3 | |
with: | |
version: "25.2" | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get the Ref | |
id: get-ref | |
uses: ankitvgupta/[email protected] | |
with: | |
ref: ${{ github.ref }} | |
head_ref: ${{ github.head_ref }} | |
- name: Lint and Test | |
run: | | |
cd backend | |
sbt "project mockingbird-native;clean;fixCheck;test" | |
- name: Create native image and stage image contents | |
run: | | |
cd backend | |
sbt "project mockingbird-native;GraalVMNativeImage / packageBin;Docker / stage;" | |
- name: Build docker image for test | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend/mockingbird-native/target/docker/stage | |
push: false | |
tags: ${{ env.MOCKINGBIRD_TEST_IMAGE_NATIVE }} | |
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: ${{ github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') }} | |
- name: Build and push docker image | |
uses: docker/build-push-action@v5 | |
with: | |
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' || endsWith(steps.get-ref.outputs.tag, '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' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }} | |
- name: Upload image with native mockingbird | |
uses: actions/upload-artifact@v4 | |
with: | |
name: image-native | |
path: /tmp/image-native.tar.gz | |
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }} | |
test-jvm-image: | |
needs: [back-build] | |
if: ${{ ! ( github.ref_type == 'tag' || endsWith(needs.back-build.outputs.ref, 'docker') ) }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
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@v4 | |
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: | |
needs: [back-build-native] | |
if: ${{ ! ( github.ref_type == 'tag' || endsWith(needs.back-build-native.outputs.ref, 'docker') ) }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
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@v4 | |
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: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 17 | |
check-latest: true | |
- name: Run | |
run: | | |
cd backend | |
sbt "project edsl; clean; fixCheck; test" |