Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build linux/arm64 ubi9 universal image in GH action #213

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 143 additions & 7 deletions .github/workflows/empty-worksapce-smoke-test-on-minikube-ubi9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ env:

jobs:
workspace-api-tests-on-minikube:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
runs-on: ${{matrix.runners}}
steps:

- name: Checkout
Expand All @@ -47,11 +51,19 @@ jobs:
# remove build-in images from the VM because it is not used
docker rmi -f $(docker images -aq)

- name: Set arch environment variable
run: |
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
echo arch="amd64" >> $GITHUB_ENV
else
echo arch="arm64" >> $GITHUB_ENV
fi

- name: Start minikube cluster
id: run-minikube
uses: che-incubator/setup-minikube-action@next
with:
minikube-version: v1.31.0
run: |
curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-${{env.arch}}
install minikube-linux-${{env.arch}} /usr/local/bin/minikube && rm minikube-linux-${{env.arch}}
minikube start --vm-driver=docker --addons=ingress --cpus 2 --memory 6500

# connect with docker daemon in the minikube and build an image there
# we need to build the image in the minikube because we have just 14 GB of space on the runner
Expand Down Expand Up @@ -89,7 +101,7 @@ jobs:
kubectl wait deployment -n devworkspace-controller devworkspace-webhook-server --for condition=Available=True --timeout=$DEPLOYMENT_TIMEOUT
kubectl wait deployment -n devworkspace-controller devworkspace-controller-manager --for condition=Available=True --timeout=$DEPLOYMENT_TIMEOUT

- name: Check that UDI is presen in the image list
- name: Check that UDI is present in the image list
run: |
# we used it for the build above and do not need it anymore. It saves the disk space
minikube image rm quay.io/devfile/base-developer-image:ubi9-latest
Expand All @@ -105,10 +117,134 @@ jobs:
repository: eclipse/che
path: che

# Host devfile locally.
# Use the insiders tag for the che-code image and the PR number for the universal-developer-image
- name: Host devfile locally
run: |
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: devfile.yaml
data:
devfile.yaml: |
schemaVersion: 2.2.2
metadata:
name: che-code
commands:
- id: init-container-command
apply:
component: che-code-injector
- id: init-che-code-command
exec:
component: che-code-runtime-description
commandLine: nohup /checode/entrypoint-volume.sh > /checode/entrypoint-logs.txt 2>&1 &
events:
preStart:
- init-container-command
postStart:
- init-che-code-command
components:
- name: che-code-injector
container:
image: quay.io/che-incubator/che-code:insiders
command:
- /entrypoint-init-container.sh
volumeMounts:
- name: checode
path: /checode
memoryLimit: 256Mi
memoryRequest: 32Mi
cpuLimit: 500m
cpuRequest: 30m
- name: che-code-runtime-description
container:
image: quay.io/devfile/universal-developer-image:${{ env.PR_NUMBER }}
memoryLimit: 1024Mi
memoryRequest: 256Mi
cpuLimit: 500m
cpuRequest: 30m
volumeMounts:
- name: checode
path: /checode
endpoints:
- name: che-code
attributes:
type: main
cookiesAuthEnabled: true
discoverable: false
urlRewriteSupported: true
targetPort: 3100
exposure: public
secure: true
protocol: https
- name: code-redirect-1
targetPort: 13131
exposure: public
protocol: https
attributes:
discoverable: false
urlRewriteSupported: false
- name: code-redirect-2
targetPort: 13132
exposure: public
protocol: https
attributes:
discoverable: false
urlRewriteSupported: false
- name: code-redirect-3
targetPort: 13133
exposure: public
protocol: https
attributes:
discoverable: false
urlRewriteSupported: false
attributes:
app.kubernetes.io/component: che-code-runtime
app.kubernetes.io/part-of: che-code.eclipse.org
controller.devfile.io/container-contribution: true
- name: checode
volume: {}
---
apiVersion: v1
kind: Pod
metadata:
name: file-server
labels:
app: file-server
spec:
containers:
- name: nginx-container
image: nginx
ports:
- containerPort: 80
volumeMounts:
- name: server-volume
mountPath: /usr/share/nginx/html
readOnly: true
volumes:
- name: server-volume
configMap:
name: devfile.yaml
---
apiVersion: v1
kind: Service
metadata:
name: file-service
spec:
selector:
app: file-server
ports:
- protocol: TCP
port: 80
targetPort: 80
EOF

