Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8724c6e
first pass version of testing out matix on gitlab pipeline
Mar 17, 2025
91a3076
sharing the docker compose file for sandboxed GitLab
Mar 17, 2025
9bc9f78
first working create job - stubbed run
Mar 18, 2025
67deb8d
using fixed list of cases in matrix and using create_experment with c…
Mar 18, 2025
a7482fa
added mech to skip cases in gitlab pipeline per host
Mar 18, 2025
7c1c2c4
couple of small changes
Mar 18, 2025
ed34030
added skip rule in run tests
Mar 18, 2025
cb4c11e
updated run-check to optionally run over all the cases in the RUNTEST…
TerrenceMcGuinness-NOAA Mar 18, 2025
a774538
added switch to run-check_ci to so all available pslots
TerrenceMcGuinness-NOAA Mar 18, 2025
19d83bb
Merge branch 'NOAA-EMC:develop' into feature/ci_nightly
TerrenceMcGuinness-NOAA Mar 18, 2025
44277b1
some helper scrpts for starting and testing runners
TerrenceMcGuinness-NOAA Mar 18, 2025
0d9f781
some helper scrpts for starting and testing runners 2
TerrenceMcGuinness-NOAA Mar 18, 2025
a02c606
had to update args to gitlab-runner register
TerrenceMcGuinness-NOAA Mar 18, 2025
8b12ecd
added correct stage list
TerrenceMcGuinness-NOAA Mar 19, 2025
cb11c59
making progress with GaeaC6 connection
TerrenceMcGuinness-NOAA Mar 19, 2025
827a486
added all that is needed to download and register gitlab runner and m…
TerrenceMcGuinness-NOAA Mar 19, 2025
d1df187
added HOMEgfs to pipline
TerrenceMcGuinness-NOAA Mar 19, 2025
007c096
Merge branch 'NOAA-EMC:develop' into feature/ci_nightly
TerrenceMcGuinness-NOAA Mar 20, 2025
df3c04e
using the same build dir between jobs
TerrenceMcGuinness-NOAA Mar 20, 2025
a1de1d2
fix workspace between jobs
TerrenceMcGuinness-NOAA Mar 20, 2025
0d244a8
moved gitlab_runner start script into ci/scripts/utils and beefed it …
TerrenceMcGuinness-NOAA Mar 20, 2025
44b6535
renamed gitlab runner launch script
Mar 18, 2025
717cf22
hard coded skip hosts for Gaea C6 and increased timeouts
TerrenceMcGuinness-NOAA Mar 22, 2025
b9c15c4
Merge branch 'NOAA-EMC:develop' into feature/ci_nightly
TerrenceMcGuinness-NOAA Mar 22, 2025
490de9b
added concurrancy to gitlab launcher
TerrenceMcGuinness-NOAA Mar 22, 2025
0dce55a
debugged inplace gitlat runner launch script
TerrenceMcGuinness-NOAA Mar 22, 2025
64574f5
deleted work temp files
TerrenceMcGuinness-NOAA Mar 22, 2025
2e8e502
reverting to org run-check ci script
TerrenceMcGuinness-NOAA Mar 22, 2025
6d2c075
synced submodules
TerrenceMcGuinness-NOAA Mar 22, 2025
114bdcf
Merge branch 'NOAA-EMC:develop' into feature/ci_nightly
TerrenceMcGuinness-NOAA Mar 24, 2025
bfc9c90
add inline bash documentation to explain the specifics for starting a…
Mar 24, 2025
cd41351
Merge branch 'develop' into feature/ci_nightly
TerrenceMcGuinness-NOAA Mar 24, 2025
c8a5b02
changed BUILD tag on name of dir for build to today instead of friday
Mar 24, 2025
081984d
needed to add export to added values in config file for Gaea C6
Mar 24, 2025
5d4826b
added double quote shell norms
Mar 24, 2025
cf8188f
added double quote shell norms 2
Mar 24, 2025
7298094
couple of more shell norms
Mar 24, 2025
3b4d04f
couple of last missed shell norms had to add DATE for date
Mar 24, 2025
4031d63
add CI to GITLAB_BUILDS_DIR to match GitLab reserved varible names to…
TerrenceMcGuinness-NOAA Mar 25, 2025
8b39060
pared down comments in config.gaeac6
TerrenceMcGuinness-NOAA Mar 25, 2025
d13f2b6
cleaned up comments in gitlab runner launch script
TerrenceMcGuinness-NOAA Mar 25, 2025
29173d9
Merge branch 'NOAA-EMC:develop' into feature/ci_nightly
TerrenceMcGuinness-NOAA Mar 25, 2025
5a53547
fixed nohup command for gitlab runner laucnch script
Mar 25, 2025
a33d5a8
fix setting of working-directory where runner is launched
TerrenceMcGuinness-NOAA Mar 25, 2025
c03ba5e
clean up pipeline scipt with some minor comments for the three main s…
TerrenceMcGuinness-NOAA Mar 25, 2025
4caa443
moved BUILD identifier TODAY as a dir level and put RUNTESTS under it…
TerrenceMcGuinness-NOAA Mar 25, 2025
71cefaa
needed to export RUNTESTS top point to where to create EXPDIRs
TerrenceMcGuinness-NOAA Mar 25, 2025
1ce0901
Update config.gaeac6
TerrenceMcGuinness-NOAA Mar 25, 2025
5b5a0c1
moved GFS_CI_ROOT on Geae C6 to precip3 proj-shared
TerrenceMcGuinness-NOAA Mar 26, 2025
77cab05
Merge branch 'NOAA-EMC:develop' into feature/ci_nightly
TerrenceMcGuinness-NOAA Mar 26, 2025
9be18a2
Merge branch 'develop' into feature/ci_nightly
TerrenceMcGuinness-NOAA Mar 28, 2025
c0440ec
Update ci/scripts/utils/launch_gitlab_runner.sh
TerrenceMcGuinness-NOAA Mar 28, 2025
3ca0f40
Update ci/scripts/utils/launch_gitlab_runner.sh
TerrenceMcGuinness-NOAA Mar 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions ci/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
stages:
- build
- create_experiments
- run_tests

