Skip to content

Commit

Permalink
Add support for GHA build WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jan 31, 2024
1 parent 4c154b3 commit 98effde
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 43 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/e2e-gha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
CIUXCONFIG: /tmp/ciux.sh
CIUX_VERSION: 769944575a
GHA_BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
NOSCIENCE: true
SUFFIX: noscience
jobs:
build:
name: Build image
Expand All @@ -27,14 +27,18 @@ jobs:
run: ciux ignite $PWD
- name: Build fink-broker image for k8s
run: |
./build.sh
./build.sh --suffix "${{ env.SUFFIX }}" --tmp-registry "${{ env.CI_REPO }}"
- name: Export fink-broker image
run: |
docker images
. ./conf.sh
$(ciux get image --check $PWD --suffix "${{ env.SUFFIX }}" --env)
mkdir -p artifacts
docker save "$IMAGE" > artifacts/image.tar
echo "$IMAGE" > artifacts/image-tag
if [ $CIUX_BUILD = true ]; then
echo "Export $CIUX_IMAGE_URL to archive"
docker save "$CIUX_IMAGE_URL" > artifacts/image.tar
else
echo "Using existing image $CIUX_IMAGE_URL"
fi
echo "IMAGE=$CIUX_IMAGE_URL" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v2
with:
name: docker-artifact
Expand Down Expand Up @@ -75,8 +79,12 @@ jobs:
path: artifacts
- name: Load container image inside kind
run: |
kind load image-archive artifacts/image.tar
docker exec -- kind-control-plane crictl image
if [ -f artifacts/image.tar ]; then
echo "Loading image from archive"
docker load --input artifacts/image.tar
else
echo "Using existing image"
fi
- name: Install fink-alert-simulator pre-requisites (argo-workflows)
run: |
. "$CIUXCONFIG"
Expand Down Expand Up @@ -152,4 +160,4 @@ jobs:
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Push image to IN2P3 registry
run: |
docker push ${{ env.IMAGE }}
docker push ${{ env.IMAGE }}
1 change: 0 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ env:
CIUXCONFIG: /tmp/ciux.sh
CIUX_VERSION: 769944575a
GHA_BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
MINIMAL: ${{ inputs.minimal }}
NOSCIENCE: ${{ inputs.noscience }}
# Override the self-hosted runner value
POD_NAMESPACE: default
Expand Down
9 changes: 5 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ while getopts hs: c ; do
done
shift `expr $OPTIND - 1`

image=$(ciux get image $PWD --suffix "$suffix")

# TODO use error code for anormal exit
# --check should return true or false
if image=$(ciux get image --check $PWD --suffix "$suffix")
$(ciux get image --check $PWD --suffix "$suffix" --tmp-registry "$tmp_registry" --env)

if [ $CIUX_BUILD = false ];
then
echo "Build cancelled, image $image already exists with current source code"
echo "Build cancelled, image $CIUX_IMAGE_URL already exists and contains current source code"
exit 0
fi

Expand All @@ -70,5 +71,5 @@ else
fi

# Build image
docker image build --tag "$IMAGE" --build-arg spark_py_image="$ASTROLABSOFTWARE_FINK_SPARK_PY_IMAGE" "$DIR" --target $target
docker image build --tag "$CIUX_IMAGE_URL" --build-arg spark_py_image="$ASTROLABSOFTWARE_FINK_SPARK_PY_IMAGE" "$DIR" --target $target

23 changes: 0 additions & 23 deletions conf.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@

. "$CIUXCONFIG"

# Do not launch science pipeline if true
NOSCIENCE="${NOSCIENCE:-false}"

# Build parameters
# ----------------

# TODO make it simpler!!
# TODO add this code to 'ciux get image --check --build-registry'
if [ "$FINK_BROKER_VERSION" = "$CIUX_IMAGE_TAG" ]
then
# We need to build the image
# and eventually set repository address on self-hosted runner
REGISTRY="${CI_REPO:-$CIUX_IMAGE_REGISTRY}"
else
# We can use an existing image
REGISTRY="$CIUX_IMAGE_REGISTRY"
fi

IMAGE="$REGISTRY/$CIUX_IMAGE_NAME:$CIUX_IMAGE_TAG"

# TODO Implement ciux get image --current ?
PROMOTED_IMAGE="$CIUX_IMAGE_REGISTRY/$CIUX_IMAGE_NAME:$FINK_BROKER_VERSION"

# Spark parameters
# ----------------

Expand Down
13 changes: 8 additions & 5 deletions e2e/fink-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ set -euxo pipefail

DIR=$(cd "$(dirname "$0")"; pwd -P)

. $DIR/../conf.sh

echo $IMAGE
if [ -n $CIUX_IMAGE_URL ];
then
IMAGE="$CIUX_IMAGE_URL"
else
echo "ERROR: CIUX_IMAGE_URL is not set"
exit 1
fi

NS=spark
echo "Create $NS namespace"
Expand All @@ -38,7 +42,7 @@ kubectl port-forward -n minio svc/minio 9000 &
# Wait to port-forward to start
sleep 2

if [ "$NOSCIENCE" = true ];
if [ "$IMAGE" =~ "-noscience" ];
then
NOSCIENCE_OPT="--noscience"
export FINKCONFIG="$DIR/finkconfig_noscience"
Expand All @@ -47,7 +51,6 @@ else
export FINKCONFIG="$DIR/finkconfig"
fi


finkctl --endpoint=localhost:9000 s3 makebucket

echo "Create spark ServiceAccount"
Expand Down
2 changes: 1 addition & 1 deletion examples/aliases-fink.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FINK_BROKER_SRC_DIR="$ASTROLAB_DIR/fink-broker"
FINK_ALERT_SIM_SRC_DIR="$ASTROLAB_DIR/fink-alert-simulator"
FINKCTL_SRC_DIR="$ASTROLAB_DIR/finkctl"

export FINKCONFIG=$FINK_BROKER_SRC_DIR/itest
export FINKCONFIG=$FINK_BROKER_SRC_DIR/e2e/finkconfig_noscience

alias cdfa="cd $FINK_ALERT_SIM_SRC_DIR"
alias cdfb="cd $FINK_BROKER_SRC_DIR"
Expand Down

0 comments on commit 98effde

Please sign in to comment.