- name: Run Empty workspace smoke test
run: |
export TS_API_TEST_UDI_IMAGE=quay.io/devfile/universal-developer-image:${{ env.PR_NUMBER }}
export TS_API_TEST_CHE_CODE_EDITOR_DEVFILE_URI=http://file-service.default.svc:80/devfile.yaml
cd che/tests/e2e
npm i
npm run driver-less-test

138 changes: 138 additions & 0 deletions .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#
# Copyright (c) 2021-2025 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-base-image:
name: Build base image
strategy:
fail-fast: false
matrix:
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
runs-on: ${{matrix.runners}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set arch environment variable
run: |
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
echo arch="amd64" >> $GITHUB_ENV
else
echo arch="arm64" >> $GITHUB_ENV
fi
- name: Free runner space
run: sudo rm -rf /usr/local/lib/android
- name: Cleanup docker images
run: docker system prune -af
- name: Build base image
run: |
cd base/ubi9 && docker buildx build \
--platform linux/${{env.arch}} \
--progress=plain \
-t base-developer-image-${{env.arch}} .
- name: Display docker images
run: docker images
- name: Compress image to a file
run: docker save base-developer-image-${{env.arch}} | gzip > base-developer-image-${{env.arch}}.tgz
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: base-developer-image-${{env.arch}}
path: base-developer-image-${{env.arch}}.tgz

build-udi:
name: Build udi
strategy:
fail-fast: false
matrix:
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
runs-on: ${{matrix.runners}}
needs: build-base-image
steps:
- name: Set arch environment variable
run: |
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
echo arch="amd64" >> $GITHUB_ENV
else
echo arch="arm64" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@v4
- name: Free runner space
run: sudo rm -rf /usr/local/lib/android
- name: Cleanup docker images
run: docker system prune -af
- name: Download BDI artifacts
uses: actions/download-artifact@v4
with:
pattern: base-developer-image-*
merge-multiple: true
path: .
- name: List downloaded files
run: ls -lah
- name: Load docker images
run: docker load -i base-developer-image-${{env.arch}}.tgz
- name: Display docker images
run: docker images
- name: Update UDI Dockerfile
run: sed "s|quay.io/devfile/base-developer-image:ubi9-latest|base-developer-image-${{env.arch}}|" -i "universal/ubi9/Dockerfile"
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build udi
run: |
cd universal/ubi9 && docker buildx build \
--platform linux/${{env.arch}} \
--progress=plain \
--push \
-t quay.io/devfile/universal-developer-image:${{env.arch}}-pr-${{github.event.number}} .

publish-udi:
name: Publish udi
runs-on: ubuntu-22.04
needs: build-udi
steps:
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: publish
run: |
docker manifest create quay.io/devfile/universal-developer-image:pr-${{github.event.number}} \
--amend quay.io/devfile/universal-developer-image:amd64-pr-${{github.event.number}} \
--amend quay.io/devfile/universal-developer-image:arm64-pr-${{github.event.number}}

docker manifest annotate quay.io/devfile/universal-developer-image:pr-${{github.event.number}} \
quay.io/devfile/universal-developer-image:amd64-pr-${{github.event.number}} \
--os linux --arch amd64
docker manifest annotate quay.io/devfile/universal-developer-image:pr-${{github.event.number}} \
quay.io/devfile/universal-developer-image:arm64-pr-${{github.event.number}} \
--os linux --arch arm64

docker manifest push quay.io/devfile/universal-developer-image:pr-${{github.event.number}}
- name: 'Comment PR'
uses: actions/github-script@v7
with:
script: |
const { repo: { owner, repo } } = context;
await github.rest.issues.createComment({
issue_number: ${{github.event.number}},
owner: context.repo.owner,
repo: context.repo.repo,
body: `Pull Request images published ✨\n\nUDI: [quay.io/devfile/universal-developer-image:pr-${{github.event.number}}](https://quay.io/devfile/universal-developer-image:pr-${{github.event.number}})`
})
Loading