# Global variables
variables:
BUILD: 'TODAY'
GIT_CLONE_PATH: '$CI_BUILDS_DIR/${BUILD}/global-workflow'
HOMEGFS: $GIT_CLONE_PATH
RUNTESTS_DIR: $CI_BUILDS_DIR/${BUILD}/RUNTESTS
GIT_DEPTH: 1
RUNNER_SCRIPT_TIMEOUT: 6h
RUNNER_AFTER_SCRIPT_TIMEOUT: 6h


# Build stage for the global workflow on compute nodes
build:
variables:
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
stage: build
script:
- echo "Using build directory ${HOMEGFS} (dated ${BUILD_DATE})"
- ci/scripts/utils/ci_utils_wrapper.sh build_compute
- sorc/link_workflow.sh
- mkdir -p ${RUNTESTS_DIR}
# TODO - Add more machines to the list and make
# the setup and run_tests stages 2D matrices
parallel:
matrix:
- MACHINE: ["gaeac6"]
tags:
- ${MACHINE}


# Create experiments stage from a fixed list of cases in $HOMEGFS/ci/cases/pr
# TODO: Find a way to dynamically generate the list of cases (maybe using Jinja2)
setup_experiments:
variables:
GIT_STRATEGY: none
stage: create_experiments
script:
- export RUNTESTS=${RUNTESTS_DIR}
- ${HOMEGFS}/ci/scripts/utils/ci_utils_wrapper.sh create_experiment ${HOMEGFS}/ci/cases/pr/${caseName}.yaml
parallel:
matrix:
- caseName: ["C48_ATM", "C48mx500_3DVarAOWCDA", "C48mx500_hybAOWCDA", "C48_S2SWA_gefs", "C48_S2SW", "C96_atm3DVar", "C96C48_hybatmDA", "C96C48_hybatmaerosnowDA"]
tags:
- gaeac6
dependencies:
- build

# Running the list of experiments created in the previous stage
# using the run-check_ci.sh script from $HOMEgfs/ci/scripts directory
run_tests:
variables:
GIT_STRATEGY: none
stage: run_tests
script:
- echo "Using build directory ${HOMEGFS} (dated ${BUILD_DATE})"
- pslot=$(${HOMEGFS}/ci/scripts/utils/ci_utils_wrapper.sh get_pslot ${RUNTESTS_DIR} ${caseName})
- ${HOMEGFS}/ci/scripts/run-check_ci.sh ${CI_BUILDS_DIR}/${BUILD} ${pslot} global-workflow
parallel:
matrix:
- caseName: ["C48_ATM", "C48mx500_3DVarAOWCDA", "C48mx500_hybAOWCDA", "C48_S2SWA_gefs", "C48_S2SW", "C96_atm3DVar", "C96C48_hybatmDA", "C96C48_hybatmaerosnowDA"]
tags:
- gaeac6
dependencies:
- setup_experiments
66 changes: 53 additions & 13 deletions ci/platforms/config.gaeac6
Original file line number Diff line number Diff line change
@@ -1,24 +1,64 @@
#!/usr/bin/bash

