diff --git a/.github/actions/load-img/action.yml b/.github/actions/load-img/action.yml index b9eb821043..0ad6f34947 100644 --- a/.github/actions/load-img/action.yml +++ b/.github/actions/load-img/action.yml @@ -3,91 +3,41 @@ description: Download and import Docker images from artifacts inputs: setup_images: - default: '["upstream_db", "ingestion_server", "catalog", "api", "api_nginx", "frontend"]' - description: JSON-encoded list of image names + default: "upstream_db ingestion_server catalog api api_nginx frontend" + description: Space-separated list of image names runs: using: "composite" steps: - # Upstream DB - - name: Download image `upstream_db` - uses: actions/download-artifact@v3 - if: contains(fromJson(inputs.setup_images), 'upstream_db') - with: - name: upstream_db - path: /tmp - - - name: Load image `upstream_db` - if: contains(fromJson(inputs.setup_images), 'upstream_db') - shell: bash - run: | - docker load --input /tmp/upstream_db.tar - - # Catalog - - name: Download image `catalog` - uses: actions/download-artifact@v3 - if: contains(fromJson(inputs.setup_images), 'catalog') - with: - name: catalog - path: /tmp - - - name: Load image `catalog` - if: contains(fromJson(inputs.setup_images), 'catalog') - shell: bash - run: | - docker load --input /tmp/catalog.tar - - # Ingestion server - - name: Download image `ingestion_server` - uses: actions/download-artifact@v3 - if: contains(fromJson(inputs.setup_images), 'ingestion_server') - with: - name: ingestion_server - path: /tmp - - - name: Load image `ingestion_server` - if: contains(fromJson(inputs.setup_images), 'ingestion_server') - shell: bash - run: | - docker load --input /tmp/ingestion_server.tar - - # API - - name: Download image `api` - uses: actions/download-artifact@v3 - if: contains(fromJson(inputs.setup_images), 'api') - with: - name: api - path: /tmp + - name: Checkout repository + uses: actions/checkout@v3 - - name: Load image `api` - if: contains(fromJson(inputs.setup_images), 'api') - shell: bash - run: | - docker load --input /tmp/api.tar - - - name: Download image `api_nginx` - uses: actions/download-artifact@v3 - if: contains(fromJson(inputs.setup_images), 'api_nginx') + # Doesn't use `setup-env` because the next step uses `npm`, not `pnpm`. + - name: Setup Node.js + uses: actions/setup-node@v3 with: - name: api_nginx - path: /tmp + node-version: "16" - - name: Load image `api_nginx` - if: contains(fromJson(inputs.setup_images), 'api_nginx') + - name: Install `@actions/artifact` shell: bash run: | - docker load --input /tmp/api_nginx.tar + npm install @actions/artifact - # Frontend - - name: Download image `frontend` - uses: actions/download-artifact@v3 - if: contains(fromJson(inputs.setup_images), 'frontend') + - name: Download images + uses: actions/github-script@v6 with: - name: frontend - path: /tmp - - - name: Load image `frontend` - if: contains(fromJson(inputs.setup_images), 'frontend') + script: | + const artifact = require("@actions/artifact") + const artifactClient = artifact.create() + const images = "${{ inputs.setup_images }}".split(" ") + for (image of images) { + await artifactClient.downloadArtifact(image, "/tmp", { createArtifactFolder: false }) + } + + - name: Load images shell: bash run: | - docker load --input /tmp/frontend.tar + images=(${{ inputs.setup_images }}); + for image in "${images[@]}"; do + docker load --input /tmp/${image}.tar + done diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index d3b10a2471..858b8ed726 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -252,7 +252,7 @@ jobs: - name: Load Docker images uses: ./.github/actions/load-img with: - setup_images: '["upstream_db", "catalog"]' + setup_images: upstream_db catalog - name: Run tests run: | @@ -281,7 +281,7 @@ jobs: - name: Load Docker images uses: ./.github/actions/load-img with: - setup_images: '["upstream_db", "catalog"]' + setup_images: upstream_db catalog - name: Check DAG documentation run: | @@ -315,7 +315,7 @@ jobs: - name: Load Docker images uses: ./.github/actions/load-img with: - setup_images: '["upstream_db", "ingestion_server"]' + setup_images: upstream_db ingestion_server - name: Run ingestion-server tests run: just ingestion_server/test-local @@ -360,7 +360,7 @@ jobs: - name: Load Docker images uses: ./.github/actions/load-img with: - setup_images: '["upstream_db", "ingestion_server", "api"]' + setup_images: upstream_db ingestion_server api - name: Start API, ingest and index test data run: just api/init @@ -413,7 +413,7 @@ jobs: - name: Load Docker images uses: ./.github/actions/load-img with: - setup_images: '["upstream_db", "ingestion_server", "api"]' + setup_images: upstream_db ingestion_server api - name: Run check recipe run: just ${{ matrix.recipe }} @@ -798,7 +798,7 @@ jobs: - name: Load Docker image `${{ matrix.image }}` uses: ./.github/actions/load-img with: - setup_images: ${{ format('["{0}"]', matrix.image) }} + setup_images: ${{ matrix.image }} - name: Load and tag image `${{ matrix.image }}` (latest & sha) run: | diff --git a/documentation/meta/ci_cd/actions.md b/documentation/meta/ci_cd/actions.md index 53d39cd4cb..e896983ce6 100644 --- a/documentation/meta/ci_cd/actions.md +++ b/documentation/meta/ci_cd/actions.md @@ -59,13 +59,13 @@ downloads the artifact and load the `.tar` files into Docker as images. **Inputs:** -By default, all images built by the Docker system will be loaded but if the job -only needs a subset of images, those can be set via the `setup_images` input, -passing a JSON encoded array of image names as strings. +By default, all images built by the Docker system will be loaded. However, if +the job only needs a subset of images, those can be set via the `setup_images` +input, passing a space-separated list of image names. ```typescript { - setup_images: string // default: '["upstream_db", "ingestion_server", "catalog", "api", "api_nginx", "frontend"]' + setup_images: string // default: 'upstream_db ingestion_server catalog api api_nginx frontend' } ```