feature/gcp ci #9323
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
name: RPM Build and Test | |
env: | |
# TODO: we really need to define a list of supported versions (ideally it's no more than 2) | |
# build is done on the lowest version and test on the highest with a "sanity test" | |
# stage done on all versions in the list except the highest | |
EL8_VERSION: 8 | |
EL9_VERSION: 9 | |
DEBIAN_VERSION: 12 | |
UBUNTU_VERSION: 22.04 | |
on: | |
workflow_dispatch: | |
inputs: | |
pr-repos: | |
description: 'Any PR-repos that you want included in this build' | |
required: false | |
pull_request: | |
concurrency: | |
group: rpm-build-and-test-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash --noprofile --norc -ueo pipefail {0} | |
permissions: {} | |
jobs: | |
# it's a real shame that this step is even needed. push events have the commit message # in | |
# ${{ github.event.head_commit.message }} but pull_requests don't. :-( | |
Import-commit-message: | |
name: Get commit message | |
if: github.repository == 'daos-stack/daos' | |
runs-on: [self-hosted, light] | |
# Map a step output to a job output | |
outputs: | |
message: ${{ steps.commit_message.outputs.text }} | |
dequoted_message: ${{ steps.dequoted_commit_message.outputs.text }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Import Commit Message | |
id: commit_message | |
run: echo "text<<EOF" >> $GITHUB_OUTPUT; | |
git show -s --format=%B >> $GITHUB_OUTPUT; | |
echo "EOF" >> $GITHUB_OUTPUT; | |
- name: Import and Dequote Commit Message | |
id: dequoted_commit_message | |
run: . ci/gha_functions.sh; | |
echo "text<<EOF" >> $GITHUB_OUTPUT; | |
git show -s --format=%B | escape_single_quotes >> $GITHUB_OUTPUT; | |
echo "EOF" >> $GITHUB_OUTPUT; | |
- name: Identify Commit Pragmas | |
run: . ci/gha_functions.sh; | |
echo '${{steps.dequoted_commit_message.outputs.text }}' | get_commit_pragmas | |
Import-commit-pragmas: | |
name: Make commit pragma variables | |
runs-on: [self-hosted, light] | |
needs: [Import-commit-message] | |
# can't use matrixes for matrixed output yet | |
# https://github.com/actions/runner/pull/2477 | |
outputs: | |
rpm-test-version: ${{ steps.rpm-test-version.outputs.value }} | |
pr-repos: ${{ steps.pr-repos.outputs.value }} | |
run-gha: ${{ steps.run-gha.outputs.value }} | |
steps: | |
- name: Set rpm-test-version variable | |
id: rpm-test-version | |
uses: ./.github/actions/variable-from-pragma | |
with: | |
commit_message: ${{ needs.Import-commit-message.outputs.dequoted_message }} | |
pragma: RPM_TEST_VERSION | |
- name: Set pr-repos variable | |
id: pr-repos | |
uses: ./.github/actions/variable-from-pragma | |
with: | |
commit_message: ${{ needs.Import-commit-message.outputs.dequoted_message }} | |
pragma: PR_REPOS | |
- name: Set run-gha variable | |
id: run-gha | |
uses: ./.github/actions/variable-from-pragma | |
with: | |
commit_message: ${{ needs.Import-commit-message.outputs.dequoted_message }} | |
pragma: RUN_GHA | |
default: false | |
Create-symlinks: | |
# you might think this is an odd place to do this and it should be done as a result of the | |
# build and/or testing stages and ideally you'd be right. | |
# the problem with that is that there is no way to get the success/fail result of individual | |
# axes of matrix jobs so there is no way to query them at the end and see their composite | |
# results. | |
# instead, the final result of the Build-RPM job, for example is a last-one-complete wins. | |
# so for example, if the el9 axis fails quickly and then the el8 axis succeeds afterward the | |
# resulting job state is success. | |
# instead we assume success at the beginning and then let any axis that fails remove the | |
# lastSuccessfulBuild link if it fails | |
name: Create lastBuild and lastSuccessfulBuild symlinks | |
runs-on: [self-hosted, light] | |
needs: [Import-commit-pragmas] | |
if: needs.Import-commit-pragmas.outputs.run-gha == 'true' && | |
needs.Import-commit-pragmas.outputs.rpm-test-version == '' && | |
!contains(needs.Import-commit-pragmas.outputs.pr-repos, 'daos@') | |
env: | |
# TODO -- this should be on stable, backedup storage, not /scratch | |
# yamllint disable-line rule:line-length | |
REPO_PATH: /scratch/job_repos/daos-stack/job/daos/job/PR-${{ github.event.pull_request.number }}/ | |
steps: | |
- name: Create lastBuild and lastSuccessfulBuild symlinks | |
run: . ci/gha_functions.sh; | |
mkdir -p ${REPO_PATH}; | |
rm -f ${REPO_PATH}last{,Successful}Build; | |
ln -s ${{ github.run_number }} ${REPO_PATH}lastBuild; | |
ln -s ${{ github.run_number }} ${REPO_PATH}lastSuccessfulBuild | |
Calc-rpm-build-matrix: | |
name: Calculate RPM Build Matrix | |
runs-on: [self-hosted, gcp] | |
needs: [Import-commit-pragmas, Create-symlinks] | |
outputs: | |
matrix: ${{ steps.matrix.outputs.text }} | |
steps: | |
- name: Import commit pragmas | |
uses: ./.github/actions/import-commit-pragmas | |
- name: Calculate RPM Build Matrix | |
id: matrix | |
run: | # do not use the non-| format for this script | |
l=() | |
trap 'echo "text=[$(IFS=","; echo "${l[*]}")]" >> $GITHUB_OUTPUT' EXIT | |
if ${CP_SKIP_BUILD:-false}; then | |
exit 0 | |
fi | |
if ! ${CP_SKIP_BUILD_EL8_RPM:-false}; then | |
l+=('"el8"') | |
fi | |
if ! ${CP_SKIP_BUILD_EL9_RPM:-false}; then | |
l+=('"el9"') | |
fi | |
if ! ${CP_SKIP_BUILD_DEB12_RPM:-false}; then | |
l+=('"deb12"') | |
fi | |
if ! ${CP_SKIP_BUILD_UBUNTU22_RPM:-false}; then | |
l+=('"ubuntu22"') | |
fi | |
Build-RPM: | |
name: Build RPM | |
permissions: | |
statuses: write | |
runs-on: [self-hosted, gcp] | |
needs: [Create-symlinks, Import-commit-pragmas, Calc-rpm-build-matrix] | |
if: needs.Import-commit-pragmas.outputs.run-gha == 'true' && | |
needs.Create-symlinks.result == 'success' && | |
((!cancelled()) || success() || failure()) | |
strategy: | |
matrix: | |
distro: ${{ fromJSON(needs.Calc-rpm-build-matrix.outputs.matrix) }} | |
fail-fast: false | |
steps: | |
- name: Import commit pragmas | |
uses: ./.github/actions/import-commit-pragmas | |
- name: Set variables | |
run: | | |
GO_BUILDER="" | |
case ${{ matrix.distro }} in | |
'el8') | |
DOCKERFILE="utils/docker/gcp/client/el/Dockerfile" | |
BASE_IMAGE_BUILDER="rockylinux/rockylinux:${{ env.EL8_VERSION }}" | |
DISTRO_NAME="EL" | |
DISTRO_VERSION="${{ env.EL8_VERSION }}" | |
;; | |
'el9') | |
DOCKERFILE="utils/docker/gcp/client/el/Dockerfile" | |
BASE_IMAGE_BUILDER="rockylinux/rockylinux:${{ env.EL9_VERSION }}" | |
DISTRO_NAME="EL" | |
DISTRO_VERSION="${{ env.EL9_VERSION }}" | |
;; | |
'deb12') | |
DOCKERFILE="utils/docker/gcp/client/deb/Dockerfile" | |
BASE_IMAGE_BUILDER="debian:${{ env.DEBIAN_VERSION }}" | |
GO_BUILDER="google-go.pkg.dev/golang:1.22.4" | |
DISTRO_NAME="DEBIAN" | |
DISTRO_VERSION="${{ env.DEBIAN_VERSION }}" | |
;; | |
'ubuntu22') | |
DOCKERFILE="utils/docker/gcp/client/deb/Dockerfile" | |
BASE_IMAGE_BUILDER="ubuntu:${{ env.UBUNTU_VERSION }}" | |
GO_BUILDER="google-go.pkg.dev/golang:1.22.4" | |
DISTRO_NAME="DEBIAN" | |
DISTRO_VERSION="${{ env.UBUNTU_VERSION }}" | |
;; | |
esac | |
echo "DOCKERFILE=$DOCKERFILE" >> $GITHUB_ENV | |
echo "BASE_IMAGE_BUILDER=$BASE_IMAGE_BUILDER" >> $GITHUB_ENV | |
echo "GO_BUILDER=$GO_BUILDER" >> $GITHUB_ENV | |
echo "DISTRO_NAME=$DISTRO_NAME" >> $GITHUB_ENV | |
echo "DISTRO_VERSION=$DISTRO_VERSION" >> $GITHUB_ENV | |
echo "STAGE_NAME=Build RPM on $DISTRO_NAME $DISTRO_VERSION" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Remove Dockerignore file | |
# necessary because our Dockerfile assumes /daos is our build context | |
# but the .dockerignore file ignores many files we need in our RPM | |
id: rm-docker-ignore | |
run: rm -f .dockerignore | |
- name: Build RPM | |
id: build-rpm | |
continue-on-error: true | |
# yamllint disable rule:line-length | |
run: sudo docker build . --file "${DOCKERFILE}" | |
--build-arg BASE_IMAGE_BUILDER="${BASE_IMAGE_BUILDER}" | |
--build-arg GO_BUILDER="${GO_BUILDER}" | |
--build-arg DAOS_BUILD_TYPE=release | |
--build-arg DAOS_SRC_DIR="." | |
--tag gha-amd-${{github.run_id}}-${{github.run_attempt}} | |
- name: Remove lastSuccessfulBuild link and exit failure | |
if: steps.build-rpm.outcome != 'success' | |
run: rm -f ${REPO_PATH}lastSuccessfulBuild; | |
exit 1 | |
- name: Restore Dockerignore file | |
id: restore-docker-ignore | |
run: git restore .dockerignore |