# Main CI root directory
export GFS_CI_ROOT=/ncrc/proj/nggps_emc/${USER}/GFS_CI_CD
# ICSDIR root directory used on the create_experment.py command line
#########################################################################
# config.gaeac6 - Platform-specific configuration for Gaea C6
#
# This file contains environment variables used by CI/CD scripts,
# directories, and settings specific to the Gaea C6 platform.
#########################################################################

# Main CI root directory - Base directory for all CI/CD operations
export GFS_CI_ROOT="/gpfs/f6/drsa-precip3/proj-shared/${USER}/GFS_CI_CD"

# ICSDIR root directory - Contains initial condition data
# Used by create_experiment.py for setting up test cases
export ICSDIR_ROOT=/gpfs/f6/drsa-precip3/world-shared/role.glopara/data/ICSDIR

# JENKINS launch directory for agent
export JENKINS_AGENT_LAUNCH_DIR=${GFS_CI_ROOT}/Jenkins/agent
#########################################################################
# Jenkins configuration settings
#########################################################################

# JENKINS launch directory for agent - Where Jenkins agents are launched from
export JENKINS_AGENT_LAUNCH_DIR="${GFS_CI_ROOT}/Jenkins/agent"

# JENKINS internal working directories for CI jobs (not for users use)
export JENKINS_WORK_DIR=${GFS_CI_ROOT}/Jenkins/workspace
# Where Jenkins stores temporary files during CI job execution
export JENKINS_WORK_DIR="${GFS_CI_ROOT}/Jenkins/workspace"

# NOTE: JENKINS custom_workspace directory where CI jobs are run
# /gpfs/f6/drsa-precip3/proj-shared/global/CI
# is defined in the Jenkinsfile
# and is defined in $HOMEgfs/ci/Jenkinsfile


#########################################################################
# GitLab CI configuration
# These variables are referenced directly by launch_gitlab_runner.sh
#########################################################################

# CTest functional test directories for pre stagged input data
export STAGED_TESTS_DIR=${GFS_CI_ROOT}/STAGED_TESTS_DIR
# Used in the 'register' step of launch_gitlab_runner.sh for --url parameter
export GITLAB_URL=https://vlab.noaa.gov/gitlab-licensed

# CI BASH test directories
export GFS_BASH_CI_ROOT=${GFS_CI_ROOT}/GFS_BASH_CI
# Directory for GitLab builds
# Used in launch_gitlab_runner.sh for location of builds
export GITLAB_CI_BUILDS_DIR=/gpfs/f6/drsa-precip3/scratch/role.glopara/GFS_CI_ROOT/GITLAB/CI

# Directory for GitLab runner used by launch_gitlab_runner.sh
export GITLAB_RUNNER_DIR="${GFS_CI_ROOT}/GitLab/Runner"


#########################################################################
# CI CRON system configuration
#########################################################################
export GFS_BASH_CI_ROOT="${GFS_CI_ROOT}/GFS_BASH_CI"
export max_concurrent_cases=5 # number of concurrent cases that can run simultaneously
export max_concurrent_pr=4 # number of concurrent pull requests


#########################################################################
# CTest functional test directories for pre-staged input data
#########################################################################
export STAGED_TESTS_DIR="${GFS_CI_ROOT}/STAGED_TESTS_DIR"

# HPC account information - For job submission
export HPC_ACCOUNT=drsa-precip3
export max_concurrent_cases=5
export max_concurrent_pr=4

123 changes: 123 additions & 0 deletions ci/scripts/utils/launch_gitlab_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env bash

set -e

#########################################################################
# launch_gitlab_runner.sh - Script to manage GitLab runners for CI/CD
#
# This script handles three main operations for GitLab runners:
# 1. register - Registers a new GitLab runner with the GitLab server
# 2. run - Starts a GitLab runner in the background
# 3. unregister - Removes a GitLab runner from the GitLab server
#
# Usage: ./launch_gitlab_runner.sh [register|run|unregister] [token]
#########################################################################

# Set the HOMEGFS_ variable to the root directory of the global workflow
HOMEGFS_="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." >/dev/null 2>&1 && pwd )"
# Get the hostname of the current machine
host="$(hostname)"

#########################################################################
# Set up runtime environment variables for accounts on supported machines
#########################################################################

