From 6eba744c9ef3b82765f59fd43bfa9315f7530b2d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 16 Jan 2025 07:52:52 +0000 Subject: [PATCH] First pass at adding CI --- .github/workflows/pr.yaml | 12 ++++++++++-- .pre-commit-config.yaml | 5 +++++ ci/check_style.sh | 28 ++++++++++++++++++++++++++++ dependencies.yaml | 18 ++++++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100755 ci/check_style.sh create mode 100644 dependencies.yaml diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index d37f253..10c55f8 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -13,5 +13,13 @@ jobs: container: image: rapidsai/ci-conda:latest steps: - - name: Test workflow existence - run: echo "Workflow exists" + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-0|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Run ci/check_style.sh + run: ci/check_style.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bc1f145..4abe859 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,3 +59,8 @@ repos: - id: codespell additional_dependencies: [tomli] args: ["--toml", "pyproject.toml"] + - repo: https://github.com/rapidsai/dependency-file-generator + rev: v1.16.0 + hooks: + - id: rapids-dependency-file-generator + args: ["--clean"] diff --git a/ci/check_style.sh b/ci/check_style.sh new file mode 100755 index 0000000..08ec248 --- /dev/null +++ b/ci/check_style.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Copyright (c) 2025, NVIDIA CORPORATION. + +set -euo pipefail + +rapids-logger "Create checks conda environment" +. /opt/conda/etc/profile.d/conda.sh + +ENV_YAML_DIR="$(mktemp -d)" + +rapids-dependency-file-generator \ + --output conda \ + --file-key checks \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee "${ENV_YAML_DIR}/env.yaml" + +rapids-mamba-retry env create --yes -f "${ENV_YAML_DIR}/env.yaml" -n checks +conda activate checks + +# TODO: Figure out the long-term plan here since the VERSION file should probably go. +RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" + +FORMAT_FILE_URL="https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_MAJOR_MINOR}/cmake-format-rapids-cmake.json" +export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json +mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) +wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} + +# Run pre-commit checks +pre-commit run --all-files --show-diff-on-failure diff --git a/dependencies.yaml b/dependencies.yaml new file mode 100644 index 0000000..735d9b2 --- /dev/null +++ b/dependencies.yaml @@ -0,0 +1,18 @@ +# Dependency list for https://github.com/rapidsai/dependency-file-generator +files: + checks: + output: none + includes: + - develop +channels: + - conda-forge +dependencies: + develop: + common: + - output_types: [conda, requirements] + packages: + - pre-commit + # pre-commit requires identify minimum version 1.0, but clang-format requires textproto support and that was + # added in 2.5.20, so we need to call out the minimum version needed for our plugins + - identify>=2.5.20 + - python>=3.10