Update uppy monorepo (develop) #6181
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 Build | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| push-docker-image-to-harbor: | |
| description: 'Push Docker Image to Harbor' | |
| type: boolean | |
| default: false | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| jobs: | |
| lint-and-unit-test: | |
| name: Lint & Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 22.21 | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: | | |
| yarn --immutable | |
| - name: Run linting | |
| run: yarn lint | |
| - name: Run unit tests | |
| run: yarn test | |
| - name: Upload coverage reports to Codecov | |
| if: success() | |
| uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1.1.0 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| e2e-tests: | |
| name: End-to-End (with mock data) Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 22.21 | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: | | |
| yarn --immutable | |
| - name: Run e2e tests | |
| run: yarn e2e | |
| - name: Upload Cypress screenshots | |
| if: failure() | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: Inventory management system Screenshots | |
| path: cypress/screenshots | |
| e2e-tests-api: | |
| name: End-to-End (with api) Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Clone IMS api repo | |
| uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| with: | |
| repository: ral-facilities/inventory-management-system-api | |
| ref: develop | |
| # This is required as need to setup api in a different directory as checkout will attempt delete | |
| # all existing files which in this case will include a data directory created by docker causing | |
| # a permission error (checkout action also can't specify a different directory to clone into) | |
| - name: Move IMS api repo | |
| run: | | |
| cd .. | |
| mkdir inventory-management-system-api | |
| mv -v inventory-management-system/* inventory-management-system-api/ | |
| cd inventory-management-system-api/ | |
| - name: Start MongoDB (For inventory-management-system-api) | |
| working-directory: ../inventory-management-system-api | |
| run: | | |
| docker compose up --detach mongo-db | |
| # Use docker run here to test the actual built image | |
| # Use same network as the MongoDB instance (which is generated by docker compose based on the folder | |
| # name) | |
| - name: Start inventory-management-system-api | |
| run: | | |
| docker run -d --network=host \ | |
| --name inventory_management_system_api_container \ | |
| --env AUTHENTICATION__ENABLED=false \ | |
| --env API__TITLE="Inventory Management System API" \ | |
| --env API__DESCRIPTION="This is the API for the Inventory Management System" \ | |
| --env DATABASE__PROTOCOL="mongodb" \ | |
| --env DATABASE__USERNAME="root" \ | |
| --env DATABASE__PASSWORD="example" \ | |
| --env DATABASE__HOST_AND_OPTIONS="localhost:27017/?authMechanism=SCRAM-SHA-256&authSource=admin" \ | |
| --env DATABASE__NAME="ims" \ | |
| --env API__ALLOWED_CORS_HEADERS='["*"]' \ | |
| --env API__ALLOWED_CORS_ORIGINS='["*"]' \ | |
| --env API__ALLOWED_CORS_METHODS='["*"]' \ | |
| --env OBJECT_STORAGE__ENABLED=true \ | |
| --env OBJECT_STORAGE__API_REQUEST_TIMEOUT_SECONDS=10 \ | |
| --env OBJECT_STORAGE__API_URL=http://localhost:8002 \ | |
| --volume /home/runner/work/inventory-management-system/inventory-management-system-api/logging.example.ini:/app/logging.ini \ | |
| harbor.stfc.ac.uk/inventory-management-system/ims-api:develop | |
| - name: Clone Object Storage api repo | |
| uses: actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb | |
| with: | |
| repository: ral-facilities/object-storage-api | |
| ref: develop | |
| path: object-storage-api | |
| - name: Move Object Storage api repo | |
| run: | | |
| cd .. | |
| mkdir object-storage-api | |
| mv -v inventory-management-system/* . | |
| cd object-storage-api/ | |
| - name: Start MongoDB and MinIO (For object-storage-api) | |
| working-directory: ../object-storage-api | |
| run: | | |
| docker compose up --detach mongo-db minio | |
| sleep 10 | |
| - name: Create MinIO buckets (For object-storage-api) | |
| working-directory: ../object-storage-api | |
| run: | | |
| docker compose up minio-create-buckets | |
| - name: Start object-storage-api | |
| run: | | |
| docker run -d -p 8002:8000 \ | |
| --name object_storage_api_container \ | |
| --network object-storage-api_default \ | |
| --env AUTHENTICATION__ENABLED=false \ | |
| --env API__TITLE="Object Storage Service API" \ | |
| --env API__DESCRIPTION="This is the API for the Object Storage Service" \ | |
| --env DATABASE__PROTOCOL="mongodb" \ | |
| --env DATABASE__USERNAME="root" \ | |
| --env DATABASE__PASSWORD="example" \ | |
| --env DATABASE__HOST_AND_OPTIONS="object-storage-api-mongodb:27017" \ | |
| --env DATABASE__NAME="object-storage" \ | |
| --env API__ALLOWED_CORS_HEADERS='["*"]' \ | |
| --env API__ALLOWED_CORS_ORIGINS='["*"]' \ | |
| --env API__ALLOWED_CORS_METHODS='["*"]' \ | |
| --env OBJECT_STORAGE__ENDPOINT_URL="http://localhost:9000" \ | |
| --env OBJECT_STORAGE__ACCESS_KEY="root" \ | |
| --env OBJECT_STORAGE__SECRET_ACCESS_KEY="example_password" \ | |
| --env OBJECT_STORAGE__BUCKET_NAME="object-storage" \ | |
| --env OBJECT_STORAGE__PRESIGNED_URL_EXPIRY_SECONDS=1800 \ | |
| --env ATTACHMENT__MAX_SIZE_BYTES=104857600 \ | |
| --env IMAGE__THUMBNAIL_MAX_SIZE_PIXELS=300 \ | |
| --env ATTACHMENT__ALLOWED_FILE_EXTENSIONS='[".csv", ".doc", ".docx", ".ods", ".odt", ".rtf", ".pdf", ".txt", ".xls", ".xlsx"]' \ | |
| --env ATTACHMENT__UPLOAD_LIMIT=50 \ | |
| --env IMAGE__ALLOWED_FILE_EXTENSIONS='[".bmp", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff", ".webp"]' \ | |
| --env IMAGE__UPLOAD_LIMIT=100 \ | |
| --add-host "localhost:host-gateway" \ | |
| --volume /home/runner/work/inventory-management-system/object-storage-api/logging.example.ini:/app/logging.ini \ | |
| harbor.stfc.ac.uk/scd-object-storage-api/object-storage-api:develop | |
| - name: Checkout repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 22.21 | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: | | |
| yarn --immutable | |
| - name: Run e2e tests | |
| run: yarn e2e:api | |
| - name: Output docker logs (ims mongodb) | |
| if: failure() | |
| run: docker logs ims-api-mongodb | |
| - name: Output docker logs (ims api) | |
| if: failure() | |
| run: docker logs inventory_management_system_api_container | |
| - name: Output docker logs (object-storage mongodb) | |
| if: failure() | |
| run: docker logs object-storage-api-mongodb | |
| - name: Output docker logs (object-storage minio) | |
| if: failure() | |
| run: docker logs object-storage-minio | |
| - name: Output docker logs (object-storage api) | |
| if: failure() | |
| run: docker logs object_storage_api_container | |
| - name: Upload Cypress screenshots | |
| if: failure() | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: Inventory management system (with api) Screenshots | |
| path: cypress/screenshots | |
| bundle_analysis: | |
| # This job triggers only if all the other jobs succeed. | |
| needs: [lint-and-unit-test, e2e-tests, e2e-tests-api] | |
| name: Bundle Analysis | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 22.21 | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: | | |
| yarn --immutable | |
| - name: Build app for production | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| # Override the value used in the .env.production | |
| run: VITE_INCLUDE_CODECOV=true yarn build | |
| docker: | |
| # This job triggers only if all the other jobs succeed. It builds the Docker image and if successful, | |
| # it pushes it to Harbor. | |
| needs: [lint-and-unit-test, e2e-tests, e2e-tests-api] | |
| name: Docker | |
| runs-on: ubuntu-latest | |
| env: | |
| PUSH_DOCKER_IMAGE_TO_HARBOR: ${{ inputs.push-docker-image-to-harbor != null && inputs.push-docker-image-to-harbor || 'false' }} | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Login to Harbor | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| registry: ${{ secrets.HARBOR_URL }} | |
| username: ${{ secrets.HARBOR_USERNAME }} | |
| password: ${{ secrets.HARBOR_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0 | |
| with: | |
| images: ${{ secrets.HARBOR_URL }}/ims | |
| - name: ${{ fromJSON(env.PUSH_DOCKER_IMAGE_TO_HARBOR) && 'Build and push Docker image to Harbor' || 'Build Docker image' }} | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
| with: | |
| context: . | |
| file: ./Dockerfile.prod | |
| push: ${{ fromJSON(env.PUSH_DOCKER_IMAGE_TO_HARBOR) }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |