diff --git a/.github/workflows/pr-check-build-che-code-image.yaml b/.github/workflows/pr-check-build-che-code-image.yaml new file mode 100644 index 00000000000..7ebb8470bf2 --- /dev/null +++ b/.github/workflows/pr-check-build-che-code-image.yaml @@ -0,0 +1,155 @@ +# +# Copyright (c) 2023 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + +name: Pull Request Check + +# Trigger the workflow on pull request +on: [pull_request] + +jobs: + build: + name: build + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + dist: [ 'musl', 'libc' ] + arch: ['amd64'] + steps: + + - name: Checkout che-code source code + uses: actions/checkout@v3 + + - name: Compile che-code + run: | + docker buildx build \ + --platform linux/${{matrix.arch}} \ + --progress=plain \ + -f build/dockerfiles/linux-${{matrix.dist}}.Dockerfile \ + -t linux-${{matrix.dist}}-${{matrix.arch}} . + + - name: Upload image + uses: ishworkh/docker-image-artifact-upload@v1 + with: + image: "linux-${{matrix.dist}}-${{matrix.arch}}" + + assemble: + name: assemble + runs-on: ubuntu-22.04 + needs: build + steps: + + - name: Checkout che-code source code + uses: actions/checkout@v3 + + - name: Cleanup docker images + run: | + docker system prune -af + + - name: Download linux-libc-amd64 image + uses: ishworkh/docker-image-artifact-download@v1 + with: + image: "linux-libc-amd64" + + - name: Download linux-musl-amd64 image + uses: ishworkh/docker-image-artifact-download@v1 + with: + image: "linux-musl-amd64" + + - name: Login to Quay.io + uses: docker/login-action@v2 + with: + registry: quay.io + username: ${{ secrets.QUAY_PULL_REQUESTS_USERNAME }} + password: ${{ secrets.QUAY_PULL_REQUESTS_PASSWORD }} + + - name: Display docker images + run: | + docker images + + - name: Assemble che-code + run: | + PR_NUMBER="${{ github.event.number }}" + echo "Pull request $PR_NUMBER" + + IMAGE_NAME="quay.io/che-incubator-pull-requests/che-code:pr-$PR_NUMBER-amd64" + echo "_IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV + + docker buildx build \ + --platform linux/amd64 \ + --progress=plain \ + --push \ + -f build/dockerfiles/assembly.Dockerfile \ + -t ${IMAGE_NAME} . + + - name: Display docker images (final) + run: | + docker images + + - name: 'Comment PR' + uses: actions/github-script@v6 + with: + script: | + const { repo: { owner, repo } } = context; + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Pull Request Che-Code image published:\nšŸ‘‰ [${process.env._IMAGE_NAME}](https://${process.env._IMAGE_NAME})` + }) + + dev: + name: dev + runs-on: ubuntu-22.04 + steps: + + - name: Checkout che-code source code + uses: actions/checkout@v2 + + - name: Login to Quay.io + uses: docker/login-action@v2 + with: + registry: quay.io + username: ${{ secrets.QUAY_PULL_REQUESTS_USERNAME }} + password: ${{ secrets.QUAY_PULL_REQUESTS_PASSWORD }} + + - name: Build Che-Code Docker image + run: | + PR_NUMBER="${{ github.event.number }}" + echo "Pull request $PR_NUMBER" + + DEV_IMAGE_NAME="quay.io/che-incubator-pull-requests/che-code-dev:pr-$PR_NUMBER-dev-amd64" + echo "Dev image $DEV_IMAGE_NAME" + echo "_DEV_IMAGE_NAME=${DEV_IMAGE_NAME}" >> $GITHUB_ENV + + docker buildx build \ + --platform linux/amd64 \ + --progress=plain \ + --push \ + -f build/dockerfiles/dev.Dockerfile \ + -t ${DEV_IMAGE_NAME} . + + - name: Display docker images + run: | + docker images + + - name: 'Comment PR' + uses: actions/github-script@v6 + with: + script: | + const { repo: { owner, repo } } = context; + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Pull Request Dev image published:\nšŸ‘‰ [${process.env._DEV_IMAGE_NAME}](https://${process.env._DEV_IMAGE_NAME})` + }) diff --git a/.github/workflows/pr-check-image-publish.yml b/.github/workflows/pr-check-image-publish.yml deleted file mode 100644 index 52d6f54d811..00000000000 --- a/.github/workflows/pr-check-image-publish.yml +++ /dev/null @@ -1,139 +0,0 @@ -# -# Copyright (c) 2021 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# - -name: Publish Image PR check - -on: - workflow_run: - workflows: ["Pull Request Check"] - types: - - completed - -jobs: - publish-image-pull-request: - name: publish image from the pull request - runs-on: ubuntu-22.04 - steps: - - name: PR number - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - name: pull-request-number - - - name: Grab pull request number - run: | - pr_number=$(cat "PR_NUMBER") - if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then - echo "pr number invalid" - exit 1 - fi - echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV - - - name: PR sha - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - name: pull-request-sha - - - name: Grab pull request sha1 - run: | - pr_sha=$(cat "PR_SHA") - echo "PR_SHA=$pr_sha" >> $GITHUB_ENV - - - name: Login to Quay.io - uses: docker/login-action@v2 - with: - registry: quay.io - username: ${{ secrets.QUAY_PULL_REQUESTS_USERNAME }} - password: ${{ secrets.QUAY_PULL_REQUESTS_PASSWORD }} - - - name: Increase Swap Space # implemented for the Linux system only - if: runner.os == 'Linux' - shell: bash - run: | - echo "Current swap area:" - sudo swapon --show - - export SWAP_SIZE=7 - export SWAP_FILE_PATH=$(swapon --show=NAME | tail -n 1) - - sudo swapoff $SWAP_FILE_PATH - sudo rm $SWAP_FILE_PATH - - sudo fallocate -l ${SWAP_SIZE}G $SWAP_FILE_PATH - sudo chmod 600 $SWAP_FILE_PATH - sudo mkswap $SWAP_FILE_PATH - sudo swapon $SWAP_FILE_PATH - - echo "Updated swap area:" - sudo swapon --show - - - name: Download che-code image - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - name: action_image_artifact_che-code-image - path: assembly/ - - - name: Load che-code image to Docker - run: | - ls -la assembly - docker load -i assembly/che-code-image - - - name: Display docker images - run: | - docker images - - - name: Docker Push - run: | - export IMAGE_NAME=quay.io/che-incubator-pull-requests/che-code:pr-${{env.PR_NUMBER}}-amd64 - docker tag che-code-image ${IMAGE_NAME} - docker push ${IMAGE_NAME} - echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV - - - name: Cleanup images - run: | - ls -la assembly - rm -rf assembly - docker system prune -af - - - name: Download che-dev image - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - name: che-dev-image - path: dev/ - - - name: Load che-code-dev image to Docker - run: | - ls -la dev - docker load -i dev/che-dev-image.tgz - - - name: Display docker images - run: | - docker images - - - name: Docker Push - run: | - export DEV_IMAGE_NAME=quay.io/che-incubator-pull-requests/che-code-dev:pr-${{env.PR_NUMBER}}-dev-amd64 - docker tag che-dev-image ${DEV_IMAGE_NAME} - docker push ${DEV_IMAGE_NAME} - echo "DEV_IMAGE_NAME=${DEV_IMAGE_NAME}" >> $GITHUB_ENV - - - name: 'Comment PR' - uses: actions/github-script@v6 - with: - script: | - const { repo: { owner, repo } } = context; - await github.rest.issues.createComment({ - issue_number: process.env.PR_NUMBER, - owner: context.repo.owner, - repo: context.repo.repo, - body: `Pull Request images published āœØ\nimage: ${process.env.IMAGE_NAME}\n Dev image: ${process.env.DEV_IMAGE_NAME}` - }) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml deleted file mode 100644 index 1afebdd376e..00000000000 --- a/.github/workflows/pr-check.yml +++ /dev/null @@ -1,117 +0,0 @@ -# -# Copyright (c) 2021 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# - -name: Pull Request Check - -# Trigger the workflow on pull request -on: [pull_request] - -jobs: - - build: - name: build - strategy: - fail-fast: false - matrix: - dist: [ 'musl', 'libc' ] - arch: ['amd64'] - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Docker Build - env: - # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - docker buildx build --memory-swap -1 --memory 10g --platform linux/${{matrix.arch}} -f build/dockerfiles/linux-${{matrix.dist}}.Dockerfile --load -t linux-${{matrix.dist}}-${{matrix.arch}} . - - name: Upload image - uses: ishworkh/docker-image-artifact-upload@v1 - with: - image: "linux-${{matrix.dist}}-${{matrix.arch}}" - - assemble: - name: assemble - needs: build - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Cleanup docker images - run: | - docker system prune -af - - - name: Download linux-libc-amd64 image - uses: ishworkh/docker-image-artifact-download@v1 - with: - image: "linux-libc-amd64" - - - name: Download linux-musl image - uses: ishworkh/docker-image-artifact-download@v1 - with: - image: "linux-musl-amd64" - - - name: Display docker images - run: | - docker images - - - name: Docker Build - run: | - docker buildx build --platform linux/amd64 -f build/dockerfiles/assembly.Dockerfile --load -t che-code-image . - - - name: Upload assembly image - uses: ishworkh/docker-image-artifact-upload@v1 - with: - image: "che-code-image" - - - name: Store PR info - run: | - echo "${{ github.event.number }}" > PR_NUMBER - echo "${{ github.event.pull_request.head.sha }}" > PR_SHA - - - name: Upload PR NUMBER - uses: actions/upload-artifact@v3 - with: - name: pull-request-number - path: PR_NUMBER - - - name: Upload PR SHA - uses: actions/upload-artifact@v3 - with: - name: pull-request-sha - path: PR_SHA - - dev: - name: dev - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Cleanup docker images - run: | - docker system prune -af - - - name: Docker Build - run: | - docker buildx build --platform linux/amd64 -f build/dockerfiles/dev.Dockerfile --load -t che-dev-image . - - - name: Save che-dev image - run: | - docker save che-dev-image | gzip > che-dev-image.tgz - - - uses: actions/upload-artifact@v3 - with: - name: che-dev-image - path: che-dev-image.tgz