From b3e1811f7797b9ba51c5dfb3ef5ac2921e7ac232 Mon Sep 17 00:00:00 2001 From: Paul Zehner Date: Fri, 2 Feb 2024 10:28:03 +0100 Subject: [PATCH] Build base image in a different workflow --- .github/workflows/__build_base.yaml | 73 +++++++++++++++++++++++++++++ .github/workflows/base_images.yaml | 50 -------------------- .github/workflows/build_test.yaml | 58 ++--------------------- 3 files changed, 76 insertions(+), 105 deletions(-) create mode 100644 .github/workflows/__build_base.yaml delete mode 100644 .github/workflows/base_images.yaml diff --git a/.github/workflows/__build_base.yaml b/.github/workflows/__build_base.yaml new file mode 100644 index 00000000..c369af0b --- /dev/null +++ b/.github/workflows/__build_base.yaml @@ -0,0 +1,73 @@ +name: Build base images + +on: + workflow_call: + inputs: + # suffix of the Docker and Singularity images + image_name_suffix: + required: false + default: main + type: string + +env: + # Force the use of BuildKit for Docker + DOCKER_BUILDKIT: 1 + +jobs: + build_base: + runs-on: ubuntu-latest + + strategy: + matrix: + backend: + - name: openmp + use_singularity: false + - name: cuda + use_singularity: true + - name: hip + use_singularity: false + - name: sycl + use_singularity: false + + steps: + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@v1.2.0 + with: + tool-cache: true + large-packages: false + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Get Singularity + env: + SINGULARITY_VERSION: 3.11.2 + run: | + wget https://github.com/sylabs/singularity/releases/download/v${{ env.SINGULARITY_VERSION }}/singularity-ce_${{ env.SINGULARITY_VERSION }}-jammy_amd64.deb + sudo apt-get install ./singularity-ce_${{ env.SINGULARITY_VERSION }}-jammy_amd64.deb + + - name: Login in GitHub Containers Repository with Docker + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Login in GitHub Containers Repository with Singularity + run: echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io + + - name: Build Docker image + run: | + docker build \ + -t ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ inputs.image_name_suffix }} \ + --cache-from ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_main \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --progress=plain \ + docker/${{ matrix.backend.name }} + + - name: Push Docker image + run: docker push ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ inputs.image_name_suffix }} + + - name: Convert Docker image to Singularity + run: singularity build base.sif docker://ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ inputs.image_name_suffix }} + if: ${{ matrix.backend.use_singularity }} + + - name: Push Singularity image + run: singularity push base.sif oras://ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_singularity_${{ inputs.image_name_suffix }} + if: ${{ matrix.backend.use_singularity }} diff --git a/.github/workflows/base_images.yaml b/.github/workflows/base_images.yaml deleted file mode 100644 index 19b57de2..00000000 --- a/.github/workflows/base_images.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build base images - -on: - workflow_call: - # push: - # branches: - # - main - # pull_request: - # branches: - # - main - # schedule: - # # TODO enable scheduler - # cron: "0 1 2,16 * *" # every 2nd and 16th of the month at 1am UTC - -jobs: - build_base: - runs-on: ubuntu-latest - - strategy: - matrix: - backend: - # - openmp - - cuda - # - hip - - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@v1.2.0 - with: - tool-cache: true - large-packages: false - - - name: Checkout repository - uses: actions/checkout@v3 - - # TODO check if current build has a different Dockerfile - - - name: Build image - # TODO improve with caching https://docs.docker.com/engine/reference/commandline/image_build/#cache-from - run: docker build \ - -t ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend }} \ - --cache-from ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend }} \ - --build-arg BUIDKIT_INLINE_CACHE=1 \ - docker/${{ matrix.backend }} - - - name: Login in GitHub Containers Repository - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Push image - run: docker push ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend }} diff --git a/.github/workflows/build_test.yaml b/.github/workflows/build_test.yaml index 8b5169f5..9c11a988 100644 --- a/.github/workflows/build_test.yaml +++ b/.github/workflows/build_test.yaml @@ -55,66 +55,14 @@ jobs: done build_base: - runs-on: ubuntu-latest - needs: check_docker_files if: ${{ needs.check_docker_files.outputs.docker_files_have_changed == 'true' }} - strategy: - matrix: - backend: - - name: openmp - use_singularity: false - - name: cuda - use_singularity: true - - name: hip - use_singularity: false - - name: sycl - use_singularity: false - - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@v1.2.0 - with: - tool-cache: true - large-packages: false - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Get Singularity - env: - SINGULARITY_VERSION: 3.11.2 - run: | - wget https://github.com/sylabs/singularity/releases/download/v${{ env.SINGULARITY_VERSION }}/singularity-ce_${{ env.SINGULARITY_VERSION }}-jammy_amd64.deb - sudo apt-get install ./singularity-ce_${{ env.SINGULARITY_VERSION }}-jammy_amd64.deb - - - name: Login in GitHub Containers Repository with Docker - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Login in GitHub Containers Repository with Singularity - run: echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io + uses: ./github/workflows/__build_base.yaml - - name: Build Docker image - run: | - docker build \ - -t ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ needs.check_docker_files.outputs.image_name_suffix }} \ - --cache-from ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_main \ - --build-arg BUILDKIT_INLINE_CACHE=1 \ - --progress=plain \ - docker/${{ matrix.backend.name }} - - - name: Push Docker image - run: docker push ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ needs.check_docker_files.outputs.image_name_suffix }} - - - name: Convert Docker image to Singularity - run: singularity build base.sif docker://ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ needs.check_docker_files.outputs.image_name_suffix }} - if: ${{ matrix.backend.use_singularity }} - - - name: Push Singularity image - run: singularity push base.sif oras://ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_singularity_${{ needs.check_docker_files.outputs.image_name_suffix }} - if: ${{ matrix.backend.use_singularity }} + with: + image_name_suffix: ${{ needs.check_docker_files.outputs.image_name_suffix }} build: runs-on: ubuntu-latest