Skip to content

[CI] Support latest python runtimes in benchmarking CI (#3246) #1389

[CI] Support latest python runtimes in benchmarking CI (#3246)

[CI] Support latest python runtimes in benchmarking CI (#3246) #1389

Workflow file for this run

# Copyright 2023 The Nuclio Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Release
on:
release:
types:
- created
# Run Release on push to development for unstable
push:
branches:
- development
workflow_dispatch:
inputs:
docker_image_rule:
description: 'Docker image rule to build and release (space separated)'
required: false
default: ''
env:
REPO: quay.io
REPO_NAME: nuclio
CACHE_REPO: ghcr.io
CACHE_REPO_NAME: ${{ github.repository_owner }}
DOCKER_BUILDKIT: 1
permissions:
# Allow the action to upload artifact to releases
contents: write
# Allow the action to upload cache images
packages: write
jobs:
image_matrix_prep:
name: Prepare image list
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: define targets
id: set-matrix
run: |
# if custom image is given, use it
if [[ -n "${{ github.event.inputs.docker_image_rule }}" ]]; then \
export DOCKER_IMAGES_RULES="${{ github.event.inputs.docker_image_rule }}"; \
fi;
docker_image_rules_json=$(make print-docker-image-rules-json)
# if "handler-builder-golang-onbuild" is in the matrix
# then ensure "handler-builder-golang-onbuild-alpine" is there too.
docker_image_rules_json=$(echo $docker_image_rules_json | \
jq -c 'select(.[].image_rule=="handler-builder-golang-onbuild") += [{"image_rule":"handler-builder-golang-onbuild-alpine"}]')
echo $docker_image_rules_json
echo "matrix=$(echo $docker_image_rules_json | jq -c '[.[].image_rule]')" >> $GITHUB_OUTPUT
release:
if: github.repository == 'nuclio/nuclio' || github.event_name == 'workflow_dispatch'
name: Release image (${{ matrix.docker_image_rule }}-${{ matrix.arch }})
runs-on: ubuntu-latest
needs: image_matrix_prep
strategy:
fail-fast: false
matrix:
arch:
- arm64
- amd64
docker_image_rule: ${{ fromJson(needs.image_matrix_prep.outputs.matrix) }}
exclude:
# issues with building on qemu
- arch: arm64
docker_image_rule: handler-builder-dotnetcore-onbuild
steps:
- name: Prepare envs
run: |
echo "NUCLIO_DOCKER_REPO=${{ env.REPO }}/${{ env.REPO_NAME }}" >> $GITHUB_ENV
echo "NUCLIO_CACHE_REPO=${{ env.CACHE_REPO }}/${{ env.CACHE_REPO_NAME }}" >> $GITHUB_ENV
echo "NUCLIO_ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
- name: Prepare outputs
id: release_info
run: |
echo "REF_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "REF_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Set NUCLIO_LABEL to unstable
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: echo "NUCLIO_LABEL=unstable" >> $GITHUB_ENV
- name: Set NUCLIO_LABEL to release tag
if: github.event_name == 'release'
run: echo "NUCLIO_LABEL=${{ steps.release_info.outputs.REF_TAG }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
cache: true
go-version-file: go.mod
- name: Install QEMU
if: matrix.arch != 'amd64'
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ matrix.arch }}
- name: Login to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REPO }}
username: ${{ secrets.QUAYIO_DOCKER_USERNAME }}
password: ${{ secrets.QUAYIO_DOCKER_PASSWORD }}
- name: Login to cache registry
uses: docker/login-action@v2
with:
registry: ${{ env.CACHE_REPO }}
username: ${{ env.CACHE_REPO_NAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{ matrix.docker_image_rule }} image
run: |
make pull-docker-images-cache || true
make docker-images
env:
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }}
DOCKER_IMAGES_RULES: ${{ matrix.docker_image_rule }}
# this only applies when target is `handler-builder-golang-onbuild`
# not applied when target is `handler-builder-golang-onbuild-alpine`
SKIP_BUILD_GOLANG_ONBUILD_ALPINE: true
- name: Push cache images
if: env.NUCLIO_LABEL == 'unstable'
run: make push-docker-images-cache
env:
DOCKER_IMAGES_RULES: ${{ matrix.docker_image_rule }}
SKIP_BUILD_GOLANG_ONBUILD_ALPINE: true
- name: Push images
run: make push-docker-images
env:
DOCKER_IMAGES_RULES: ${{ matrix.docker_image_rule }}
SKIP_BUILD_GOLANG_ONBUILD_ALPINE: true
- name: Tag and push stable images
if: env.NUCLIO_LABEL != 'unstable' && github.event.release.target_commitish == 'master' && contains(matrix.docker_image_rule, 'dashboard')
run: |
docker tag "$NUCLIO_DOCKER_REPO/dashboard:$NUCLIO_LABEL-$NUCLIO_ARCH" "$NUCLIO_DOCKER_REPO/dashboard:stable-$NUCLIO_ARCH"
docker push "$NUCLIO_DOCKER_REPO/dashboard:stable-$NUCLIO_ARCH"
env:
DOCKER_IMAGES_RULES: ${{ matrix.docker_image_rule }}
release_binary:
if: github.event_name == 'release'
name: Release Binary ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch:
- arm64
- amd64
steps:
- name: Prepare envs
run: |
echo "NUCLIO_ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
- name: Prepare outputs
id: release_info
run: |
echo "REF_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "REF_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Set NUCLIO_LABEL to unstable
if: github.event_name == 'push'
run: echo "NUCLIO_LABEL=unstable" >> $GITHUB_ENV
- name: Set NUCLIO_LABEL to release tag
if: github.event_name == 'release'
run: echo "NUCLIO_LABEL=${{ steps.release_info.outputs.REF_TAG }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
cache: true
- name: Install QEMU
if: matrix.arch != 'amd64'
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ matrix.arch }}
- name: Build binaries
run: |
NUCLIO_OS=linux make tools
NUCLIO_OS=darwin make tools
if [ $NUCLIO_ARCH == "amd64" ]; then \
NUCLIO_OS=windows make tools; \
fi;
env:
NUCLIO_NUCTL_CREATE_SYMLINK: false
GOPATH: /home/runner/go
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }}
- name: Upload binaries
uses: AButler/[email protected]
with:
files: '/home/runner/go/bin/nuctl-*'
repo-token: ${{ secrets.GITHUB_TOKEN }}