# Source the detect_machine.sh script to determine the MACHINE_ID
source "${HOMEGFS_}/ush/detect_machine.sh"
# Check the MACHINE_ID and set up the environment accordingly
case "${MACHINE_ID}" in
hera | orion | hercules | wcoss2 | gaeac5 | gaeac6 )
echo "Launching GitLab Runner on ${MACHINE_ID}";;
noaacloud )
echo "Launching GitLab Runner on ${PW_CSP}";;
*)
echo "Unsupported platform. Exiting with error."
exit 1;;
esac

# Source the platform-specific configuration file
# This file contains platform-specific variables such as GITLAB_URL, GITLAB_CI_BUILDS_DIR,
# and GITLAB_RUNNER_DIR which are required for runner registration and execution
source "${HOMEGFS_}/ci/platforms/config.${MACHINE_ID}"

# Change to the GitLab runner directory defined in the platform config
cd "${GITLAB_RUNNER_DIR}" || exit 1

# Set the log file name with the current date and time
DATE=$(date +%Y%m%d%M) || true
GITLAB_LOG="${PWD}/launched_gitlab_runner-${DATE}.log"
rm -f "${GITLAB_LOG}"

#########################################################################
# GitLab Token Handling
# The token is used to authenticate the runner with the GitLab server
#########################################################################

# Get the GitLab runner token from:
# 1. The second command-line argument
# 2. The GITLAB_RUNNER_TOKEN environment variable
# 3. A gitlab_token file in the current directory
GITLAB_RUNNER_TOKEN="${2:-${GITLAB_RUNNER_TOKEN}}"
if [[ -z "${GITLAB_RUNNER_TOKEN}" ]]; then
if [[ -f gitlab_token ]]; then
source gitlab_token
fi
fi
if [[ -z "${GITLAB_RUNNER_TOKEN}" ]]; then
echo "ERROR: GITLAB_RUNNER_TOKEN not set"
exit 1
fi

# Download the GitLab runner binary if it does not exist
if [[ ! -f gitlab-runner ]]; then
curl -L --output "${PWD}/gitlab-runner" https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
chmod +x ./gitlab-runner
fi

#########################################################################
# REGISTER argument handling
# Registers a new GitLab runner with the GitLab server
#########################################################################

if [[ "${1}" == "register" ]]; then

echo "Registering GitLab Runner ${MACHINE_ID} on host ${host} at ${DATE}" >> "${GITLAB_LOG}"
echo "with runner name: ${GITLAB_RUNNER_NAME}" >> "${GITLAB_LOG}"
# Register the GitLab runner with the following parameters:
# -n: Run in non-interactive mode
# -t: Registration token from GitLab
# --url: URL of the GitLab server (from config.MACHINE_ID)
# --executor: Type of executor (shell in this case)
# --builds-dir: Directory where builds will be stored (from config.MACHINE_ID)
# --custom_build_dir-enabled: Enable custom build directories
# --request-concurrency: Number of concurrent requests that can be handled
./gitlab-runner register -n -t "${GITLAB_RUNNER_TOKEN}" --url "${GITLAB_URL}" --executor shell --shell bash --builds-dir "${GITLAB_CI_BUILDS_DIR}" --custom_build_dir-enabled true --request-concurrency 24

# Set the concurrent job limit in the GitLab runner config file
sed -i 's/concurrent.*/concurrent = 24/' ~/.gitlab-runner/config.toml
exit 0
fi

#########################################################################
# RUN: Starts a GitLab runner in the background
#########################################################################

if [[ "${1}" == "run" ]]; then
# --working-directory: Directory where the runner is launched and keeps its working files (from config.$MACHINE_ID)
# do not confuse this with GitLabs CI_BUILDS_DIR which is designate by GFS_CI_BUILDS_DIR and is where the builds are stored
COMMAND="nohup ./gitlab-runner run --working-directory ${GITLAB_RUNNER_DIR}"
echo -e "Running gitlab-runner with the command:\n${COMMAND}\nsee log ${GITLAB_LOG}"
echo -e "Running gitlab-runner with the command:${COMMAND}" >& "${GITLAB_LOG}"
${COMMAND} >> "${GITLAB_LOG}" 2>&1 &
cat "${GITLAB_LOG}"
exit 0
fi

#########################################################################
# UNREGISTER: Removes a GitLab runner from the GitLab server
#########################################################################

if [[ "${1}" == "unregister" ]]; then
# Unregister the GitLab runner by name
./gitlab-runner unregister --name "${GITLAB_RUNNER_NAME}"
fi