-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a299ff4
commit 3edfc83
Showing
5 changed files
with
241 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,154 @@ | ||
language: go | ||
# | ||
# 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 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
|
||
language: go | ||
go: | ||
- "1.15" | ||
|
||
- '1.15' | ||
os: linux | ||
dist: focal | ||
|
||
git: | ||
depth: false | ||
|
||
env: | ||
global: | ||
- TAG=next | ||
- TRAVIS_TAG=travis | ||
- REGISTRY=quay.io | ||
- ORGANIZATION=eclipse | ||
- IMAGE=che-machine-exec | ||
- PR_NUMBER= | ||
|
||
install: | ||
- export SHORT_SHA=$(git rev-parse --short HEAD) | ||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
- echo "$QUAY_PASSWORD" | docker login quay.io -u "$QUAY_USERNAME " --password-stdin | ||
# TODO when we're confident that sha-tagged travis-built images won't collide with GHA built ones, we can remove the -travis suffix here | ||
- export SHORT_SHA=$(git rev-parse --short HEAD)-travis | ||
- export GITHUB_TOKEN="$CHE_BOT_GITHUB_TOKEN" | ||
- echo "$RH_CHE_AUTOMATION_DOCKERHUB_PASSWORD" | docker login -u "$RH_CHE_AUTOMATION_DOCKERHUB_USERNAME" --password-stdin | ||
- echo "$QUAY_ECLIPSE_CHE_PASSWORD" | docker login quay.io -u "$QUAY_ECLIPSE_CHE_USERNAME" --password-stdin | ||
|
||
env: | ||
global: | ||
- TAG=next-travis | ||
- REGISTRY=quay.io | ||
- ORGANIZATION=eclipse | ||
- IMAGE=che-machine-exec | ||
- PR_NUMBER= | ||
|
||
jobs: | ||
fast_finish: true | ||
allow_failures: | ||
- if: env(PR_NUMBER) IS present | ||
arch: arm64 | ||
- if: env(PR_NUMBER) IS present | ||
arch: ppc64le | ||
- if: env(PR_NUMBER) IS present | ||
arch: s390x | ||
- if: env(PR_NUMBER) IS present | ||
arch: arm64 | ||
- if: env(PR_NUMBER) IS present | ||
arch: ppc64le | ||
- if: env(PR_NUMBER) IS present | ||
arch: s390x | ||
include: | ||
- &docker-build-pr | ||
stage: PR Check | ||
if: env(PR_NUMBER) IS present | ||
name: Check docker build on amd64 | ||
arch: amd64 | ||
install: | ||
- git fetch origin +refs/pull/${PR_NUMBER}/merge | ||
- git checkout -qf FETCH_HEAD | ||
script: docker build -f build/dockerfiles/Dockerfile -t "${REGISTRY}/${ORGANIZATION}/${IMAGE}:pr-check-${TRAVIS_CPU_ARCH}" . | ||
- <<: *docker-build-pr | ||
name: Check docker build on arm64 | ||
arch: arm64 | ||
- <<: *docker-build-pr | ||
name: Check docker build on ppc64le | ||
arch: ppc64le | ||
- <<: *docker-build-pr | ||
name: check docker build PR on s390x | ||
arch: s390x | ||
|
||
- &unit-test | ||
if: env(PR_NUMBER) IS present | ||
name: Run unit tests on amd64 | ||
arch: amd64 | ||
install: | ||
- git fetch origin +refs/pull/${PR_NUMBER}/merge | ||
- git checkout -qf FETCH_HEAD | ||
- export GO111MODULE="on" | ||
- go get ${gobuild_args} ./... | ||
script: | ||
- | | ||
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -ldflags '-w -s' -a -installsuffix cgo -o che-machine-exec . | ||
export CHE_WORKSPACE_ID=test_id | ||
go test ./... -test.v | ||
- <<: *unit-test | ||
name: Run unit tests on arm64 | ||
arch: arm64 | ||
- <<: *unit-test | ||
name: Run unit tests on ppc64le | ||
arch: ppc64le | ||
- <<: *unit-test | ||
name: Run unit tests on s390x | ||
arch: s390x | ||
|
||
- &next-build | ||
stage: Build and push both short SHA tag and next tag | ||
if: type = api AND branch = main AND env(TAG) = "next" | ||
name: Build image on amd64 | ||
arch: amd64 | ||
script: | ||
- bash .travis/build_image.sh | ||
- <<: *next-build | ||
name: Build image on arm64 | ||
arch: arm64 | ||
- <<: *next-build | ||
name: Build image on ppc64le | ||
arch: ppc64le | ||
- <<: *next-build | ||
name: Build image on s390x | ||
arch: s390x | ||
|
||
- stage: Publish multiarch image with next & short_sha tag | ||
if: type = api AND branch = main AND env(TAG) = "next" | ||
script: bash .travis/publish_multiarch.sh | ||
|
||
- &release-build | ||
stage: Release che-machine-exec | ||
if: type = api AND env(TAG) IS present AND env(TAG) != "next" | ||
name: Build image on amd64 | ||
arch: amd64 | ||
script: | ||
- | | ||
BRANCH=${TAG%.*}.x | ||
git checkout "${BRANCH}" | ||
bash .travis/build_image.sh | ||
- <<: *release-build | ||
name: Build image on arm64 | ||
arch: arm64 | ||
- <<: *release-build | ||
name: Build image on ppc64le | ||
arch: ppc64le | ||
- <<: *release-build | ||
name: Build image on s390x | ||
arch: s390x | ||
|
||
- stage: Publish multiarch image with release tag | ||
if: type = api AND env(TAG) IS present AND env(TAG) != "next" | ||
script: bash .travis/publish_multiarch.sh | ||
- stage: PR Check | ||
if: env(PR_NUMBER) IS present | ||
name: Check docker build on amd64 | ||
arch: amd64 | ||
install: &1 | ||
- git fetch origin +refs/pull/${PR_NUMBER}/merge | ||
- git checkout -qf FETCH_HEAD | ||
script: docker build -f build/dockerfiles/Dockerfile -t "${REGISTRY}/${ORGANIZATION}/${IMAGE}:pr-check-${TRAVIS_CPU_ARCH}" | ||
. | ||
- stage: PR Check | ||
if: env(PR_NUMBER) IS present | ||
name: Check docker build on arm64 | ||
arch: arm64 | ||
install: *1 | ||
script: docker build -f build/dockerfiles/Dockerfile -t "${REGISTRY}/${ORGANIZATION}/${IMAGE}:pr-check-${TRAVIS_CPU_ARCH}" | ||
. | ||
- stage: PR Check | ||
if: env(PR_NUMBER) IS present | ||
name: Check docker build on ppc64le | ||
arch: ppc64le | ||
install: *1 | ||
script: docker build -f build/dockerfiles/Dockerfile -t "${REGISTRY}/${ORGANIZATION}/${IMAGE}:pr-check-${TRAVIS_CPU_ARCH}" | ||
. | ||
- stage: PR Check | ||
if: env(PR_NUMBER) IS present | ||
name: check docker build PR on s390x | ||
arch: s390x | ||
install: *1 | ||
script: docker build -f build/dockerfiles/Dockerfile -t "${REGISTRY}/${ORGANIZATION}/${IMAGE}:pr-check-${TRAVIS_CPU_ARCH}" | ||
. | ||
- if: env(PR_NUMBER) IS present | ||
name: Run unit tests on amd64 | ||
arch: amd64 | ||
install: &2 | ||
- git fetch origin +refs/pull/${PR_NUMBER}/merge | ||
- git checkout -qf FETCH_HEAD | ||
- export GO111MODULE="on" | ||
- go get ${gobuild_args} ./... | ||
script: &3 | ||
- | | ||
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -ldflags '-w -s' -a -installsuffix cgo -o che-machine-exec . | ||
export CHE_WORKSPACE_ID=test_id | ||
go test ./... -test.v | ||
- if: env(PR_NUMBER) IS present | ||
name: Run unit tests on arm64 | ||
arch: arm64 | ||
install: *2 | ||
script: *3 | ||
- if: env(PR_NUMBER) IS present | ||
name: Run unit tests on ppc64le | ||
arch: ppc64le | ||
install: *2 | ||
script: *3 | ||
- if: env(PR_NUMBER) IS present | ||
name: Run unit tests on s390x | ||
arch: s390x | ||
install: *2 | ||
script: *3 | ||
- stage: Build and push both short SHA tag and next-travis tag | ||
if: type = api AND branch = main AND env(TAG) = "next-travis" AND env(PR_NUMBER) IS blank | ||
name: Build image on amd64 | ||
arch: amd64 | ||
script: &4 | ||
- .travis/build_image.sh | ||
- stage: Build and push both short SHA tag and next-travis tag | ||
if: type = api AND branch = main AND env(TAG) = "next-travis" AND env(PR_NUMBER) IS blank | ||
name: Build image on arm64 | ||
arch: arm64 | ||
script: *4 | ||
- stage: Build and push both short SHA tag and next-travis tag | ||
if: type = api AND branch = main AND env(TAG) = "next-travis" AND env(PR_NUMBER) IS blank | ||
name: Build image on ppc64le | ||
arch: ppc64le | ||
script: *4 | ||
- stage: Build and push both short SHA tag and next-travis tag | ||
if: type = api AND branch = main AND env(TAG) = "next-travis" AND env(PR_NUMBER) IS blank | ||
name: Build image on s390x | ||
arch: s390x | ||
script: *4 | ||
- stage: Publish multiarch image with next-travis & short_sha tag | ||
if: type = api AND branch = main AND env(TAG) = "next-travis" AND env(PR_NUMBER) IS blank | ||
script: .travis/publish_multiarch.sh | ||
- stage: Release che-machine-exec | ||
if: type = api AND env(TAG) IS present AND env(TAG) != "next-travis" | ||
name: Build image on amd64 | ||
arch: amd64 | ||
script: &5 | ||
- | | ||
BRANCH=${TAG%.*}.x | ||
git checkout "${BRANCH}" | ||
TAG=${TAG}-travis | ||
.travis/build_image.sh | ||
- stage: Release che-machine-exec | ||
if: type = api AND env(TAG) IS present AND env(TAG) != "next-travis" | ||
name: Build image on arm64 | ||
arch: arm64 | ||
script: *5 | ||
- stage: Release che-machine-exec | ||
if: type = api AND env(TAG) IS present AND env(TAG) != "next-travis" | ||
name: Build image on ppc64le | ||
arch: ppc64le | ||
script: *5 | ||
- stage: Release che-machine-exec | ||
if: type = api AND env(TAG) IS present AND env(TAG) != "next-travis" | ||
name: Build image on s390x | ||
arch: s390x | ||
script: *5 | ||
- stage: Publish multiarch image with release tag | ||
if: type = api AND env(TAG) IS present AND env(TAG) != "next-travis" | ||
script: TAG=$TAG-travis .travis/publish_multiarch.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
#!/bin/bash | ||
# | ||
# 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 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
set -e | ||
|
||
# Build images | ||
docker build -f build/dockerfiles/Dockerfile -t "${REGISTRY}/${ORGANIZATION}/${IMAGE}:${TAG}-${TRAVIS_TAG}-${TRAVIS_CPU_ARCH}" . | ||
docker push "${REGISTRY}/${ORGANIZATION}/${IMAGE}:${TAG}-${TRAVIS_TAG}-${TRAVIS_CPU_ARCH}" | ||
#shellcheck disable=SC1073 disable=SC2066 disable=SC2153 | ||
for image in ${IMAGE}; do | ||
the_image="${REGISTRY}/${ORGANIZATION}/${image}" | ||
|
||
# Tag image with short_sha in case of next build | ||
if [[ "$TAG" == "next" ]]; then | ||
docker tag "${REGISTRY}/${ORGANIZATION}/${IMAGE}:${TAG}-${TRAVIS_TAG}-${TRAVIS_CPU_ARCH}" "${REGISTRY}/${ORGANIZATION}/${IMAGE}:${SHORT_SHA}-${TRAVIS_TAG}-${TRAVIS_CPU_ARCH}" | ||
docker push "${REGISTRY}/${ORGANIZATION}/${IMAGE}:${SHORT_SHA}-${TRAVIS_TAG}-${TRAVIS_CPU_ARCH}" | ||
fi | ||
# Build images | ||
docker build -f build/dockerfiles/Dockerfile -t "${the_image}:${TAG}-${TRAVIS_CPU_ARCH}" . | ||
docker push "${the_image}:${TAG}-${TRAVIS_CPU_ARCH}" | ||
|
||
# Tag image with short_sha in case of next build | ||
if [[ "$TAG" == "next-travis" ]]; then | ||
docker tag "${the_image}:${TAG}-${TRAVIS_CPU_ARCH}" "${the_image}:${SHORT_SHA}-${TRAVIS_CPU_ARCH}" | ||
docker push "${the_image}:${SHORT_SHA}-${TRAVIS_CPU_ARCH}" | ||
fi | ||
done |
Oops, something went wrong.