Added downscaling to pdfToImage-Converter to avoid too big images (#41) #160
This file contains hidden or 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 and Docker Deploy | |
| on: | |
| push: | |
| branches: ["robotik-challenge-main", "robotik-challenge/*"] | |
| tags: ["v*.*.*"] | |
| paths-ignore: | |
| - ".github/ISSUE_TEMPLATE/**" | |
| - ".github/CODEOWNERS" | |
| - ".github/copilot-instructions.md" | |
| - "wiki/**" | |
| - "README.md" | |
| pull_request: | |
| branches: ["robotik-challenge-main"] | |
| paths-ignore: | |
| - ".github/ISSUE_TEMPLATE/**" | |
| - ".github/CODEOWNERS" | |
| - ".github/copilot-instructions.md" | |
| - "wiki/**" | |
| - "README.md" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| # Update the version manually | |
| IMAGE_TAG_VERSION: ${{ github.ref_name }} | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-browser-image: | |
| name: Build browser image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/amd64 | |
| context: "." | |
| cache-from: mnestix/mnestix-browser:dev | |
| cache-to: type=local,dest=/tmp/buildx-amd64-cache,mode=max | |
| target: production | |
| push: false | |
| tags: mnestix/mnestix-browser:latest | |
| load: true | |
| - name: Cache buildx | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: | | |
| /tmp/buildx-amd64-cache | |
| key: buildx-amd64-${{github.ref}}-${{ github.run_id }} | |
| enableCrossOsArchive: true | |
| - name: Save mnestix-browser image | |
| run: docker save mnestix/mnestix-browser:latest -o mnestix-browser.tar | |
| - name: Cache image | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: mnestix-browser.tar | |
| key: docker-image-${{github.ref}}-${{ github.run_id }} | |
| e2e-tests: | |
| name: e2e test matrix | |
| runs-on: ubuntu-latest | |
| needs: ["build-browser-image"] | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # add more containers to run more tests in parallel | |
| containers: [1, 2, 3, 4] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Restore image | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: mnestix-browser.tar | |
| key: docker-image-${{github.ref}}-${{ github.run_id }} | |
| # image too big to be reused | |
| - name: Build test image | |
| run: docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests build cypress-test | |
| - name: Pull images | |
| run: docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests pull | |
| # Remove old image to avoid conflicts, before sometimes the old image wasn't loaded | |
| # If this step fails please check docker-compose/compose.test.yml if tag is still correct | |
| - name: Remove Docker image mnestix/mnestix-browser:latest, to avoid conflicts | |
| run: docker rmi mnestix/mnestix-browser:latest | |
| # overwrite the pulled image with the new image | |
| - name: Load mnestix-browser image | |
| run: docker load -i mnestix-browser.tar | |
| - name: Run e2e tests | |
| # 18-minute timeout to speed up failing tests that are retried too long. | |
| # If the timeout is reached under normal test conditions, consider increasing | |
| # the number of containers to run more tests in parallel. | |
| timeout-minutes: 18 | |
| run: | | |
| docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests up -d && | |
| docker compose -f compose.yml -f docker-compose/compose.test.yml attach cypress-test | |
| env: | |
| SPLIT: ${{ strategy.job-total }} | |
| SPLIT_INDEX: ${{ strategy.job-index }} | |
| TEST_ADMIN_USER_PASSWORD: admin | |
| TEST_USER_PASSWORD: test | |
| - name: E2E test collect artifact | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: cypress-artifacts-${{ matrix.containers }} | |
| path: cypress-artifacts/ | |
| unit-test: | |
| name: Unit Test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "24.13.0" | |
| cache: "yarn" | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Generate Prisma Client | |
| run: yarn prisma:generate | |
| - name: Run unit tests | |
| run: npx jest | |
| lint: | |
| name: Lint and Typecheck | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "24.13.0" | |
| cache: "yarn" | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Generate Prisma Client | |
| run: yarn prisma:generate | |
| - name: Typescript check | |
| run: yarn typecheck | |
| - name: Typescript e2e check | |
| run: yarn typecheck:e2e | |
| - name: Linting check | |
| run: yarn lint | |
| # Target for PR Merge Check | |
| ci-success: | |
| name: Successful build and tests | |
| runs-on: ubuntu-latest | |
| needs: ["lint", "unit-test", "e2e-tests"] | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Success | |
| run: echo "Success" | |
| # It takes 22 minutes to build the arm64 image in amd64-QEMU so we build a cache on the arm64 runner | |
| # Github Issues point to a yarn problem | |
| # https://github.com/docker/build-push-action/issues/471 | |
| # https://github.com/nodejs/docker-node/issues/1335 | |
| build-arm-cache: | |
| name: Build arm image cache | |
| runs-on: ubuntu-24.04-arm | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/arm64 | |
| context: "." | |
| cache-to: type=local,dest=/tmp/buildx-arm64-cache,mode=max | |
| target: production | |
| push: false | |
| - name: Cache buildx | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: | | |
| /tmp/buildx-arm64-cache | |
| key: buildx-arm64-${{github.ref}}-${{ github.run_id }} | |
| enableCrossOsArchive: true | |
| push-image: | |
| name: Push image to registry | |
| needs: ["ci-success", "build-arm-cache"] | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' && startsWith(github.ref_name, 'robotik-challenge') && github.repository_owner == 'ARENA2036' | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| steps: | |
| - name: Restore amd64 cache | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: | | |
| /tmp/buildx-amd64-cache | |
| key: buildx-amd64-${{github.ref}}-${{ github.run_id }} | |
| # can be build without cache | |
| fail-on-cache-miss: false | |
| - name: Restore arm64 cache | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: | | |
| /tmp/buildx-arm64-cache | |
| key: buildx-arm64-${{github.ref}}-${{ github.run_id }} | |
| # building takes ages | |
| fail-on-cache-miss: true | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract branch name | |
| id: extract_branch | |
| run: | | |
| TAG=${IMAGE_TAG_VERSION//\//_} # This uses shell parameter substitution to replace "/" with "_" | |
| TAG=${TAG,,} # Convert to lowercase | |
| IMAGE_NAME_LOWER=${IMAGE_NAME,,} # Convert IMAGE_NAME to lowercase | |
| echo "TAG=${TAG}" >> $GITHUB_OUTPUT | |
| echo "IMAGE_NAME=${IMAGE_NAME_LOWER}" >> $GITHUB_OUTPUT | |
| echo "TAG=${TAG}" | |
| echo "IMAGE_NAME=${IMAGE_NAME_LOWER}" | |
| - name: Build and push docker images | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| context: "." | |
| cache-from: | | |
| type=local,src=/tmp/buildx-arm64-cache | |
| type=local,src=/tmp/buildx-amd64-cache | |
| target: production | |
| push: true | |
| tags: ${{ format('{0}/{1}:{2}', env.REGISTRY, steps.extract_branch.outputs.IMAGE_NAME, steps.extract_branch.outputs.TAG) }} |