From 8cd30a274598fd908dab2f5cb2715b4a346489a0 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 18 Jul 2024 20:48:27 +0100 Subject: [PATCH] Remove arm64 build --- .github/actions/create-dev-env/action.yml | 27 ---- .github/actions/load-image/action.yml | 31 ---- .../workflows/docker-build-test-upload.yml | 113 +++++++------- .github/workflows/docker-merge-tags.yml | 65 -------- .github/workflows/docker-push.yml | 93 ----------- .github/workflows/docker.yml | 144 ------------------ 6 files changed, 55 insertions(+), 418 deletions(-) delete mode 100644 .github/actions/create-dev-env/action.yml delete mode 100644 .github/actions/load-image/action.yml delete mode 100644 .github/workflows/docker-merge-tags.yml delete mode 100644 .github/workflows/docker-push.yml delete mode 100644 .github/workflows/docker.yml diff --git a/.github/actions/create-dev-env/action.yml b/.github/actions/create-dev-env/action.yml deleted file mode 100644 index b8b3d3d40..000000000 --- a/.github/actions/create-dev-env/action.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -name: Build environment -description: Create build environment - -inputs: - architecture: - description: architecture to be run on - required: true - type: string - -runs: - using: composite - steps: - # actions/setup-python doesn't support Linux arm64 runners - # See: https://github.com/actions/setup-python/issues/108 - # python3 is manually preinstalled in the arm64 VM self-hosted runner - - name: Set Up Python 🐍 - if: ${{ inputs.architecture == 'amd64' }} - uses: actions/setup-python@v4 - with: - python-version: 3.x - - - name: Install Dev Dependencies 📦 - run: | - pip install --upgrade pip - pip install --upgrade -r docker/requirements-dev.txt - shell: bash diff --git a/.github/actions/load-image/action.yml b/.github/actions/load-image/action.yml deleted file mode 100644 index 4bc7a99c6..000000000 --- a/.github/actions/load-image/action.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -name: Load Docker image -description: Download image tar and load it to docker - -inputs: - image: - description: Image name - required: true - type: string - architecture: - description: Image architecture - required: true - type: string - -runs: - using: composite - steps: - - name: Download built image 📥 - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.image }}-${{ inputs.architecture }} - path: /tmp/aiidalab/ - - name: Load downloaded image to docker 📥 - run: | - docker load --input /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar - docker image ls --all - shell: bash - - name: Delete the file 🗑️ - run: rm -f /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar - shell: bash - if: always() diff --git a/.github/workflows/docker-build-test-upload.yml b/.github/workflows/docker-build-test-upload.yml index f4579cf31..520096f5a 100644 --- a/.github/workflows/docker-build-test-upload.yml +++ b/.github/workflows/docker-build-test-upload.yml @@ -1,78 +1,75 @@ --- -name: Build a new image and then upload the image, tags and manifests to GitHub artifacts +name: Build Docker image + +on: + pull_request: + push: + branches: + - main + tags: + - v* + workflow_dispatch: env: - OWNER: ${{ github.repository_owner }} FORCE_COLOR: 1 -on: - workflow_call: - inputs: - image: - description: Image name - required: true - type: string - architecture: - description: Image architecture, e.g. amd64, arm64 - required: true - type: string - runsOn: - description: GitHub Actions Runner image - required: true - type: string +# https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # only cancel in-progress jobs or runs for the current workflow - matches against branch & tags + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build-test-upload: - runs-on: ${{ inputs.runsOn }} + runs-on: ubuntu-latest continue-on-error: true steps: - name: Checkout Repo ⚡️ uses: actions/checkout@v4 - - name: Create dev environment 📦 - uses: ./.github/actions/create-dev-env - with: - architecture: ${{ inputs.architecture }} - # Self-hosted runners share a state (whole VM) between runs - # Also, they might have running or stopped containers, - # which are not cleaned up by `docker system prun` - - name: Reset docker state and cleanup artifacts 🗑️ - if: ${{ startsWith(inputs.runsOn, 'ubuntu') }} - run: | - docker kill $(docker ps --quiet) || true - docker rm $(docker ps --all --quiet) || true - docker system prune --all --force - rm -rf /tmp/aiidalab/ - shell: bash + - name: Login to Container Registry 🔑 + uses: docker/login-action@v2 + if: ${{ !github.event.pull_request.head.repo.fork }} + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Build image 🛠 - working-directory: docker - run: docker buildx bake --set qe.platform=linux/${{ inputs.architecture }} -f docker-bake.hcl -f build.json --load - env: - # Use buildx - DOCKER_BUILDKIT: 1 - # Full logs for CI build - BUILDKIT_PROGRESS: plain - shell: bash + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Run tests ✅ - uses: ./.github/actions/integration-tests + - name: Docker meta 📝 + if: ${{ !github.event.pull_request.head.repo.fork }} + id: meta + uses: docker/metadata-action@v4 with: - architecture: ${{ inputs.architecture }} - runsOn: ${{ inputs.runsOn }} + images: | + name=ghcr.io/{{ github.repository_owner }}/qe + tags: | + type=edge,enable={{is_default_branch}} + type=ref,event=pr + type=match,pattern=v(\d{2}\.\d{2}.\d+.*),group=1 + type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} - - name: Save image as a tar for later use 💾 - run: | - mkdir -p /tmp/aiidalab/ - docker save ${{ env.OWNER }}/${{ inputs.image }} -o /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar - shell: bash - if: always() + - name: Build and load to Docker + id: build-upload + uses: docker/build-push-action@v5 + with: + tags: ${{ steps.meta.outputs.tags }} + load: ${{ github.event.pull_request.head.repo.fork }} + push: ${{ ! github.event.pull_request.head.repo.fork }} + context: . + platforms: linux/amd64 + cache-to: | + type=gha,scope=${{ github.workflow }},mode=min + cache-from: | + type=gha,scope=${{ github.workflow }} - - name: Upload image as artifact 💾 - uses: actions/upload-artifact@v4 + - name: Set Up Python 🐍 + uses: actions/setup-python@v5 with: - name: ${{ inputs.image }}-${{ inputs.architecture }} - path: /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar - retention-days: 3 - if: always() + python-version: 3.11 + + - name: Install Dev Dependencies 📦 + run: pip install -r docker/requirements-dev.txt diff --git a/.github/workflows/docker-merge-tags.yml b/.github/workflows/docker-merge-tags.yml deleted file mode 100644 index b0d43fec6..000000000 --- a/.github/workflows/docker-merge-tags.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -name: Download images tags from GitHub artifacts and create multi-platform manifests - -on: - workflow_call: - inputs: - image: - description: Image name - required: true - type: string - registry: - description: Docker registry, e.g. ghcr.io, docker.io - required: true - type: string - secrets: - REGISTRY_USERNAME: - required: true - REGISTRY_TOKEN: - required: true - - -jobs: - merge-tags: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repo ⚡️ - uses: actions/checkout@v4 - - name: Create dev environment 📦 - uses: ./.github/actions/create-dev-env - with: - architecture: amd64 - - - name: Download amd64 tags file 📥 - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.registry }}-${{ inputs.image }}-amd64-tags - path: /tmp/aiidalab - - name: Download arm64 tags file 📥 - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.registry }}-${{ inputs.image }}-arm64-tags - path: /tmp/aiidalab - - - name: Login to Container Registry 🔑 - uses: docker/login-action@v2 - with: - registry: ${{ inputs.registry }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Merge tags for the images of different arch 🔀 - run: | - for arch_tag in $(cat /tmp/aiidalab/${{ inputs.image }}-amd64-tags.txt); do - tag=$(echo $arch_tag | sed "s/:amd64-/:/") - docker manifest create $tag --amend $arch_tag - docker manifest push $tag - done - - for arch_tag in $(cat /tmp/aiidalab/${{ inputs.image }}-arm64-tags.txt); do - tag=$(echo $arch_tag | sed "s/:arm64-/:/") - docker manifest create $tag --amend $arch_tag - docker manifest push $tag - done - shell: bash diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml deleted file mode 100644 index ddc9d63ee..000000000 --- a/.github/workflows/docker-push.yml +++ /dev/null @@ -1,93 +0,0 @@ ---- -name: Download Docker image and its tags from GitHub artifacts, apply them and push the image to container registry - -env: - OWNER: ${{ github.repository_owner }} - -on: - workflow_call: - inputs: - image: - description: Image name - required: true - type: string - architecture: - description: Image architecture - required: true - type: string - registry: - description: Docker registry - required: true - type: string - secrets: - REGISTRY_USERNAME: - required: true - REGISTRY_TOKEN: - required: true - -jobs: - tag-push: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repo ⚡️ - uses: actions/checkout@v3 - - name: Create dev environment 📦 - uses: ./.github/actions/create-dev-env - with: - architecture: ${{ inputs.architecture }} - - name: Load image to Docker 📥 - uses: ./.github/actions/load-image - with: - image: ${{ inputs.image }} - architecture: ${{ inputs.architecture }} - - - name: Read build variables - working-directory: docker - id: build_vars - run: | - vars=$(cat build.json | jq -c '[.variable | to_entries[] | {"key": .key, "value": .value.default}] | from_entries') - echo "vars=$vars" >> "${GITHUB_OUTPUT}" - - - name: Docker meta 📝 - id: meta - uses: docker/metadata-action@v4 - env: ${{ fromJson(steps.build_vars.outputs.vars) }} - with: - images: | - name=${{ inputs.registry }}/${{ env.OWNER }}/${{ inputs.image }} - tags: | - type=edge,enable={{is_default_branch}} - type=sha,enable=${{ github.ref_type != 'tag' }} - type=ref,event=pr - type=match,pattern=v(\d{2}\.\d{2}.\d+.*),group=1 - type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} - type=raw,value=qe-${{ env.QE_VERSION }},enable=${{ startsWith(github.ref, 'refs/tags/v') }} - - - name: Login to Container Registry 🔑 - uses: docker/login-action@v2 - with: - registry: ${{ inputs.registry }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Set tags for image and push 🏷️📤💾 - run: | - declare -a arr=(${{ steps.meta.outputs.tags }}) - for tag in "${arr[@]}"; do - arch_tag=$(echo ${tag} | sed "s/:/:${{ inputs.architecture }}-/") - docker tag aiidalab/${{ inputs.image }}:newly-baked ${arch_tag} - docker push ${arch_tag} - - # write tag to file - mkdir -p /tmp/aiidalab/ - echo ${arch_tag} >> /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}-tags.txt - done - shell: bash - - - name: Upload tags file 📤 - uses: actions/upload-artifact@v4 - with: - name: ${{ inputs.registry }}-${{ inputs.image }}-${{ inputs.architecture }}-tags - path: /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}-tags.txt - retention-days: 3 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 32d0d64a9..000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,144 +0,0 @@ ---- -name: Build, and push Docker Image - -on: - pull_request: - paths: - - .github/workflows/docker.yml - # We use local reusable workflows to make architecture clean an simple - # https://docs.github.com/en/actions/using-workflows/reusing-workflows - - .github/workflows/docker-build-test-upload.yml - - .github/workflows/docker-merge-tags.yml - - .github/workflows/docker-push.yml - - # We use local composite actions to combine multiple workflow steps within one action - # https://docs.github.com/en/actions/creating-actions/about-custom-actions#composite-actions - - .github/actions/create-dev-env/action.yml - - .github/actions/load-image/action.yml - - - src/** - - docker/** - - qe.ipynb - - setup.cfg - - pyproject.toml - - push: - branches: - - main - tags: - - v* - paths: - - .github/workflows/docker.yml - # We use local reusable workflows to make architecture clean an simple - # https://docs.github.com/en/actions/using-workflows/reusing-workflows - - .github/workflows/docker-build-test-upload.yml - - .github/workflows/docker-merge-tags.yml - - .github/workflows/docker-push.yml - - # We use local composite actions to combine multiple workflow steps within one action - # https://docs.github.com/en/actions/creating-actions/about-custom-actions#composite-actions - - .github/actions/create-dev-env/action.yml - - .github/actions/load-image/action.yml - - - src/** - - docker/** - - qe.ipynb - - setup.cfg - - pyproject.toml - workflow_dispatch: - schedule: - # Periodically build and test the image and keep `edge` always up-to-date - # Weekly, at 03:00 on Monday UTC time - - cron: 0 3 * * 1 - -# https://docs.github.com/en/actions/using-jobs/using-concurrency -concurrency: - # only cancel in-progress jobs or runs for the current workflow - matches against branch & tags - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - amd64: - uses: ./.github/workflows/docker-build-test-upload.yml - with: - image: qe - architecture: amd64 - runsOn: ubuntu-latest - - arm64: - uses: ./.github/workflows/docker-build-test-upload.yml - with: - image: qe - architecture: arm64 - runsOn: ARM64 - if: ${{ !github.event.pull_request.head.repo.fork }} - - amd64-push-ghcr: - uses: ./.github/workflows/docker-push.yml - with: - image: qe - architecture: amd64 - registry: ghcr.io - secrets: - REGISTRY_USERNAME: ${{ github.actor }} - REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - needs: [amd64] - if: ${{ !github.event.pull_request.head.repo.fork }} - - arm64-push-ghcr: - uses: ./.github/workflows/docker-push.yml - with: - image: qe - architecture: arm64 - registry: ghcr.io - secrets: - REGISTRY_USERNAME: ${{ github.actor }} - REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - needs: [arm64] - if: ${{ !github.event.pull_request.head.repo.fork }} - - merge-tags-ghcr: - uses: ./.github/workflows/docker-merge-tags.yml - with: - image: qe - registry: ghcr.io - secrets: - REGISTRY_USERNAME: ${{ github.actor }} - REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - needs: [amd64-push-ghcr, arm64-push-ghcr] - if: ${{ !github.event.pull_request.head.repo.fork }} - - amd64-push-dockerhub: - if: github.repository == 'aiidalab/aiidalab-qe' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: ./.github/workflows/docker-push.yml - with: - image: qe - architecture: amd64 - registry: docker.io - secrets: - REGISTRY_USERNAME: ${{ secrets.DOCKER_USERNAME }} - REGISTRY_TOKEN: ${{ secrets.DOCKER_PASSWORD }} - needs: [amd64] - - arm64-push-dockerhub: - if: github.repository == 'aiidalab/aiidalab-qe' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: ./.github/workflows/docker-push.yml - with: - image: qe - architecture: arm64 - registry: docker.io - secrets: - REGISTRY_USERNAME: ${{ secrets.DOCKER_USERNAME }} - REGISTRY_TOKEN: ${{ secrets.DOCKER_PASSWORD }} - needs: [arm64] - - merge-tags-dockerhub: - if: github.repository == 'aiidalab/aiidalab-qe' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: ./.github/workflows/docker-merge-tags.yml - with: - image: qe - registry: docker.io - secrets: - REGISTRY_USERNAME: ${{ secrets.DOCKER_USERNAME }} - REGISTRY_TOKEN: ${{ secrets.DOCKER_PASSWORD }} - needs: [amd64-push-dockerhub, arm64-push-dockerhub]