run cuda build again...save container #1
Workflow file for this run
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: Build and Test Configuration | ||
on: | ||
workflow_call: | ||
inputs: | ||
BUILD_AND_TEST_CLI_ARGS: | ||
required: false | ||
type: string | ||
BUILD_TYPE: | ||
required: false | ||
type: string | ||
default: build | ||
CMAKE_BUILD_TYPE: | ||
required: true | ||
type: string | ||
DOCKER_IMAGE_TAG: | ||
required: true | ||
type: string | ||
DOCKER_REPOSITORY: | ||
required: true | ||
type: string | ||
DOCKER_RUN_ARGS: | ||
required: false | ||
type: string | ||
ENABLE_HYPRE: | ||
required: false | ||
type: string | ||
ENABLE_HYPRE_DEVICE: | ||
required: false | ||
type: string | ||
ENABLE_TRILINOS: | ||
required: false | ||
type: string | ||
GCP_BUCKET: | ||
required: false | ||
type: string | ||
HOST_CONFIG: | ||
required: false | ||
type: string | ||
RUNS_ON: | ||
required: true | ||
type: string | ||
USE_SCCACHE: | ||
required: false | ||
type: boolean | ||
default: true | ||
secrets: | ||
GOOGLE_CLOUD_GCP: | ||
required: false | ||
jobs: | ||
build_test_deploy: | ||
runs-on: ${{ inputs.RUNS_ON }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
lfs: ${{ inputs.BUILD_TYPE == 'integrated_tests' }} | ||
fetch-depth: 1 | ||
- id: 'auth' | ||
if: ${{ inputs.GCP_BUCKET || inputs.USE_SCCACHE }} | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
credentials_json: '${{ secrets.GOOGLE_CLOUD_GCP }}' | ||
create_credentials_file: true | ||
- name: 'Set up Cloud SDK' | ||
if: inputs.GCP_BUCKET | ||
uses: 'google-github-actions/setup-gcloud@v1' | ||
with: | ||
version: '>= 363.0.0' | ||
- name: Print environment | ||
run: printenv | ||
- name: Build, test, deploy. | ||
run: | | ||
# Those two bash arrays will be populated depending on the required options, | ||
# and expended as CLI arguments for the docker and scripts calls. | ||
docker_args=() | ||
script_args=() | ||
docker_args+=(${{ inputs.DOCKER_RUN_ARGS }}) | ||
COMMIT=${{ github.event.pull_request.head.sha }} | ||
SHORT_COMMIT=${COMMIT:0:7} | ||
script_args+=(--install-dir-basename GEOSX-${SHORT_COMMIT}) | ||
# All the data exchanged with the docker container is eventually meant to be send to the cloud. | ||
if [[ ! -z "${{ inputs.GCP_BUCKET }}" ]]; then | ||
if [ "${{ inputs.BUILD_TYPE }}" = "build" ]; then | ||
DATA_BASENAME=GEOSX-and-TPL-${SHORT_COMMIT}.tar.gz | ||
elif [ "${{ inputs.BUILD_TYPE }}" = "integrated_tests" ]; then | ||
DATA_BASENAME=integratedTests-pr${{ github.event.number }}-${{ github.run_number }}-${SHORT_COMMIT}.tar.gz | ||
script_args+=(--run-integrated-tests) | ||
fi | ||
script_args+=(--data-basename ${DATA_BASENAME}) | ||
DATA_EXCHANGE_DIR=/mnt/geos-exchange # Exchange folder outside of the container | ||
if [ ! -d "${DATA_EXCHANGE_DIR}" ]; then | ||
sudo mkdir -p ${DATA_EXCHANGE_DIR} | ||
fi | ||
DATA_EXCHANGE_MOUNT_POINT=/tmp/exchange # Exchange folder inside of the container | ||
docker_args+=(--volume=${DATA_EXCHANGE_DIR}:${DATA_EXCHANGE_MOUNT_POINT}) | ||
script_args+=(--exchange-dir ${DATA_EXCHANGE_MOUNT_POINT}) | ||
fi | ||
HOST_CONFIG=${{ inputs.HOST_CONFIG }} | ||
script_args+=(${HOST_CONFIG:+"--host-config ${HOST_CONFIG}"}) | ||
if ${{ inputs.USE_SCCACHE }} == 'true'; then | ||
script_args+=(--sccache-credentials $(basename ${GOOGLE_GHA_CREDS_PATH})) | ||
fi | ||
RUNNER_CERTIFICATES_DIR=/etc/pki/ca-trust/source/anchors/ | ||
mkdir -p ${GITHUB_WORKSPACE}/certificates | ||
cp ${RUNNER_CERTIFICATES_DIR}/*.crt* ${GITHUB_WORKSPACE}/certificates | ||
#/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt | ||
# We need to know where the code folder is mounted inside the container so we can run the script at the proper location! | ||
# Since this information is repeated twice, we use a variable. | ||
GITHUB_WORKSPACE_MOUNT_POINT=/tmp/geos | ||
docker_args+=(--volume=${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE_MOUNT_POINT}) | ||
script_args+=(--repository ${GITHUB_WORKSPACE_MOUNT_POINT}) | ||
# The linear algebra environment variables (ENABLE_HYPRE, ENABLE_HYPRE_DEVICE & ENABLE_TRILINOS) | ||
# could be passed as scripts parameters as well, but a specific care must be taken to be sure | ||
# there's no conflict with the host-config files. | ||
ENABLE_HYPRE=${{ inputs.ENABLE_HYPRE }} | ||
ENABLE_HYPRE_DEVICE=${{ inputs.ENABLE_HYPRE_DEVICE }} | ||
ENABLE_TRILINOS=${{ inputs.ENABLE_TRILINOS }} | ||
docker_args+=(-e ENABLE_HYPRE=${ENABLE_HYPRE:-OFF}) | ||
docker_args+=(-e ENABLE_HYPRE_DEVICE=${ENABLE_HYPRE_DEVICE:-CPU}) | ||
docker_args+=(-e ENABLE_TRILINOS=${ENABLE_TRILINOS:-ON}) | ||
docker_args+=(--cap-add=SYS_PTRACE) | ||
script_args+=(--cmake-build-type ${{ inputs.CMAKE_BUILD_TYPE }}) | ||
script_args+=(${{ inputs.BUILD_AND_TEST_CLI_ARGS }}) | ||
SPLIT_DOCKER_REPOSITORY=(${DOCKER_REPOSITORY//// }) | ||
CONTAINER_NAME=geosx_build_${SPLIT_DOCKER_REPOSITORY[1]}_${GITHUB_SHA:0:7} | ||
if [ "$(docker ps -aq -f name=${CONTAINER_NAME})" ]; then | ||
docker rm -f ${CONTAINER_NAME} | ||
fi | ||
docker_args+=(--name ${CONTAINER_NAME}) | ||
# In case of integrated tests run, we still want to send the results to the cloud for inspection. | ||
# While for standard build (if even possible), pushing a failed build would be pointless. | ||
# GHA set `-e` to bash scripts by default to fail asap, | ||
# but for this precise call, we want to deal with it more precisely | ||
set +e | ||
docker run \ | ||
${docker_args[@]} \ | ||
${{ inputs.DOCKER_REPOSITORY }}:${{ inputs.DOCKER_IMAGE_TAG }} \ | ||
${GITHUB_WORKSPACE_MOUNT_POINT}/scripts/ci_build_and_test_in_container.sh \ | ||
${script_args[@]} | ||
EXIT_STATUS=$? | ||
echo "Received exit status ${EXIT_STATUS} from the build process." | ||
set -e | ||
echo DATA_EXCHANGE_DIR = ${DATA_EXCHANGE_DIR} | ||
echo DATA_BASENAME = ${DATA_BASENAME} | ||
echo GCP_BUCKET = ${{inputs.GCP_BUCKET}} | ||
# Send to the bucket and print the download link when it makes sense. | ||
if [[ ! -z "${{ inputs.GCP_BUCKET }}" ]]; then | ||
if [[ "${{ inputs.BUILD_TYPE }}" = "integrated_tests" || ${EXIT_STATUS} -eq 0 ]]; then | ||
CLOUDSDK_PYTHON=python3 gsutil cp -a public-read ${DATA_EXCHANGE_DIR}/${DATA_BASENAME} gs://${{ inputs.GCP_BUCKET }}/ | ||
echo "Download the bundle at https://storage.googleapis.com/${{ inputs.GCP_BUCKET }}/${DATA_BASENAME}" | ||
fi | ||
fi | ||
# Remove the container and the workspace to avoid any conflict with the next run. | ||
echo github.workspace = ${{ github.workspace }} | ||
rm -rf ${{ github.workspace }}/* | ||
# docker rm -f ${CONTAINER_NAME} | ||
exit ${EXIT_STATUS} |