2024-02-06 10:56:27 +00:00
|
|
|
name: Reusable - Docker
|
2023-08-17 03:04:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
docker_file:
|
|
|
|
default: docker/codex.Dockerfile
|
|
|
|
description: Dockerfile
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
docker_repo:
|
|
|
|
default: codexstorage/nim-codex
|
|
|
|
description: DockerHub repository
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
make_parallel:
|
|
|
|
default: 4
|
|
|
|
description: Make parallel
|
|
|
|
required: false
|
|
|
|
type: number
|
|
|
|
nimflags:
|
|
|
|
default: '-d:disableMarchNative'
|
|
|
|
description: Nim flags for builds
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
nat_ip_auto:
|
|
|
|
default: false
|
|
|
|
description: Enable NAT IP auto
|
|
|
|
required: false
|
|
|
|
type: boolean
|
|
|
|
tag_latest:
|
|
|
|
default: true
|
|
|
|
description: Set latest tag for Docker images
|
|
|
|
required: false
|
|
|
|
type: boolean
|
|
|
|
tag_sha:
|
|
|
|
default: true
|
|
|
|
description: Set Git short commit as Docker tag
|
|
|
|
required: false
|
|
|
|
type: boolean
|
|
|
|
tag_suffix:
|
|
|
|
default: ''
|
|
|
|
description: Suffix for Docker images tag
|
|
|
|
required: false
|
|
|
|
type: string
|
2023-11-27 11:32:13 +00:00
|
|
|
continuous_tests_list:
|
|
|
|
default: ''
|
|
|
|
description: Continuous Tests list
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
continuous_tests_duration:
|
|
|
|
default: 48h
|
|
|
|
description: Continuous Tests duration
|
|
|
|
required: false
|
|
|
|
type: string
|
2024-12-04 11:52:51 +00:00
|
|
|
run_release_tests:
|
|
|
|
description: Run Release tests
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
default: false
|
2023-08-17 03:04:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
env:
|
2023-11-27 11:32:13 +00:00
|
|
|
# Build
|
2023-08-17 03:04:50 +00:00
|
|
|
DOCKER_FILE: ${{ inputs.docker_file }}
|
|
|
|
DOCKER_REPO: ${{ inputs.docker_repo }}
|
|
|
|
MAKE_PARALLEL: ${{ inputs.make_parallel }}
|
|
|
|
NIMFLAGS: ${{ inputs.nimflags }}
|
|
|
|
NAT_IP_AUTO: ${{ inputs.nat_ip_auto }}
|
|
|
|
TAG_LATEST: ${{ inputs.tag_latest }}
|
|
|
|
TAG_SHA: ${{ inputs.tag_sha }}
|
|
|
|
TAG_SUFFIX: ${{ inputs.tag_suffix }}
|
2023-11-27 11:32:13 +00:00
|
|
|
# Tests
|
2024-12-04 11:52:51 +00:00
|
|
|
TESTS_SOURCE: codex-storage/cs-codex-dist-tests
|
|
|
|
TESTS_BRANCH: master
|
2023-11-27 11:32:13 +00:00
|
|
|
CONTINUOUS_TESTS_LIST: ${{ inputs.continuous_tests_list }}
|
|
|
|
CONTINUOUS_TESTS_DURATION: ${{ inputs.continuous_tests_duration }}
|
|
|
|
CONTINUOUS_TESTS_NAMEPREFIX: c-tests-ci
|
2023-08-17 03:04:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
# Build platform specific image
|
|
|
|
build:
|
|
|
|
strategy:
|
|
|
|
fail-fast: true
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
- os: linux
|
|
|
|
arch: amd64
|
|
|
|
- os: linux
|
|
|
|
arch: arm64
|
|
|
|
include:
|
|
|
|
- target:
|
|
|
|
os: linux
|
|
|
|
arch: amd64
|
|
|
|
builder: ubuntu-22.04
|
|
|
|
- target:
|
|
|
|
os: linux
|
|
|
|
arch: arm64
|
2024-12-04 11:52:51 +00:00
|
|
|
builder: buildjet-8vcpu-ubuntu-2204-arm
|
2023-08-17 03:04:50 +00:00
|
|
|
|
|
|
|
name: Build ${{ matrix.target.os }}/${{ matrix.target.arch }}
|
|
|
|
runs-on: ${{ matrix.builder }}
|
|
|
|
env:
|
|
|
|
PLATFORM: ${{ format('{0}/{1}', 'linux', matrix.target.arch) }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-08-17 03:04:50 +00:00
|
|
|
|
|
|
|
- name: Docker - Meta
|
|
|
|
id: meta
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: docker/metadata-action@v5
|
2023-08-17 03:04:50 +00:00
|
|
|
with:
|
|
|
|
images: ${{ env.DOCKER_REPO }}
|
|
|
|
|
|
|
|
- name: Docker - Set up Buildx
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2023-08-17 03:04:50 +00:00
|
|
|
|
|
|
|
- name: Docker - Login to Docker Hub
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: docker/login-action@v3
|
2023-08-17 03:04:50 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Docker - Build and Push by digest
|
|
|
|
id: build
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: docker/build-push-action@v5
|
2023-08-17 03:04:50 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ${{ env.DOCKER_FILE }}
|
|
|
|
platforms: ${{ env.PLATFORM }}
|
|
|
|
push: true
|
|
|
|
build-args: |
|
|
|
|
MAKE_PARALLEL=${{ env.MAKE_PARALLEL }}
|
|
|
|
NIMFLAGS=${{ env.NIMFLAGS }}
|
|
|
|
NAT_IP_AUTO=${{ env.NAT_IP_AUTO }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
outputs: type=image,name=${{ env.DOCKER_REPO }},push-by-digest=true,name-canonical=true,push=true
|
|
|
|
|
|
|
|
- name: Docker - Export digest
|
|
|
|
run: |
|
|
|
|
mkdir -p /tmp/digests
|
|
|
|
digest="${{ steps.build.outputs.digest }}"
|
|
|
|
touch "/tmp/digests/${digest#sha256:}"
|
|
|
|
|
|
|
|
- name: Docker - Upload digest
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-08-17 03:04:50 +00:00
|
|
|
with:
|
2024-01-29 18:12:07 +00:00
|
|
|
name: digests-${{ matrix.target.arch }}
|
2023-08-17 03:04:50 +00:00
|
|
|
path: /tmp/digests/*
|
|
|
|
if-no-files-found: error
|
|
|
|
retention-days: 1
|
|
|
|
|
|
|
|
|
|
|
|
# Publish multi-platform image
|
|
|
|
publish:
|
|
|
|
name: Publish multi-platform image
|
|
|
|
runs-on: ubuntu-latest
|
2023-11-27 11:32:13 +00:00
|
|
|
outputs:
|
|
|
|
version: ${{ steps.meta.outputs.version }}
|
2023-08-17 03:04:50 +00:00
|
|
|
needs: build
|
|
|
|
steps:
|
|
|
|
- name: Docker - Variables
|
|
|
|
run: |
|
|
|
|
# Adjust custom suffix when set and
|
|
|
|
if [[ -n "${{ env.TAG_SUFFIX }}" ]]; then
|
|
|
|
echo "TAG_SUFFIX=-${{ env.TAG_SUFFIX }}" >>$GITHUB_ENV
|
|
|
|
fi
|
|
|
|
# Disable SHA tags on tagged release
|
|
|
|
if [[ ${{ startsWith(github.ref, 'refs/tags/') }} == "true" ]]; then
|
|
|
|
echo "TAG_SHA=false" >>$GITHUB_ENV
|
|
|
|
fi
|
|
|
|
# Handle latest and latest-custom using raw
|
|
|
|
if [[ ${{ env.TAG_SHA }} == "false" ]]; then
|
|
|
|
echo "TAG_LATEST=false" >>$GITHUB_ENV
|
|
|
|
echo "TAG_RAW=true" >>$GITHUB_ENV
|
|
|
|
if [[ -z "${{ env.TAG_SUFFIX }}" ]]; then
|
|
|
|
echo "TAG_RAW_VALUE=latest" >>$GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "TAG_RAW_VALUE=latest-{{ env.TAG_SUFFIX }}" >>$GITHUB_ENV
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "TAG_RAW=false" >>$GITHUB_ENV
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Docker - Download digests
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: actions/download-artifact@v4
|
2023-08-17 03:04:50 +00:00
|
|
|
with:
|
2024-01-29 18:12:07 +00:00
|
|
|
pattern: digests-*
|
|
|
|
merge-multiple: true
|
2023-08-17 03:04:50 +00:00
|
|
|
path: /tmp/digests
|
|
|
|
|
|
|
|
- name: Docker - Set up Buildx
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2023-08-17 03:04:50 +00:00
|
|
|
|
|
|
|
- name: Docker - Meta
|
|
|
|
id: meta
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: docker/metadata-action@v5
|
2023-08-17 03:04:50 +00:00
|
|
|
with:
|
|
|
|
images: ${{ env.DOCKER_REPO }}
|
|
|
|
flavor: |
|
|
|
|
latest=${{ env.TAG_LATEST }}
|
|
|
|
suffix=${{ env.TAG_SUFFIX }},onlatest=true
|
|
|
|
tags: |
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=raw,enable=${{ env.TAG_RAW }},value=latest
|
|
|
|
type=sha,enable=${{ env.TAG_SHA }}
|
|
|
|
|
|
|
|
- name: Docker - Login to Docker Hub
|
2024-01-29 15:21:52 +00:00
|
|
|
uses: docker/login-action@v3
|
2023-08-17 03:04:50 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Docker - Create manifest list and push
|
|
|
|
working-directory: /tmp/digests
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
|
|
|
$(printf '${{ env.DOCKER_REPO }}@sha256:%s ' *)
|
|
|
|
|
|
|
|
- name: Docker - Inspect image
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect ${{ env.DOCKER_REPO }}:${{ steps.meta.outputs.version }}
|
2023-11-27 11:32:13 +00:00
|
|
|
|
|
|
|
|
2024-12-04 11:52:51 +00:00
|
|
|
# Compute Tests inputs
|
2023-11-27 11:32:13 +00:00
|
|
|
compute-tests-inputs:
|
2024-12-04 11:52:51 +00:00
|
|
|
name: Compute Tests inputs
|
|
|
|
if: ${{ inputs.continuous_tests_list != '' || inputs.run_release_tests == 'true' }}
|
2023-11-27 11:32:13 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: publish
|
|
|
|
outputs:
|
|
|
|
source: ${{ steps.compute.outputs.source }}
|
2024-12-04 11:52:51 +00:00
|
|
|
branch: ${{ env.TESTS_BRANCH }}
|
|
|
|
workflow_source: ${{ env.TESTS_SOURCE }}
|
2023-11-27 11:32:13 +00:00
|
|
|
codexdockerimage: ${{ steps.compute.outputs.codexdockerimage }}
|
2024-12-04 11:52:51 +00:00
|
|
|
steps:
|
|
|
|
- name: Compute Tests inputs
|
|
|
|
id: compute
|
|
|
|
run: |
|
|
|
|
echo "source=${{ format('{0}/{1}', github.server_url, env.TESTS_SOURCE) }}" >> "$GITHUB_OUTPUT"
|
|
|
|
echo "codexdockerimage=${{ inputs.docker_repo }}:${{ needs.publish.outputs.version }}" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
|
|
|
|
# Compute Continuous Tests inputs
|
|
|
|
compute-continuous-tests-inputs:
|
|
|
|
name: Compute Continuous Tests inputs
|
|
|
|
if: ${{ inputs.continuous_tests_list != '' && github.ref_name == github.event.repository.default_branch }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: compute-tests-inputs
|
|
|
|
outputs:
|
2023-11-27 11:32:13 +00:00
|
|
|
nameprefix: ${{ steps.compute.outputs.nameprefix }}
|
|
|
|
continuous_tests_list: ${{ steps.compute.outputs.continuous_tests_list }}
|
2024-12-04 11:52:51 +00:00
|
|
|
continuous_tests_duration: ${{ env.CONTINUOUS_TESTS_DURATION }}
|
2023-11-27 11:32:13 +00:00
|
|
|
continuous_tests_workflow: ${{ steps.compute.outputs.continuous_tests_workflow }}
|
|
|
|
steps:
|
2024-12-04 11:52:51 +00:00
|
|
|
- name: Compute Continuous Tests inputs
|
2023-11-27 11:32:13 +00:00
|
|
|
id: compute
|
|
|
|
run: |
|
|
|
|
echo "nameprefix=$(awk '{ print tolower($0) }' <<< ${{ env.CONTINUOUS_TESTS_NAMEPREFIX }})" >> "$GITHUB_OUTPUT"
|
|
|
|
echo "continuous_tests_list=$(jq -cR 'split(" ")' <<< '${{ env.CONTINUOUS_TESTS_LIST }}')" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
|
|
|
|
# Run Continuous Tests
|
2024-12-04 11:52:51 +00:00
|
|
|
run-continuous-tests:
|
2023-11-27 11:32:13 +00:00
|
|
|
name: Run Continuous Tests
|
2024-12-04 11:52:51 +00:00
|
|
|
needs: [compute-tests-inputs, compute-continuous-tests-inputs]
|
2023-11-27 11:32:13 +00:00
|
|
|
strategy:
|
|
|
|
max-parallel: 1
|
|
|
|
matrix:
|
2024-12-04 11:52:51 +00:00
|
|
|
tests: ${{ fromJSON(needs.compute-continuous-tests-inputs.outputs.continuous_tests_list) }}
|
2023-12-19 06:47:23 +00:00
|
|
|
uses: codex-storage/cs-codex-dist-tests/.github/workflows/run-continuous-tests.yaml@master
|
2023-11-27 11:32:13 +00:00
|
|
|
with:
|
|
|
|
source: ${{ needs.compute-tests-inputs.outputs.source }}
|
|
|
|
branch: ${{ needs.compute-tests-inputs.outputs.branch }}
|
|
|
|
codexdockerimage: ${{ needs.compute-tests-inputs.outputs.codexdockerimage }}
|
2024-12-04 11:52:51 +00:00
|
|
|
nameprefix: ${{ needs.compute-continuous-tests-inputs.outputs.nameprefix }}-${{ matrix.tests }}-${{ needs.compute-continuous-tests-inputs.outputs.continuous_tests_duration }}
|
2023-11-27 11:32:13 +00:00
|
|
|
tests_filter: ${{ matrix.tests }}
|
|
|
|
tests_target_duration: ${{ needs.compute-tests-inputs.outputs.continuous_tests_duration }}
|
|
|
|
workflow_source: ${{ needs.compute-tests-inputs.outputs.workflow_source }}
|
|
|
|
secrets: inherit
|
2024-12-04 11:52:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Run Release Tests
|
|
|
|
run-release-tests:
|
|
|
|
name: Run Release Tests
|
|
|
|
needs: [compute-tests-inputs]
|
|
|
|
if: ${{ inputs.run_release_tests == 'true' }}
|
|
|
|
uses: codex-storage/cs-codex-dist-tests/.github/workflows/run-release-tests.yaml@master
|
|
|
|
with:
|
|
|
|
source: ${{ needs.compute-tests-inputs.outputs.source }}
|
|
|
|
branch: ${{ needs.compute-tests-inputs.outputs.branch }}
|
|
|
|
codexdockerimage: ${{ needs.compute-tests-inputs.outputs.codexdockerimage }}
|
|
|
|
workflow_source: ${{ needs.compute-tests-inputs.outputs.workflow_source }}
|
|
|
|
secrets: inherit
|