From 02498d2f8ffc594ad03d23d067fc2eb18f50db8e Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 23 Apr 2024 01:10:46 +0100 Subject: [PATCH 01/43] CI: WIP: Refactore docker build --- .docker/docker-bake.hcl | 2 +- .github/actions/create-dev-env/action.yml | 1 - .github/actions/load-image/action.yml | 30 ------- .../workflows/docker-build-test-upload.yml | 83 ------------------ .github/workflows/docker-build.yml | 30 +++++++ .github/workflows/docker-merge-tags.yml | 65 -------------- .github/workflows/docker-push.yml | 54 +----------- .github/workflows/docker.yml | 84 ++++--------------- 8 files changed, 49 insertions(+), 300 deletions(-) delete mode 100644 .github/actions/load-image/action.yml delete mode 100644 .github/workflows/docker-build-test-upload.yml create mode 100644 .github/workflows/docker-build.yml delete mode 100644 .github/workflows/docker-merge-tags.yml diff --git a/.docker/docker-bake.hcl b/.docker/docker-bake.hcl index 533995af8d..41fa93b6f5 100644 --- a/.docker/docker-bake.hcl +++ b/.docker/docker-bake.hcl @@ -27,7 +27,7 @@ variable "TARGETS" { function "tags" { params = [image] result = [ - "${REGISTRY}${ORGANIZATION}/${image}:newly-baked" + "${REGISTRY}${ORGANIZATION}/${image}" ] } diff --git a/.github/actions/create-dev-env/action.yml b/.github/actions/create-dev-env/action.yml index 8ad3a4a125..a012197dad 100644 --- a/.github/actions/create-dev-env/action.yml +++ b/.github/actions/create-dev-env/action.yml @@ -5,7 +5,6 @@ inputs: architecture: description: architecture to be run on required: true - type: string runs: using: composite diff --git a/.github/actions/load-image/action.yml b/.github/actions/load-image/action.yml deleted file mode 100644 index 6598424fdd..0000000000 --- a/.github/actions/load-image/action.yml +++ /dev/null @@ -1,30 +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/ - - name: Load downloaded image to docker 📥 - run: | - docker load --input /tmp/${{ inputs.image }}-${{ inputs.architecture }}.tar - docker image ls --all - shell: bash - - name: Delete the file 🗑️ - run: rm -f /tmp/${{ 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 deleted file mode 100644 index 3195206afa..0000000000 --- a/.github/workflows/docker-build-test-upload.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Build image and then upload the image, tags and manifests to GitHub artifacts - -env: - OWNER: ${{ github.repository_owner }} - -on: - workflow_call: - inputs: - architecture: - description: Image architecture, e.g. amd64, arm64 - required: true - type: string - runsOn: - description: GitHub Actions Runner image - required: true - type: string - -jobs: - build-test-upload: - runs-on: ${{ inputs.runsOn }} - defaults: - run: - shell: bash - working-directory: .docker - - 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: ${{ inputs.platform != 'x86_64' }} - run: | - docker kill $(docker ps --quiet) || true - docker rm $(docker ps --all --quiet) || true - docker system prune --all --force - rm -rf /tmp/aiida-core/ - shell: bash - - - name: Build aiida-core images - # The order of the buildx bake files is important, as the second one will overwrite the first one - run: docker buildx bake -f docker-bake.hcl -f build.json --set *.platform=linux/${{ inputs.architecture }} --load - env: - # Full logs for CI build - BUILDKIT_PROGRESS: plain - - - name: Run tests ✅ - run: TAG=newly-baked python -m pytest -s tests - - - name: Save images as tar for later use 💾 - run: | - mkdir -p /tmp/aiida-core - docker save ${{ env.OWNER }}/aiida-core-base -o /tmp/aiida-core/aiida-core-base-${{ inputs.architecture }}.tar - docker save ${{ env.OWNER }}/aiida-core-with-services -o /tmp/aiida-core/aiida-core-with-services-${{ inputs.architecture }}.tar - docker save ${{ env.OWNER }}/aiida-core-dev -o /tmp/aiida-core/aiida-core-dev-${{ inputs.architecture }}.tar - - - name: Upload aiida-core-base image as artifact 💾 - uses: actions/upload-artifact@v4 - with: - name: aiida-core-base-${{ inputs.architecture }} - path: /tmp/aiida-core/aiida-core-base-${{ inputs.architecture }}.tar - retention-days: 3 - - - name: Upload aiida-core-with-services image as artifact 💾 - uses: actions/upload-artifact@v4 - with: - name: aiida-core-with-services-${{ inputs.architecture }} - path: /tmp/aiida-core/aiida-core-with-services-${{ inputs.architecture }}.tar - retention-days: 3 - - - name: Upload aiida-core-dev image as artifact 💾 - uses: actions/upload-artifact@v4 - with: - name: aiida-core-dev-${{ inputs.architecture }} - path: /tmp/aiida-core/aiida-core-dev-${{ inputs.architecture }}.tar - retention-days: 3 diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000000..7be021a9b4 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,30 @@ +name: Build image and then upload the image, tags and manifests to GitHub artifacts + +env: + OWNER: ${{ github.repository_owner }} + # Full logs for CI build + BUILDKIT_PROGRESS: plain + +on: + workflow_call: + inputs: + runsOn: + description: GitHub Actions Runner image + required: true + type: string + +jobs: + build-test-upload: + runs-on: ${{ inputs.runsOn }} + defaults: + run: + shell: bash + working-directory: .docker + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Build aiida-core images for amd64 + # The order of the buildx bake files is important, as the second one will overwrite the first one + run: docker buildx bake -f docker-bake.hcl -f build.json --set *.platform=linux/$amd64 --load diff --git a/.github/workflows/docker-merge-tags.yml b/.github/workflows/docker-merge-tags.yml deleted file mode 100644 index e82661e376..0000000000 --- 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: - 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 - strategy: - matrix: - image: [aiida-core-base, aiida-core-with-services, aiida-core-dev] - permissions: - packages: write - - 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 }}-${{ matrix.image }}-amd64-tags - path: /tmp/aiida-core - - name: Download arm64 tags file 📥 - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.registry }}-${{ matrix.image }}-arm64-tags - path: /tmp/aiida-core - - - 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/aiida-core/${{ matrix.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/aiida-core/${{ matrix.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 index 912738dcd9..02868b4491 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -5,20 +5,6 @@ env: on: workflow_call: - inputs: - 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: @@ -31,20 +17,11 @@ jobs: shell: bash working-directory: .docker permissions: - packages: write + packages: read steps: - name: Checkout Repo ⚡️ uses: actions/checkout@v4 - - 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: ${{ matrix.image }} - architecture: ${{ inputs.architecture }} - name: Read build variables id: build_vars @@ -58,7 +35,7 @@ jobs: env: ${{ fromJson(steps.build_vars.outputs.vars) }} with: images: | - name=${{ inputs.registry }}/${{ env.OWNER }}/${{ matrix.image }} + name=docker.io/${{ env.OWNER }}/${{ matrix.image }} tags: | type=edge,enable={{is_default_branch}} type=sha,enable=${{ github.ref_type != 'tag' }} @@ -67,30 +44,3 @@ jobs: type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=raw,value=python-${{ env.PYTHON_VERSION }},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=raw,value=postgresql-${{ env.PGSQL_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 ${{ env.OWNER }}/${{ matrix.image }}:newly-baked ${arch_tag} - docker push ${arch_tag} - - # write tag to file - mkdir -p /tmp/aiida-core - echo ${arch_tag} >> /tmp/aiida-core/${{ matrix.image }}-${{ inputs.architecture }}-tags.txt - done - - - name: Upload tags file 📤 - uses: actions/upload-artifact@v4 - with: - name: ${{ inputs.registry }}-${{ matrix.image }}-${{ inputs.architecture }}-tags - path: /tmp/aiida-core/${{ matrix.image }}-${{ inputs.architecture }}-tags.txt - retention-days: 3 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 30a41ed5b0..ac2d6cbf1f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,79 +23,27 @@ concurrency: cancel-in-progress: true jobs: - amd64-build: - uses: ./.github/workflows/docker-build-test-upload.yml + build: + uses: ./.github/workflows/docker-build.yml with: - architecture: amd64 - runsOn: ubuntu-latest - - arm64-build: - uses: ./.github/workflows/docker-build-test-upload.yml - with: - architecture: arm64 - runsOn: ARM64 - if: ${{ !github.event.pull_request.head.repo.fork }} - - amd64-push-ghcr: - uses: ./.github/workflows/docker-push.yml - with: - architecture: amd64 - registry: ghcr.io - secrets: - REGISTRY_USERNAME: ${{ github.actor }} - REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - needs: [amd64-build] - if: ${{ !github.event.pull_request.head.repo.fork }} - - arm64-push-ghcr: - uses: ./.github/workflows/docker-push.yml - with: - architecture: arm64 - registry: ghcr.io - secrets: - REGISTRY_USERNAME: ${{ github.actor }} - REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - needs: [arm64-build] - if: ${{ !github.event.pull_request.head.repo.fork }} + runsOn: ubuntu-22.04 - merge-tags-ghcr: - uses: ./.github/workflows/docker-merge-tags.yml + test: + needs: build + uses: ./.github/workflows/docker-test.yml + strategy: + matrix: + targets: [aiida-core-base, aiida-core-with-services, aiida-core-dev] + runsOn: [ARM64, ubuntu-22.04] with: - 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 }} + runsOn: ${{ matrix.runsOn }} + target: ${{ matrix.target }} - amd64-push-dockerhub: + publish: if: github.repository == 'aiidateam/aiida-core' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: ./.github/workflows/docker-push.yml + needs: [build, test] + uses: ./.github/workflows/docker-publish.yml with: architecture: amd64 registry: docker.io - secrets: - REGISTRY_USERNAME: ${{ secrets.DOCKER_USERNAME }} - REGISTRY_TOKEN: ${{ secrets.DOCKER_TOKEN }} - needs: [amd64-build] - - arm64-push-dockerhub: - if: github.repository == 'aiidateam/aiida-core' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: ./.github/workflows/docker-push.yml - with: - architecture: arm64 - registry: docker.io - secrets: - REGISTRY_USERNAME: ${{ secrets.DOCKER_USERNAME }} - REGISTRY_TOKEN: ${{ secrets.DOCKER_TOKEN }} - needs: [arm64-build] - - merge-tags-dockerhub: - if: github.repository == 'aiidateam/aiida-core' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: ./.github/workflows/docker-merge-tags.yml - with: - registry: docker.io - secrets: - REGISTRY_USERNAME: ${{ secrets.DOCKER_USERNAME }} - REGISTRY_TOKEN: ${{ secrets.DOCKER_TOKEN }} - needs: [amd64-push-dockerhub, arm64-push-dockerhub] + secrets: inherit From 7ab005aa888494a49cbdef851a1c7ac18273cb8f Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 23 Apr 2024 09:42:40 +0100 Subject: [PATCH 02/43] Remove pre-commit from requirements --- .docker/requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/.docker/requirements.txt b/.docker/requirements.txt index 3ba15482bb..85be15c317 100644 --- a/.docker/requirements.txt +++ b/.docker/requirements.txt @@ -1,8 +1,6 @@ docker -pre-commit pytest requests tabulate pytest-docker docker-compose -pyyaml<=5.3.1 From 29768ad5a04af362e9b0f17b08c8150981fd5eeb Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 23 Apr 2024 09:52:52 +0100 Subject: [PATCH 03/43] Add docker-test --- .github/workflows/docker-push.yml | 2 +- .github/workflows/docker-test.yml | 54 +++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 3 +- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/docker-test.yml diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index 02868b4491..1bb67994c8 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -1,4 +1,4 @@ -name: Download Docker image and its tags from GitHub artifacts, apply them and push the image to container registry +name: Publish images to DockerHub env: OWNER: ${{ github.repository_owner }} diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 0000000000..b06bd41ddd --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -0,0 +1,54 @@ +name: Test newly built images + +on: + workflow_call: + inputs: + runsOn: + description: GitHub Actions Runner image + required: true + type: string + images: + description: Images built in build step + required: true + type: string + +jobs: + + test: + runs-on: ${{ inputs.runsOn }} + timeout-minutes: 30 + strategy: + matrix: + target: [aiida-core-base, aiida-core-with-services, aiida-core-dev] + defaults: + run: + shell: bash + working-directory: .docker + + steps: + + - name: Checkout Repo ⚡️ + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry 🔑 + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set Up Python 🐍 + if: ${{ inputs.runsOn != 'ARM64' }} + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: pip + + - name: Install dependencies 📦 + run: | + pip install -r requirements.txt + pip freeze + + - name: Run tests + run: pytest -s + env: ${{ fromJSON(inputs.images) }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ac2d6cbf1f..b62db193b3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -33,11 +33,10 @@ jobs: uses: ./.github/workflows/docker-test.yml strategy: matrix: - targets: [aiida-core-base, aiida-core-with-services, aiida-core-dev] runsOn: [ARM64, ubuntu-22.04] with: runsOn: ${{ matrix.runsOn }} - target: ${{ matrix.target }} + images: ${{ needs.build.images }} publish: if: github.repository == 'aiidateam/aiida-core' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) From b141d5bd08230cc24ce3a6e5ab807889959add3b Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 23 Apr 2024 10:10:21 +0100 Subject: [PATCH 04/43] Docker publish --- .../{docker-push.yml => docker-publish.yml} | 44 +++++++++++++++++-- .github/workflows/docker.yml | 3 -- 2 files changed, 41 insertions(+), 6 deletions(-) rename .github/workflows/{docker-push.yml => docker-publish.yml} (51%) diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-publish.yml similarity index 51% rename from .github/workflows/docker-push.yml rename to .github/workflows/docker-publish.yml index 1bb67994c8..6adc5370eb 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-publish.yml @@ -5,11 +5,22 @@ env: on: workflow_call: + inputs: + runsOn: + description: GitHub Actions Runner image + required: true + type: string + images: + description: Images built in build step + required: true + type: string jobs: tag-push: runs-on: ubuntu-latest + timeout-minutes: 30 strategy: + fail-fast: true matrix: image: [aiida-core-base, aiida-core-with-services, aiida-core-dev] defaults: @@ -23,24 +34,51 @@ jobs: - name: Checkout Repo ⚡️ uses: actions/checkout@v4 + - name: Login to GitHub Container Registry 🔑 + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to DockerHub 🔑 + uses: docker/login-action@v3 + with: + registry: docker.io + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Read build variables id: build_vars run: | vars=$(cat build.json | jq -c '[.variable | to_entries[] | {"key": .key, "value": .value.default}] | from_entries') + echo "vars=$vars" echo "vars=$vars" >> "${GITHUB_OUTPUT}" - name: Docker meta 📝 id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 env: ${{ fromJson(steps.build_vars.outputs.vars) }} with: images: | name=docker.io/${{ env.OWNER }}/${{ matrix.image }} tags: | type=edge,enable={{is_default_branch}} - type=sha,enable=${{ github.ref_type != 'tag' }} - type=ref,event=pr type=match,pattern=v(\d+\.\d+.\d+),group=1 type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=raw,value=python-${{ env.PYTHON_VERSION }},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=raw,value=postgresql-${{ env.PGSQL_VERSION }},enable=${{ startsWith(github.ref, 'refs/tags/v') }} + + - name: Determine src image tag + id: images + run: | + src=$(echo '${{ inputs.images }}'| jq -cr '.[("${{ matrix.target }}"|ascii_upcase|sub("-"; "_"; "g")) + "_IMAGE"]') + echo "src=$src" + echo "src=$src" >> "${GITHUB_OUTPUT}" + + - name: Push image to docker.io + uses: akhilerm/tag-push-action@v2.2.0 + if: false # TODO: Enable this! + with: + src: ${{ steps.images.outputs.src }} + dst: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b62db193b3..c5dbb92441 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -42,7 +42,4 @@ jobs: if: github.repository == 'aiidateam/aiida-core' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) needs: [build, test] uses: ./.github/workflows/docker-publish.yml - with: - architecture: amd64 - registry: docker.io secrets: inherit From 967b6374bef7bc8a9d5ae613e54fa87feb0fe421 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 23 Apr 2024 10:23:12 +0100 Subject: [PATCH 05/43] Initial build workflow --- .github/workflows/docker-build.yml | 59 ++++++++++++++++++- .../workflows/extract-docker-image-names.sh | 53 +++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100755 .github/workflows/extract-docker-image-names.sh diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 7be021a9b4..d42b1018ea 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -14,7 +14,7 @@ on: type: string jobs: - build-test-upload: + build: runs-on: ${{ inputs.runsOn }} defaults: run: @@ -28,3 +28,60 @@ jobs: - name: Build aiida-core images for amd64 # The order of the buildx bake files is important, as the second one will overwrite the first one run: docker buildx bake -f docker-bake.hcl -f build.json --set *.platform=linux/$amd64 --load + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry 🔑 + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # TODO: Separate amd64 build just just for testing now + - name: Build amd64 images 🏗️ + id: build-amd64 + uses: docker/bake-action@v4 + with: + push: true + set: | + *.platform=linux/amd64 + files: | + docker-bake.hcl + build.json + + - name: Set output variables + run: .github/workflows/extract-docker-image-names.sh >> "${GITHUB_OUTPUT}" + env: + BAKE_METADATA: ${{ steps.build-amd64.outputs.metadata }} + + # Here we build arm64 images (with help of QEMU virtualization) + # and upload both amd64 and arm64 images to ghcr.io + - name: Build ARM64 and upload to ghcr.io 🍎📤 + id: build-upload + if: false + uses: docker/bake-action@v4 + with: + # TODO: Actually push, add tags first though! + load: true + push: false + # Using provenance to disable default attestation so it will build only desired images: + # https://github.com/orgs/community/discussions/45969 + provenance: false + # NOTE: linux/amd64 images are taken from previous step + set: | + *.platform=linux/amd64,linux/arm64 + files: | + docker-bake.hcl + build.json + + - name: Set output variables + if: false + id: bake_metadata + run: .github/workflows/extract-docker-image-names.sh >> "${GITHUB_OUTPUT}" + env: + BAKE_METADATA: ${{ steps.build-upload.outputs.metadata }} diff --git a/.github/workflows/extract-docker-image-names.sh b/.github/workflows/extract-docker-image-names.sh new file mode 100755 index 0000000000..c40c602904 --- /dev/null +++ b/.github/workflows/extract-docker-image-names.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +set -euo pipefail + +# Extract image names together with their digests +# to uniquely identify newly built images in subsequent steps. + +# TODO: Make these examples specific to aiida-core +# +# The input to this script is a JSON string passed via BAKE_METADATA env variable +# Here's example input (trimmed to relevant bits): +# BAKE_META: { +# "base": { +# "buildx.build.ref": "builder-9dc30f03-42f5-4fd5-8c9a-0d54be5ad996/builder-9dc30f03-42f5-4fd5-8c9a-0d54be5ad9960/jex1w6zvslbbomtkedn4no62l", +# "containerimage.config.digest": "sha256:b76dc61672dd0efbd586d56393d3a57f6309654e6903d738168892bc09017e8b", +# "containerimage.descriptor": { +# "mediaType": "application/vnd.docker.distribution.manifest.v2+json", +# "digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", +# "size": 6170, +# "platform": { +# "architecture": "amd64", +# "os": "linux" +# } +# }, +# "containerimage.digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", +# "image.name": "ghcr.io/aiidalab/base:pr-439,ghcr.io/aiidalab/base:sha-a0cd2be" +# }, +# "base-with-services": { +# "containerimage.digest": "sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", +# "...": "" +# } +# "full-stack": { +# "containerimage.digest": "sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", +# "...": "" +# } +# } +# +# Example output (real output is on one line): +# +# images={ +# "BASE_IMAGE":"ghcr.io/aiidalab/base:pr-439@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", +# "BASE_WITH_SERVICES_IMAGE":"ghcr.io/aiidalab/base-with-services:pr-439@sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", +# "FULL_STACK_IMAGE":"ghcr.io/aiidalab/full-stack:pr-439@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", +# "LAB_IMAGE":"ghcr.io/aiidalab/lab:pr-439@sha256:4d9be090da287fcdf2d4658bb82f78bad791ccd15dac9af594fb8306abe47e97" +# } + +if [[ -z ${BAKE_METADATA-} ]];then + echo "ERROR: Environment variable BAKE_METADATA is not set!" + exit 1 +fi + +images=$(echo "${BAKE_METADATA}" | jq -c '. as $base |[to_entries[] |{"key": (.key|ascii_upcase|sub("-"; "_"; "g") + "_IMAGE"), "value": [(.value."image.name"|split(",")[0]),.value."containerimage.digest"]|join("@")}] |from_entries') +echo "images=$images" From e64965abcb40e0fda0740c638edcb6b50ac5ea84 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 23 Apr 2024 10:25:11 +0100 Subject: [PATCH 06/43] remove action --- .github/actions/create-dev-env/action.yml | 25 ----------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/actions/create-dev-env/action.yml diff --git a/.github/actions/create-dev-env/action.yml b/.github/actions/create-dev-env/action.yml deleted file mode 100644 index a012197dad..0000000000 --- a/.github/actions/create-dev-env/action.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Build environment -description: Create build environment - -inputs: - architecture: - description: architecture to be run on - required: true - -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 🐍 - uses: actions/setup-python@v5 - with: - python-version: 3.x - if: ${{ inputs.architecture == 'amd64' }} - - - name: Install Dev Dependencies 📦 - run: | - pip install --upgrade pip - pip install --upgrade -r .docker/requirements.txt - shell: bash From fc00eb04746a9b1bfe40a01a9c3a620b4b3e3cd6 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 13 May 2024 11:15:28 +0100 Subject: [PATCH 07/43] Updates from aiidalab stack --- .docker/docker-bake.hcl | 2 +- .github/workflows/docker-build.yml | 72 ++++++++----------- .github/workflows/docker-publish.yml | 54 +++++++------- .github/workflows/docker-test.yml | 12 ++-- .github/workflows/docker.yml | 48 +++++++++++-- .../workflows/extract-docker-image-names.sh | 42 ++++++----- 6 files changed, 130 insertions(+), 100 deletions(-) diff --git a/.docker/docker-bake.hcl b/.docker/docker-bake.hcl index 41fa93b6f5..0785e27190 100644 --- a/.docker/docker-bake.hcl +++ b/.docker/docker-bake.hcl @@ -13,7 +13,7 @@ variable "ORGANIZATION" { } variable "REGISTRY" { - default = "docker.io/" + default = "ghcr.io/" } variable "PLATFORMS" { diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index d42b1018ea..0784c696f3 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,8 +1,6 @@ -name: Build image and then upload the image, tags and manifests to GitHub artifacts +name: Build Docker images and upload them to ghcr.io env: - OWNER: ${{ github.repository_owner }} - # Full logs for CI build BUILDKIT_PROGRESS: plain on: @@ -12,24 +10,36 @@ on: description: GitHub Actions Runner image required: true type: string + platforms: + description: Target platforms for the build (linux/amd64 and/or linux/arm64) + required: true + type: string + outputs: + images: + description: Images identified by digests + value: ${{ jobs.build.outputs.images }} jobs: build: + name: ${{ inputs.platforms }} runs-on: ${{ inputs.runsOn }} + timeout-minutes: 60 defaults: run: - shell: bash + # Make sure we fail if any command in a piped command sequence fails + shell: bash -e -o pipefail {0} working-directory: .docker + outputs: + images: ${{ steps.bake_metadata.outputs.images }} + steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - name: Build aiida-core images for amd64 - # The order of the buildx bake files is important, as the second one will overwrite the first one - run: docker buildx bake -f docker-bake.hcl -f build.json --set *.platform=linux/$amd64 --load + - name: Checkout Repo ⚡️ + uses: actions/checkout@v4 - name: Set up QEMU + if: ${{ inputs.platforms != 'linux/amd64' }} uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -38,50 +48,30 @@ jobs: - name: Login to GitHub Container Registry 🔑 uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # TODO: Separate amd64 build just just for testing now - - name: Build amd64 images 🏗️ - id: build-amd64 + - name: Build and upload to ghcr.io 📤 + id: build uses: docker/bake-action@v4 with: push: true - set: | - *.platform=linux/amd64 - files: | - docker-bake.hcl - build.json - - - name: Set output variables - run: .github/workflows/extract-docker-image-names.sh >> "${GITHUB_OUTPUT}" - env: - BAKE_METADATA: ${{ steps.build-amd64.outputs.metadata }} - - # Here we build arm64 images (with help of QEMU virtualization) - # and upload both amd64 and arm64 images to ghcr.io - - name: Build ARM64 and upload to ghcr.io 🍎📤 - id: build-upload - if: false - uses: docker/bake-action@v4 - with: - # TODO: Actually push, add tags first though! - load: true - push: false - # Using provenance to disable default attestation so it will build only desired images: - # https://github.com/orgs/community/discussions/45969 + # Using provenance to disable default attestation so it will build only desired images: + # https://github.com/orgs/community/discussions/45969 provenance: false - # NOTE: linux/amd64 images are taken from previous step set: | - *.platform=linux/amd64,linux/arm64 + *.platform=${{ inputs.platforms }} + *.output=type=registry,push-by-digest=true,name-canonical=true + *.cache-to=type=gha,scope=${{ github.workflow }},mode=max + *.cache-from=type=gha,scope=${{ github.workflow }} files: | docker-bake.hcl build.json - name: Set output variables - if: false id: bake_metadata - run: .github/workflows/extract-docker-image-names.sh >> "${GITHUB_OUTPUT}" + run: | + .github/workflows/extract-docker-image-names.sh | tee -a "${GITHUB_OUTPUT}" env: - BAKE_METADATA: ${{ steps.build-upload.outputs.metadata }} + BAKE_METADATA: ${{ steps.build.outputs.metadata }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 6adc5370eb..259df9b03e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,7 +1,8 @@ -name: Publish images to DockerHub +name: Publish images to Docker container registries env: - OWNER: ${{ github.repository_owner }} + # https://github.com/docker/metadata-action?tab=readme-ov-file#environment-variables + DOCKER_METADATA_PR_HEAD_SHA: true on: workflow_call: @@ -14,25 +15,23 @@ on: description: Images built in build step required: true type: string + registry: + description: Docker container registry + required: true + type: string jobs: - tag-push: - runs-on: ubuntu-latest + + release: + runs-on: ${{ inputs.runsOn }} timeout-minutes: 30 strategy: fail-fast: true matrix: - image: [aiida-core-base, aiida-core-with-services, aiida-core-dev] - defaults: - run: - shell: bash - working-directory: .docker - permissions: - packages: read + target: [aiida-core-base, aiida-core-with-services, aiida-core-dev] steps: - - name: Checkout Repo ⚡️ - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - name: Login to GitHub Container Registry 🔑 uses: docker/login-action@v3 @@ -43,6 +42,7 @@ jobs: - name: Login to DockerHub 🔑 uses: docker/login-action@v3 + if: inputs.registry == 'docker.io' with: registry: docker.io username: ${{ secrets.DOCKER_USERNAME }} @@ -52,33 +52,31 @@ jobs: id: build_vars run: | vars=$(cat build.json | jq -c '[.variable | to_entries[] | {"key": .key, "value": .value.default}] | from_entries') - echo "vars=$vars" - echo "vars=$vars" >> "${GITHUB_OUTPUT}" + echo "vars=$vars" | tee -a "${GITHUB_OUTPUT}" - - name: Docker meta 📝 + - name: Docker meta id: meta uses: docker/metadata-action@v5 - env: ${{ fromJson(steps.build_vars.outputs.vars) }} + env: ${{ fromJSON(steps.build_vars.outputs.vars) }} with: - images: | - name=docker.io/${{ env.OWNER }}/${{ matrix.image }} + # e.g. ghcr.io/aiidalab/full-stack + images: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ matrix.target }} tags: | + type=ref,event=pr type=edge,enable={{is_default_branch}} - type=match,pattern=v(\d+\.\d+.\d+),group=1 - type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} - type=raw,value=python-${{ env.PYTHON_VERSION }},enable=${{ startsWith(github.ref, 'refs/tags/v') }} - type=raw,value=postgresql-${{ env.PGSQL_VERSION }},enable=${{ startsWith(github.ref, 'refs/tags/v') }} + type=raw,value=aiida-${{ env.AIIDA_VERSION }},enable=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} + type=raw,value=python-${{ env.PYTHON_VERSION }},enable=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} + type=raw,value=postgresql-${{ env.PGSQL_VERSION }},enable=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} + type=match,pattern=v(\d{4}\.\d{4}(-.+)?),group=1 - - name: Determine src image tag + - name: Determine source image id: images run: | src=$(echo '${{ inputs.images }}'| jq -cr '.[("${{ matrix.target }}"|ascii_upcase|sub("-"; "_"; "g")) + "_IMAGE"]') - echo "src=$src" - echo "src=$src" >> "${GITHUB_OUTPUT}" + echo "src=$src" | tee -a "${GITHUB_OUTPUT}" - - name: Push image to docker.io + - name: Push image uses: akhilerm/tag-push-action@v2.2.0 - if: false # TODO: Enable this! with: src: ${{ steps.images.outputs.src }} dst: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index b06bd41ddd..2cc40f6580 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -11,15 +11,16 @@ on: description: Images built in build step required: true type: string + target: + description: Target image for testing + required: true + type: string jobs: test: runs-on: ${{ inputs.runsOn }} - timeout-minutes: 30 - strategy: - matrix: - target: [aiida-core-base, aiida-core-with-services, aiida-core-dev] + timeout-minutes: 20 defaults: run: shell: bash @@ -38,7 +39,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Set Up Python 🐍 - if: ${{ inputs.runsOn != 'ARM64' }} + if: ${{ startsWith(inputs.runsOn, 'ubuntu') }} uses: actions/setup-python@v5 with: python-version: '3.11' @@ -50,5 +51,6 @@ jobs: pip freeze - name: Run tests + # TODO: This probably needs tweaking run: pytest -s env: ${{ fromJSON(inputs.images) }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c5dbb92441..c0269e773c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,6 +3,8 @@ name: Build, test and push Docker Images on: pull_request: paths-ignore: + - '**.md' + - '**.txt' - docs/** - tests/** push: @@ -22,24 +24,56 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + FORCE_COLOR: 1 + jobs: build: uses: ./.github/workflows/docker-build.yml with: runsOn: ubuntu-22.04 + platforms: linux/amd64,linux/arm64 - test: + test-amd64: needs: build uses: ./.github/workflows/docker-test.yml strategy: matrix: - runsOn: [ARM64, ubuntu-22.04] + target: [aiida-core-base, aiida-core-with-services, aiida-core-dev] + with: + runsOn: ubuntu-22.04 + images: ${{ needs.build.outputs.images }} + + # IMPORTANT: To save arm64 runners resources, + # we run the test only when pushing to main. + # We also only test the aiida-core-dev image + test-arm64: + needs: build + if: >- + github.repository == 'aiidateam/aiida-core' + && (github.ref_type == 'tag' || github.ref_name == 'main') + uses: ./.github/workflows/docker-test.yml with: - runsOn: ${{ matrix.runsOn }} - images: ${{ needs.build.images }} + runsOn: buildjet-4vcpu-ubuntu-2204-arm + images: ${{ needs.build.outputs.images }} + target: aiida-core-dev - publish: - if: github.repository == 'aiidateam/aiida-core' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - needs: [build, test] + publish-ghcr: + needs: [build, test-amd64] uses: ./.github/workflows/docker-publish.yml secrets: inherit + with: + runsOn: ubuntu-22.04 + images: ${{ needs.build.outputs.images }} + registry: ghcr.io + + publish-dockerhub: + if: >- + github.repository == 'aiidateam/aiida-core' + && (github.ref_type == 'tag' || github.ref_name == 'main') + needs: [build, test-amd64, test-arm64, publish-ghcr] + uses: ./.github/workflows/docker-publish.yml + secrets: inherit + with: + images: ${{ needs.build.outputs.images }} + registry: docker.io diff --git a/.github/workflows/extract-docker-image-names.sh b/.github/workflows/extract-docker-image-names.sh index c40c602904..fd642555a1 100755 --- a/.github/workflows/extract-docker-image-names.sh +++ b/.github/workflows/extract-docker-image-names.sh @@ -2,47 +2,53 @@ set -euo pipefail -# Extract image names together with their digests -# to uniquely identify newly built images in subsequent steps. - -# TODO: Make these examples specific to aiida-core +# Extract image names together with their sha256 digests +# from the docker/bake-action metadata output. +# These together uniquely identify newly built images. # +# TODO: Make these examples specific to aiida-core + # The input to this script is a JSON string passed via BAKE_METADATA env variable # Here's example input (trimmed to relevant bits): -# BAKE_META: { +# BAKE_METADATA: { # "base": { -# "buildx.build.ref": "builder-9dc30f03-42f5-4fd5-8c9a-0d54be5ad996/builder-9dc30f03-42f5-4fd5-8c9a-0d54be5ad9960/jex1w6zvslbbomtkedn4no62l", -# "containerimage.config.digest": "sha256:b76dc61672dd0efbd586d56393d3a57f6309654e6903d738168892bc09017e8b", # "containerimage.descriptor": { # "mediaType": "application/vnd.docker.distribution.manifest.v2+json", # "digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", # "size": 6170, -# "platform": { -# "architecture": "amd64", -# "os": "linux" -# } # }, # "containerimage.digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", -# "image.name": "ghcr.io/aiidalab/base:pr-439,ghcr.io/aiidalab/base:sha-a0cd2be" +# "image.name": "ghcr.io/aiidalab/base" # }, # "base-with-services": { +# "image.name": "ghcr.io/aiidalab/base-with-services" # "containerimage.digest": "sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", # "...": "" # } # "full-stack": { -# "containerimage.digest": "sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", -# "...": "" +# "image.name": "ghcr.io/aiidalab/full-stack" +# "containerimage.digest": "sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", +# "...": "" +# } +# "lab": { +# "image.name": "ghcr.io/aiidalab/lab" +# "containerimage.digest": "sha256:4d9be090da287fcdf2d4658bb82f78bad791ccd15dac9af594fb8306abe47e97", +# "...": "" # } # } # # Example output (real output is on one line): # # images={ -# "BASE_IMAGE":"ghcr.io/aiidalab/base:pr-439@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", -# "BASE_WITH_SERVICES_IMAGE":"ghcr.io/aiidalab/base-with-services:pr-439@sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", -# "FULL_STACK_IMAGE":"ghcr.io/aiidalab/full-stack:pr-439@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", -# "LAB_IMAGE":"ghcr.io/aiidalab/lab:pr-439@sha256:4d9be090da287fcdf2d4658bb82f78bad791ccd15dac9af594fb8306abe47e97" +# "BASE_IMAGE": "ghcr.io/aiidalab/base@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", +# "BASE_WITH_SERVICES_IMAGE": "ghcr.io/aiidalab/base-with-services@sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", +# "FULL_STACK_IMAGE": "ghcr.io/aiidalab/full-stack@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", +# "LAB_IMAGE": "ghcr.io/aiidalab/lab@sha256:4d9be090da287fcdf2d4658bb82f78bad791ccd15dac9af594fb8306abe47e97" # } +# +# This json output is later turned to environment variables using fromJson() GHA builtin +# (e.g. BASE_IMAGE=ghcr.io/aiidalab/base@sha256:8e57a52b...) +# and these are in turn read in the docker-compose..yml files for tests. if [[ -z ${BAKE_METADATA-} ]];then echo "ERROR: Environment variable BAKE_METADATA is not set!" From 9c0c257120a51bd84b36626f3e0a16d1e72b4816 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 16 May 2024 08:58:29 +0100 Subject: [PATCH 08/43] Fix test-amd64 --- .github/workflows/docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c0269e773c..df4578c023 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,4 @@ -name: Build, test and push Docker Images +name: Docker Images on: pull_request: @@ -43,6 +43,7 @@ jobs: with: runsOn: ubuntu-22.04 images: ${{ needs.build.outputs.images }} + target: ${{ matrix.target }} # IMPORTANT: To save arm64 runners resources, # we run the test only when pushing to main. From e16c127bafdb8d5516c195b19abc44cc3687d1c6 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 16 May 2024 09:00:31 +0100 Subject: [PATCH 09/43] One more fix --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index df4578c023..ee7ce035e2 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -76,5 +76,6 @@ jobs: uses: ./.github/workflows/docker-publish.yml secrets: inherit with: + runsOn: ubuntu-22.04 images: ${{ needs.build.outputs.images }} registry: docker.io From f088c2941ca5b169cc9500b05dd155e06b418bbf Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 16 May 2024 09:03:09 +0100 Subject: [PATCH 10/43] Don't run ci-code on push --- .github/workflows/ci-code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-code.yml b/.github/workflows/ci-code.yml index 9ff7b8106b..a1a869e31f 100644 --- a/.github/workflows/ci-code.yml +++ b/.github/workflows/ci-code.yml @@ -2,7 +2,7 @@ name: continuous-integration-code on: push: - branches-ignore: [gh-pages] + branches: [main] pull_request: branches-ignore: [gh-pages] paths-ignore: [docs/**] From 9491a2e2df700d5f346aecf51c65008791c66354 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 16 May 2024 09:12:09 +0100 Subject: [PATCH 11/43] workdir --- .github/workflows/docker-build.yml | 8 ++++---- .github/workflows/docker-publish.yml | 6 +++++- .github/workflows/docker-test.yml | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 0784c696f3..fcc3da6e63 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -26,9 +26,8 @@ jobs: timeout-minutes: 60 defaults: run: - # Make sure we fail if any command in a piped command sequence fails + # Make sure we fail if any command in a piped command sequence fails shell: bash -e -o pipefail {0} - working-directory: .docker outputs: images: ${{ steps.bake_metadata.outputs.images }} @@ -57,8 +56,9 @@ jobs: uses: docker/bake-action@v4 with: push: true - # Using provenance to disable default attestation so it will build only desired images: - # https://github.com/orgs/community/discussions/45969 + workdir: .docker/ + # Using provenance to disable default attestation so it will build only desired images: + # https://github.com/orgs/community/discussions/45969 provenance: false set: | *.platform=${{ inputs.platforms }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 259df9b03e..ca383c6e57 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,6 +29,11 @@ jobs: fail-fast: true matrix: target: [aiida-core-base, aiida-core-with-services, aiida-core-dev] + defaults: + run: + # Make sure we fail if any command in a piped command sequence fails + shell: bash -e -o pipefail {0} + working-directory: .docker steps: - uses: actions/checkout@v4 @@ -59,7 +64,6 @@ jobs: uses: docker/metadata-action@v5 env: ${{ fromJSON(steps.build_vars.outputs.vars) }} with: - # e.g. ghcr.io/aiidalab/full-stack images: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ matrix.target }} tags: | type=ref,event=pr diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 2cc40f6580..cc854b636c 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -23,7 +23,8 @@ jobs: timeout-minutes: 20 defaults: run: - shell: bash + # Make sure we fail if any command in a piped command sequence fails + shell: bash -e -o pipefail {0} working-directory: .docker steps: @@ -51,6 +52,5 @@ jobs: pip freeze - name: Run tests - # TODO: This probably needs tweaking run: pytest -s env: ${{ fromJSON(inputs.images) }} From d4703788b12a146026059df0b80120ca781230e6 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 16 May 2024 09:24:01 +0100 Subject: [PATCH 12/43] Fix test-install? --- .github/workflows/test-install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml index c72c1f4ba6..4f66ea6d2a 100644 --- a/.github/workflows/test-install.yml +++ b/.github/workflows/test-install.yml @@ -216,7 +216,7 @@ jobs: run: sudo apt update && sudo apt install postgresql graphviz - name: Install aiida-core - uses: .github/actions/install-aiida-core + uses: ./.github/actions/install-aiida-core with: python-version: ${{ matrix.python-version }} extras: '[atomic_tools, docs, notebook, rest, tests, tui]' From 8a2941d0d6b7b7e2a82d2b4d78ee7345fde57ebb Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 16 May 2024 10:55:58 +0100 Subject: [PATCH 13/43] Build only amd64 --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ee7ce035e2..3f49093d40 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/docker-build.yml with: runsOn: ubuntu-22.04 - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 test-amd64: needs: build From 6c4fe7b3392b2fc5119d261231bfed4710f54dd2 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 16 May 2024 11:14:52 +0100 Subject: [PATCH 14/43] Docker: Pintesting environment --- .docker/requirements.in | 4 ++++ .docker/requirements.txt | 40 ++++++++++++++++++++++++++----- .github/workflows/docker-test.yml | 6 +---- 3 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 .docker/requirements.in diff --git a/.docker/requirements.in b/.docker/requirements.in new file mode 100644 index 0000000000..4b5c21b59d --- /dev/null +++ b/.docker/requirements.in @@ -0,0 +1,4 @@ +docker +pytest +requests +pytest-docker diff --git a/.docker/requirements.txt b/.docker/requirements.txt index 85be15c317..e867f8766e 100644 --- a/.docker/requirements.txt +++ b/.docker/requirements.txt @@ -1,6 +1,34 @@ -docker -pytest -requests -tabulate -pytest-docker -docker-compose +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.in +attrs==23.2.0 + # via pytest-docker +certifi==2024.2.2 + # via requests +charset-normalizer==3.3.2 + # via requests +docker==7.0.0 + # via -r requirements.in +idna==3.7 + # via requests +iniconfig==2.0.0 + # via pytest +packaging==24.0 + # via + # docker + # pytest +pluggy==1.5.0 + # via pytest +pytest==8.2.0 + # via + # -r requirements.in + # pytest-docker +pytest-docker==3.1.1 + # via -r requirements.in +requests==2.31.0 + # via + # -r requirements.in + # docker +urllib3==2.2.1 + # via + # docker + # requests diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index cc854b636c..5e124fa625 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -23,8 +23,6 @@ jobs: timeout-minutes: 20 defaults: run: - # Make sure we fail if any command in a piped command sequence fails - shell: bash -e -o pipefail {0} working-directory: .docker steps: @@ -47,9 +45,7 @@ jobs: cache: pip - name: Install dependencies 📦 - run: | - pip install -r requirements.txt - pip freeze + run: pip install -r requirements.txt --no-deps - name: Run tests run: pytest -s From 6d71fc0c9c389cf6ee4f412c81a06ce5e6e35380 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 20:12:11 +0100 Subject: [PATCH 15/43] Build amd64 first --- .github/workflows/docker.yml | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3f49093d40..98ed399e04 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -28,26 +28,42 @@ env: FORCE_COLOR: 1 jobs: - build: + # We build only amd64 first to catch failures faster. + build-amd64: uses: ./.github/workflows/docker-build.yml with: runsOn: ubuntu-22.04 platforms: linux/amd64 test-amd64: - needs: build + needs: build-amd64 uses: ./.github/workflows/docker-test.yml strategy: matrix: target: [aiida-core-base, aiida-core-with-services, aiida-core-dev] with: runsOn: ubuntu-22.04 - images: ${{ needs.build.outputs.images }} + images: ${{ needs.build-amd64.outputs.images }} target: ${{ matrix.target }} + build: + uses: ./.github/workflows/docker-build.yml + with: + runsOn: ubuntu-22.04 + platforms: linux/amd64,linux/arm64 + + publish-ghcr: + needs: [build, test-amd64] + uses: ./.github/workflows/docker-publish.yml + secrets: inherit + with: + runsOn: ubuntu-22.04 + images: ${{ needs.build.outputs.images }} + registry: ghcr.io + # IMPORTANT: To save arm64 runners resources, # we run the test only when pushing to main. - # We also only test the aiida-core-dev image + # We also only test the aiida-core-dev image. test-arm64: needs: build if: >- @@ -59,15 +75,6 @@ jobs: images: ${{ needs.build.outputs.images }} target: aiida-core-dev - publish-ghcr: - needs: [build, test-amd64] - uses: ./.github/workflows/docker-publish.yml - secrets: inherit - with: - runsOn: ubuntu-22.04 - images: ${{ needs.build.outputs.images }} - registry: ghcr.io - publish-dockerhub: if: >- github.repository == 'aiidateam/aiida-core' From ff0c49f4c4dbecbd3dd00aa20ecc714f96540410 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 20:18:19 +0100 Subject: [PATCH 16/43] Add target option to pytest --- .docker/tests/conftest.py | 32 +++++++++++++++++++++---------- .github/workflows/docker-test.yml | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.docker/tests/conftest.py b/.docker/tests/conftest.py index 9eb79ddede..2b6915b559 100644 --- a/.docker/tests/conftest.py +++ b/.docker/tests/conftest.py @@ -3,17 +3,29 @@ import pytest +TARGETS = ('aiida-core-base', 'aiida-core-base-with-services', 'aiida-core-dev') -@pytest.fixture( - scope='session', - params=[ - 'aiida-core-base', - 'aiida-core-with-services', - 'aiida-core-dev', - ], -) -def variant(request): - return request.param + +def target_checker(value): + msg = f"Invalid image target '{value}', must be one of: {TARGETS}" + if value not in TARGETS: + raise pytest.UsageError(msg) + return value + + +def pytest_addoption(parser): + parser.addoption( + '--target', + action='store', + required=True, + help='target (image name) of the docker-compose file to use.', + type=target_checker, + ) + + +@pytest.fixture(scope='session') +def variant(pytestconfig): + return pytestconfig.getoption('target') @pytest.fixture(scope='session') diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 5e124fa625..d6f2085a5c 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -48,5 +48,5 @@ jobs: run: pip install -r requirements.txt --no-deps - name: Run tests - run: pytest -s + run: pytest -s --target ${{ inputs.target }} env: ${{ fromJSON(inputs.images) }} From a9e6290d0e914409c45f27e52f4aaf1a0a650c12 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 21:21:55 +0100 Subject: [PATCH 17/43] wtf --- .docker/pytest.ini | 2 +- .docker/tests/conftest.py | 6 +++--- .github/workflows/docker-test.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.docker/pytest.ini b/.docker/pytest.ini index d1e7877377..e6c356c3eb 100644 --- a/.docker/pytest.ini +++ b/.docker/pytest.ini @@ -1,5 +1,5 @@ [pytest] minversion = 7.0 -addopts = -ra -q +addopts = -ra -q --strict-markers testpaths = tests diff --git a/.docker/tests/conftest.py b/.docker/tests/conftest.py index 2b6915b559..72d6bab9e1 100644 --- a/.docker/tests/conftest.py +++ b/.docker/tests/conftest.py @@ -15,7 +15,7 @@ def target_checker(value): def pytest_addoption(parser): parser.addoption( - '--target', + '--variant', action='store', required=True, help='target (image name) of the docker-compose file to use.', @@ -25,11 +25,11 @@ def pytest_addoption(parser): @pytest.fixture(scope='session') def variant(pytestconfig): - return pytestconfig.getoption('target') + return pytestconfig.getoption('variant') @pytest.fixture(scope='session') -def docker_compose_file(pytestconfig, variant): +def docker_compose_file(variant): return f'docker-compose.{variant}.yml' diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index d6f2085a5c..ee294974a2 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -48,5 +48,5 @@ jobs: run: pip install -r requirements.txt --no-deps - name: Run tests - run: pytest -s --target ${{ inputs.target }} + run: pytest -s --target ${{ inputs.target }} tests/ env: ${{ fromJSON(inputs.images) }} From d8b979c0eb1d67225877e5f1bede2a1aae3bcf1b Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 23:02:19 +0100 Subject: [PATCH 18/43] Fix --- .github/workflows/docker-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index ee294974a2..67b9875435 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -48,5 +48,5 @@ jobs: run: pip install -r requirements.txt --no-deps - name: Run tests - run: pytest -s --target ${{ inputs.target }} tests/ + run: pytest -s --variant ${{ inputs.target }} tests/ env: ${{ fromJSON(inputs.images) }} From 9f9b694848f2033e76c6d5163cf86255d3085f03 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 23:08:37 +0100 Subject: [PATCH 19/43] Full build needs test-amd64 --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 98ed399e04..3f80a6aaf3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -47,6 +47,7 @@ jobs: target: ${{ matrix.target }} build: + needs: test-amd64 uses: ./.github/workflows/docker-build.yml with: runsOn: ubuntu-22.04 From 4c906c0111a54b41c92613e7ff3b0a42ccf2c11d Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 23:09:24 +0100 Subject: [PATCH 20/43] Fix --- .docker/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/tests/conftest.py b/.docker/tests/conftest.py index 72d6bab9e1..968e941b29 100644 --- a/.docker/tests/conftest.py +++ b/.docker/tests/conftest.py @@ -3,7 +3,7 @@ import pytest -TARGETS = ('aiida-core-base', 'aiida-core-base-with-services', 'aiida-core-dev') +TARGETS = ('aiida-core-base', 'aiida-core-with-services', 'aiida-core-dev') def target_checker(value): From d9443f568175e7d1e0a48d3bea4853cd56fa7827 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 23:12:03 +0100 Subject: [PATCH 21/43] Fix docker-compose files --- .docker/docker-compose.aiida-core-base.yml | 2 +- .docker/docker-compose.aiida-core-dev.yml | 2 +- .docker/docker-compose.aiida-core-with-services.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.docker/docker-compose.aiida-core-base.yml b/.docker/docker-compose.aiida-core-base.yml index 4524938065..478d752db4 100644 --- a/.docker/docker-compose.aiida-core-base.yml +++ b/.docker/docker-compose.aiida-core-base.yml @@ -29,7 +29,7 @@ services: retries: 10 aiida: - image: ${REGISTRY:-}${BASE_IMAGE:-aiidateam/aiida-core-base}:${TAG:-latest} + image: ${REGISTRY:-}${AIIDA_CORE_BASE_IMAGE:-aiidateam/aiida-core-base}${TAG:-} environment: RMQHOST: messaging TZ: Europe/Zurich diff --git a/.docker/docker-compose.aiida-core-dev.yml b/.docker/docker-compose.aiida-core-dev.yml index c07fb3a5cf..b59f6484a5 100644 --- a/.docker/docker-compose.aiida-core-dev.yml +++ b/.docker/docker-compose.aiida-core-dev.yml @@ -3,7 +3,7 @@ version: '3.4' services: aiida: - image: ${REGISTRY:-}${BASE_IMAGE:-aiidateam/aiida-core-dev}:${TAG:-latest} + image: ${REGISTRY:-}${AIIDA_CORE_DEV_IMAGE:-aiidateam/aiida-core-dev}${TAG:-} environment: TZ: Europe/Zurich SETUP_DEFAULT_AIIDA_PROFILE: 'true' diff --git a/.docker/docker-compose.aiida-core-with-services.yml b/.docker/docker-compose.aiida-core-with-services.yml index 445259b428..73cf83e7e3 100644 --- a/.docker/docker-compose.aiida-core-with-services.yml +++ b/.docker/docker-compose.aiida-core-with-services.yml @@ -3,7 +3,7 @@ version: '3.4' services: aiida: - image: ${REGISTRY:-}${BASE_IMAGE:-aiidateam/aiida-core-with-services}:${TAG:-latest} + image: ${REGISTRY:-}${AIIDA_CORE_WITH_SERVICES_IMAGE:-aiidateam/aiida-core-with-services}${TAG:-} environment: TZ: Europe/Zurich SETUP_DEFAULT_AIIDA_PROFILE: 'true' From 2fe8562359b61c9fdc66ad182a3217872b5538f8 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 01:26:55 +0100 Subject: [PATCH 22/43] update uv --- .github/actions/install-aiida-core/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install-aiida-core/action.yml b/.github/actions/install-aiida-core/action.yml index aacbe774a4..700e565034 100644 --- a/.github/actions/install-aiida-core/action.yml +++ b/.github/actions/install-aiida-core/action.yml @@ -28,7 +28,7 @@ runs: - name: Install uv installer run: curl --proto '=https' --tlsv1.2 -LsSf https://${{ env.UV_URL }} | sh env: - UV_VERSION: 0.1.35 + UV_VERSION: 0.1.44 UV_URL: github.com/astral-sh/uv/releases/download/$UV_VERSION/uv-installer.sh shell: bash From eb69696e4d76ddf1e001cb2bc8c6de9a28abffd0 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 02:20:43 +0100 Subject: [PATCH 23/43] Fix test-install.yml test --- .github/workflows/test-install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml index 4f66ea6d2a..a3bf124cd1 100644 --- a/.github/workflows/test-install.yml +++ b/.github/workflows/test-install.yml @@ -219,7 +219,7 @@ jobs: uses: ./.github/actions/install-aiida-core with: python-version: ${{ matrix.python-version }} - extras: '[atomic_tools, docs, notebook, rest, tests, tui]' + extras: '[atomic_tools,docs,notebook,rest,tests,tui]' from-requirements: 'false' - name: Setup AiiDA environment From a06b5492345a2594e458168e750b71ac6afdea1f Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 02:23:11 +0100 Subject: [PATCH 24/43] Decrease timeout --- .docker/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/tests/conftest.py b/.docker/tests/conftest.py index 968e941b29..51be602d5b 100644 --- a/.docker/tests/conftest.py +++ b/.docker/tests/conftest.py @@ -54,7 +54,7 @@ def is_container_ready(): return '✔ broker:' in output and 'Daemon is running' in output docker_services.wait_until_responsive( - timeout=600.0, + timeout=300.0, pause=2, check=lambda: is_container_ready(), ) From b7f81361630bfce47b079c08ae8aca2df54364ba Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 02:49:38 +0100 Subject: [PATCH 25/43] Fix comments in Dockerfile --- .docker/aiida-core-base/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.docker/aiida-core-base/Dockerfile b/.docker/aiida-core-base/Dockerfile index 47f517d2fe..7de1ddb5bd 100644 --- a/.docker/aiida-core-base/Dockerfile +++ b/.docker/aiida-core-base/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # Inspired by jupyter's docker-stacks-fundation image: -# https://github.com/jupyter/docker-stacks/blob/main/docker-stacks-foundation/Dockerfile +# https://github.com/jupyter/docker-stacks/tree/main/images/docker-stacks-foundation/Dockerfile ARG BASE=ubuntu:22.04 @@ -87,7 +87,7 @@ RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashr # Add call to conda init script see https://stackoverflow.com/a/58081608/4413446 echo 'eval "$(command conda shell.bash hook 2> /dev/null)"' >> /etc/skel/.bashrc -# Create SYSTEM_USER with name jovyan user with UID=1000 and in the 'users' group +# Create $SYSTEM_USER user with UID=1000 and 'users' group # and make sure these dirs are writable by the `users` group. RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \ sed -i.bak -e 's/^%admin/#%admin/' /etc/sudoers && \ @@ -112,7 +112,7 @@ ARG MAMBA_VERSION # Similar projects using Micromamba: # - Micromamba-Docker: # - repo2docker: -# Install Python, Mamba and jupyter_core +# Install Python, Mamba # Cleanup temporary files and remove Micromamba # Correct permissions # Do all this in a single RUN command to avoid duplicating all of the From fad7c282cddb74b1982ee7a76134d73d6b828e73 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 02:50:47 +0100 Subject: [PATCH 26/43] Temporarily enable arm64 testing --- .github/workflows/docker.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3f80a6aaf3..cd40327fbb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -67,9 +67,6 @@ jobs: # We also only test the aiida-core-dev image. test-arm64: needs: build - if: >- - github.repository == 'aiidateam/aiida-core' - && (github.ref_type == 'tag' || github.ref_name == 'main') uses: ./.github/workflows/docker-test.yml with: runsOn: buildjet-4vcpu-ubuntu-2204-arm From 115b2f44363f428209f12f2c7b55743487066e48 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 03:00:09 +0100 Subject: [PATCH 27/43] Update comments --- .../workflows/extract-docker-image-names.sh | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/extract-docker-image-names.sh b/.github/workflows/extract-docker-image-names.sh index fd642555a1..ca72b54040 100755 --- a/.github/workflows/extract-docker-image-names.sh +++ b/.github/workflows/extract-docker-image-names.sh @@ -6,8 +6,6 @@ set -euo pipefail # from the docker/bake-action metadata output. # These together uniquely identify newly built images. # -# TODO: Make these examples specific to aiida-core - # The input to this script is a JSON string passed via BAKE_METADATA env variable # Here's example input (trimmed to relevant bits): # BAKE_METADATA: { @@ -20,18 +18,18 @@ set -euo pipefail # "containerimage.digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", # "image.name": "ghcr.io/aiidalab/base" # }, -# "base-with-services": { -# "image.name": "ghcr.io/aiidalab/base-with-services" +# "aiida-core-base": { +# "image.name": "ghcr.io/aiidateam/aiida-core-base" # "containerimage.digest": "sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", # "...": "" # } -# "full-stack": { -# "image.name": "ghcr.io/aiidalab/full-stack" +# "aiida-core-with-services": { +# "image.name": "ghcr.io/aiidateam/aiida-core-with-services" # "containerimage.digest": "sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", # "...": "" # } -# "lab": { -# "image.name": "ghcr.io/aiidalab/lab" +# "aiida-core-dev": { +# "image.name": "ghcr.io/aiidateam/aiida-core-with-services" # "containerimage.digest": "sha256:4d9be090da287fcdf2d4658bb82f78bad791ccd15dac9af594fb8306abe47e97", # "...": "" # } @@ -40,14 +38,13 @@ set -euo pipefail # Example output (real output is on one line): # # images={ -# "BASE_IMAGE": "ghcr.io/aiidalab/base@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", -# "BASE_WITH_SERVICES_IMAGE": "ghcr.io/aiidalab/base-with-services@sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", -# "FULL_STACK_IMAGE": "ghcr.io/aiidalab/full-stack@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", -# "LAB_IMAGE": "ghcr.io/aiidalab/lab@sha256:4d9be090da287fcdf2d4658bb82f78bad791ccd15dac9af594fb8306abe47e97" +# "AIIDA_CORE_BASE_IMAGE": "ghcr.io/aiidalab/base@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", +# "AIIDA_CORE_WITH_SERVICES_IMAGE": "ghcr.io/aiidalab/base-with-services@sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", +# "AIIDA_CORE_DEV_IMAGE": "ghcr.io/aiidalab/full-stack@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", # } # # This json output is later turned to environment variables using fromJson() GHA builtin -# (e.g. BASE_IMAGE=ghcr.io/aiidalab/base@sha256:8e57a52b...) +# (e.g. AIIDA_CORE_BASE_IMAGE=ghcr.io/aiidateam/aiida-core-base@sha256:8e57a52b...) # and these are in turn read in the docker-compose..yml files for tests. if [[ -z ${BAKE_METADATA-} ]];then From 13f69c2e794e02120fc1ea06ea97eb739418be03 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 03:18:38 +0100 Subject: [PATCH 28/43] Downgrade pytest --- .docker/requirements.in | 2 +- .docker/requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.docker/requirements.in b/.docker/requirements.in index 4b5c21b59d..cde218af15 100644 --- a/.docker/requirements.in +++ b/.docker/requirements.in @@ -1,4 +1,4 @@ docker -pytest +pytest~=7.4 requests pytest-docker diff --git a/.docker/requirements.txt b/.docker/requirements.txt index e867f8766e..ead7600f27 100644 --- a/.docker/requirements.txt +++ b/.docker/requirements.txt @@ -18,13 +18,13 @@ packaging==24.0 # pytest pluggy==1.5.0 # via pytest -pytest==8.2.0 +pytest==7.4.4 # via # -r requirements.in # pytest-docker pytest-docker==3.1.1 # via -r requirements.in -requests==2.31.0 +requests==2.32.2 # via # -r requirements.in # docker From cc4bd580783a73216a40d933bfc06a083e485949 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 05:25:03 +0100 Subject: [PATCH 29/43] Fix ARM tests --- .docker/requirements.in | 4 ---- .docker/requirements.txt | 38 ++++--------------------------- .github/workflows/docker-test.yml | 2 +- 3 files changed, 5 insertions(+), 39 deletions(-) delete mode 100644 .docker/requirements.in diff --git a/.docker/requirements.in b/.docker/requirements.in deleted file mode 100644 index cde218af15..0000000000 --- a/.docker/requirements.in +++ /dev/null @@ -1,4 +0,0 @@ -docker -pytest~=7.4 -requests -pytest-docker diff --git a/.docker/requirements.txt b/.docker/requirements.txt index ead7600f27..6c84d9fa30 100644 --- a/.docker/requirements.txt +++ b/.docker/requirements.txt @@ -1,34 +1,4 @@ -# This file was autogenerated by uv via the following command: -# uv pip compile requirements.in -attrs==23.2.0 - # via pytest-docker -certifi==2024.2.2 - # via requests -charset-normalizer==3.3.2 - # via requests -docker==7.0.0 - # via -r requirements.in -idna==3.7 - # via requests -iniconfig==2.0.0 - # via pytest -packaging==24.0 - # via - # docker - # pytest -pluggy==1.5.0 - # via pytest -pytest==7.4.4 - # via - # -r requirements.in - # pytest-docker -pytest-docker==3.1.1 - # via -r requirements.in -requests==2.32.2 - # via - # -r requirements.in - # docker -urllib3==2.2.1 - # via - # docker - # requests +docker~=7.0.0 +pytest~=8.2.0 +requests~=2.32.0 +pytest-docker~=3.1.0 diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 67b9875435..652c459102 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -45,7 +45,7 @@ jobs: cache: pip - name: Install dependencies 📦 - run: pip install -r requirements.txt --no-deps + run: pip install -r requirements.txt - name: Run tests run: pytest -s --variant ${{ inputs.target }} tests/ From c4204527a273085f8adec707a1b6205cd7cb191b Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 06:25:18 +0100 Subject: [PATCH 30/43] Revert "Temporarily enable arm64 testing" This reverts commit fad7c282cddb74b1982ee7a76134d73d6b828e73. --- .github/workflows/docker.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cd40327fbb..3f80a6aaf3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -67,6 +67,9 @@ jobs: # We also only test the aiida-core-dev image. test-arm64: needs: build + if: >- + github.repository == 'aiidateam/aiida-core' + && (github.ref_type == 'tag' || github.ref_name == 'main') uses: ./.github/workflows/docker-test.yml with: runsOn: buildjet-4vcpu-ubuntu-2204-arm From 608aff88802edd35c4a48abd415a558f2a0059f5 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 06:25:50 +0100 Subject: [PATCH 31/43] Increase timeout again --- .docker/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/tests/conftest.py b/.docker/tests/conftest.py index 51be602d5b..968e941b29 100644 --- a/.docker/tests/conftest.py +++ b/.docker/tests/conftest.py @@ -54,7 +54,7 @@ def is_container_ready(): return '✔ broker:' in output and 'Daemon is running' in output docker_services.wait_until_responsive( - timeout=300.0, + timeout=600.0, pause=2, check=lambda: is_container_ready(), ) From ab2ebd1967c0739f9ab8a8c54be137451c584a28 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 06:26:36 +0100 Subject: [PATCH 32/43] Revert "Fix test-install.yml test" This reverts commit eb69696e4d76ddf1e001cb2bc8c6de9a28abffd0. --- .github/workflows/test-install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml index a3bf124cd1..4f66ea6d2a 100644 --- a/.github/workflows/test-install.yml +++ b/.github/workflows/test-install.yml @@ -219,7 +219,7 @@ jobs: uses: ./.github/actions/install-aiida-core with: python-version: ${{ matrix.python-version }} - extras: '[atomic_tools,docs,notebook,rest,tests,tui]' + extras: '[atomic_tools, docs, notebook, rest, tests, tui]' from-requirements: 'false' - name: Setup AiiDA environment From f5d125ec50871cb3f2662ec75230371063cbb4d0 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 06:27:32 +0100 Subject: [PATCH 33/43] revert test-install fix --- .github/workflows/test-install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml index 4f66ea6d2a..c72c1f4ba6 100644 --- a/.github/workflows/test-install.yml +++ b/.github/workflows/test-install.yml @@ -216,7 +216,7 @@ jobs: run: sudo apt update && sudo apt install postgresql graphviz - name: Install aiida-core - uses: ./.github/actions/install-aiida-core + uses: .github/actions/install-aiida-core with: python-version: ${{ matrix.python-version }} extras: '[atomic_tools, docs, notebook, rest, tests, tui]' From 0130717dde872518b0fc44737a5ded52dac338bf Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 22 May 2024 06:29:59 +0100 Subject: [PATCH 34/43] Don't run on forks for now --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3f80a6aaf3..72fc71be67 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,6 +30,7 @@ env: jobs: # We build only amd64 first to catch failures faster. build-amd64: + if: github.repository == 'aiidateam/aiida-core' uses: ./.github/workflows/docker-build.yml with: runsOn: ubuntu-22.04 From 57f209d5a1f8928ec5d801dd81ab8f4c6096b50c Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Fri, 24 May 2024 17:29:52 +0100 Subject: [PATCH 35/43] Update .github/workflows/extract-docker-image-names.sh Co-authored-by: Jusong Yu --- .github/workflows/extract-docker-image-names.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/extract-docker-image-names.sh b/.github/workflows/extract-docker-image-names.sh index ca72b54040..8609f7c385 100755 --- a/.github/workflows/extract-docker-image-names.sh +++ b/.github/workflows/extract-docker-image-names.sh @@ -38,9 +38,9 @@ set -euo pipefail # Example output (real output is on one line): # # images={ -# "AIIDA_CORE_BASE_IMAGE": "ghcr.io/aiidalab/base@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", -# "AIIDA_CORE_WITH_SERVICES_IMAGE": "ghcr.io/aiidalab/base-with-services@sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", -# "AIIDA_CORE_DEV_IMAGE": "ghcr.io/aiidalab/full-stack@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", +# "AIIDA_CORE_BASE_IMAGE": "ghcr.io/aiidateam/aiida-core-base@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", +# "AIIDA_CORE_WITH_SERVICES_IMAGE": "ghcr.io/aiidateam/aiida-core-with-services@sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26", +# "AIIDA_CORE_DEV_IMAGE": "ghcr.io/aiidateam/aiida-core-dev@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", # } # # This json output is later turned to environment variables using fromJson() GHA builtin From 5d0c01224fddf5c707ad49b3235b1cf556e9ed0e Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 25 May 2024 11:17:39 +0100 Subject: [PATCH 36/43] warp --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 72fc71be67..af57d800d1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -73,7 +73,7 @@ jobs: && (github.ref_type == 'tag' || github.ref_name == 'main') uses: ./.github/workflows/docker-test.yml with: - runsOn: buildjet-4vcpu-ubuntu-2204-arm + runsOn: warp-ubuntu-latest-arm64-2x images: ${{ needs.build.outputs.images }} target: aiida-core-dev From 49a0b097bbf2c5380fc41d8162ecb3d6fc4f92c2 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 25 May 2024 15:44:31 +0100 Subject: [PATCH 37/43] Skip Docker build for PRs from forks --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index af57d800d1..eea352c22a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,7 +30,7 @@ env: jobs: # We build only amd64 first to catch failures faster. build-amd64: - if: github.repository == 'aiidateam/aiida-core' + if: github.event.pull_request.head.repo.fork uses: ./.github/workflows/docker-build.yml with: runsOn: ubuntu-22.04 From ec12d505606cec4cbbd0152db4b1988e361b7cd4 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 25 May 2024 15:44:52 +0100 Subject: [PATCH 38/43] Skip Docker build for PRs from forks --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index eea352c22a..e4dca233ce 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,7 +30,7 @@ env: jobs: # We build only amd64 first to catch failures faster. build-amd64: - if: github.event.pull_request.head.repo.fork + if: ${{ ! github.event.pull_request.head.repo.fork }} uses: ./.github/workflows/docker-build.yml with: runsOn: ubuntu-22.04 From ed3621a97d5454c58f2de28aa6a5495e2ddd25a9 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 25 May 2024 15:47:05 +0100 Subject: [PATCH 39/43] Test arm on branch --- .github/workflows/docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e4dca233ce..be51972353 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -68,9 +68,9 @@ jobs: # We also only test the aiida-core-dev image. test-arm64: needs: build - if: >- - github.repository == 'aiidateam/aiida-core' - && (github.ref_type == 'tag' || github.ref_name == 'main') + #if: >- + # github.repository == 'aiidateam/aiida-core' + # && (github.ref_type == 'tag' || github.ref_name == 'main') uses: ./.github/workflows/docker-test.yml with: runsOn: warp-ubuntu-latest-arm64-2x From cb6f1fed2197c555e4a8bd21ac136aff9e8a3e1c Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 25 May 2024 23:45:52 +0100 Subject: [PATCH 40/43] Revert "Test arm on branch" This reverts commit ed3621a97d5454c58f2de28aa6a5495e2ddd25a9. --- .github/workflows/docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index be51972353..e4dca233ce 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -68,9 +68,9 @@ jobs: # We also only test the aiida-core-dev image. test-arm64: needs: build - #if: >- - # github.repository == 'aiidateam/aiida-core' - # && (github.ref_type == 'tag' || github.ref_name == 'main') + if: >- + github.repository == 'aiidateam/aiida-core' + && (github.ref_type == 'tag' || github.ref_name == 'main') uses: ./.github/workflows/docker-test.yml with: runsOn: warp-ubuntu-latest-arm64-2x From b53ff48d0f483a1c67cdf1526fe7e3c93ec5d3a8 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 25 May 2024 23:46:12 +0100 Subject: [PATCH 41/43] Revert "warp" This reverts commit 5d0c01224fddf5c707ad49b3235b1cf556e9ed0e. --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e4dca233ce..956c78c952 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -73,7 +73,7 @@ jobs: && (github.ref_type == 'tag' || github.ref_name == 'main') uses: ./.github/workflows/docker-test.yml with: - runsOn: warp-ubuntu-latest-arm64-2x + runsOn: buildjet-4vcpu-ubuntu-2204-arm images: ${{ needs.build.outputs.images }} target: aiida-core-dev From f0a9a94b826113c0d2a21404f24896c975f2944b Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 27 May 2024 12:47:19 +0100 Subject: [PATCH 42/43] revert ci-code change --- .github/workflows/ci-code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-code.yml b/.github/workflows/ci-code.yml index cc767521e5..bec312c60f 100644 --- a/.github/workflows/ci-code.yml +++ b/.github/workflows/ci-code.yml @@ -2,7 +2,7 @@ name: continuous-integration-code on: push: - branches: [main] + branches-ignore: [gh-pages] pull_request: branches-ignore: [gh-pages] paths-ignore: [docs/**] From bd9cc398df800777a717c99de26c46e857779a6b Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 27 May 2024 12:47:49 +0100 Subject: [PATCH 43/43] Consistent path-ignore in docker.yml --- .github/workflows/docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 956c78c952..5bb0a6147a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,6 +14,8 @@ on: tags: - v* paths-ignore: + - '**.md' + - '**.txt' - docs/** - tests/** workflow_dispatch: