From aaaf0754554dde821ab5b11a01c1865901b32196 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 25 Jan 2026 20:58:00 +0100 Subject: [PATCH 1/5] Introduce MicroMamba --- .micromamba/dev.yaml | 14 ++++++ .micromamba/init.sh | 104 +++++++++++++++++++++++++++++++++++++++ .micromamba/uninstall.sh | 27 ++++++++++ 3 files changed, 145 insertions(+) create mode 100644 .micromamba/dev.yaml create mode 100644 .micromamba/init.sh create mode 100644 .micromamba/uninstall.sh diff --git a/.micromamba/dev.yaml b/.micromamba/dev.yaml new file mode 100644 index 00000000..49133464 --- /dev/null +++ b/.micromamba/dev.yaml @@ -0,0 +1,14 @@ +name: dev +channels: + - conda-forge +dependencies: + - python=3.11 + - pytest + - pylint + - pycodestyle + - buildifier + - clang + - clang-tools + - bazel=6 + - pip: + - codechecker==6.25 diff --git a/.micromamba/init.sh b/.micromamba/init.sh new file mode 100644 index 00000000..1380ab33 --- /dev/null +++ b/.micromamba/init.sh @@ -0,0 +1,104 @@ +# Make sure we source the script +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + echo "ERROR: This script must be 'sourced':" + echo " source ${0}" + exit 1 +fi + +# Parse arguments +unset VERBOSE +MAMBA_VERBOSITY="--quiet" +args=() +for arg in "$@"; do + if [[ "$arg" == "-v" ]]; then + VERBOSE=1 + elif [[ "$arg" == "-vv" ]]; then + VERBOSE=2 + MAMBA_VERBOSITY="" + else + args+=("${arg}") + fi +done +set -- "${args[@]}" +unset args + +# Logging function +function log() { + [[ -n "$VERBOSE" ]] && echo "[micromamba] $@" +} + +# Logging function +function info() { + echo "[micromamba] $@" +} + +# Get the environment name +log "Arguments: \"$@\"" +ENV_NAME="${1:-dev}" +log "Environment: $ENV_NAME" + +# Get the location of this script +THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +log "Location: $THIS_DIR" + +# Check if we have environment file +if [ ! -f $THIS_DIR/$ENV_NAME.yaml ]; then + info "ERROR: No environment file found: $THIS_DIR/$ENV_NAME.yaml" + return 1 +fi + +# Install micromamba if not installed +# See https://mamba.readthedocs.io +if [ ! -f $THIS_DIR/bin/micromamba ]; then + info "Installing to $THIS_DIR/bin ..." + pushd $THIS_DIR > /dev/null + curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba + popd > /dev/null +else + info "Using: $(ls $THIS_DIR/bin/micromamba)" +fi + +# Initialize shell with micromamba +export MAMBA_EXE="$THIS_DIR/bin/micromamba"; +export MAMBA_ROOT_PREFIX="$THIS_DIR/micromamba"; +eval "$($MAMBA_EXE shell hook --shell bash --root-prefix $MAMBA_ROOT_PREFIX)" +log "Micromamba:" +log "MAMBA_EXE=$MAMBA_EXE" +log "MAMBA_ROOT_PREFIX=$MAMBA_ROOT_PREFIX" +if [[ "$VERBOSE" -ge 2 ]]; then + micromamba info +fi + +# Create environment +info "Creating environment [$ENV_NAME]..." +micromamba create --file $THIS_DIR/$ENV_NAME.yaml --name $ENV_NAME --yes $MAMBA_VERBOSITY +# micromamba config set env_prompt "[{name}] " +micromamba activate $ENV_NAME + +# # Create environment +# info "Creating environment [$ENV_NAME]..." +# micromamba create --file $THIS_DIR/$ENV_NAME.yaml --prefix $THIS_DIR/$ENV_NAME --yes $MAMBA_VERBOSITY +# micromamba config set env_prompt "[{name}] " +# micromamba activate $THIS_DIR/$ENV_NAME + +# Print out tools information +if [[ -n "$VERBOSE" ]]; then + log "Tools:" + which python3 + which bazel + which CodeChecker + which pytest + which pylint + which pycodestyle + which buildifier + which clang + which clang-tidy + which diagtool + which clang-extdef-mapping +fi + +# Unset variables +unset ENV_NAME +unset THIS_DIR +unset MAMBA_VERBOSITY +info "To exit session run: micromamba deactivate" diff --git a/.micromamba/uninstall.sh b/.micromamba/uninstall.sh new file mode 100644 index 00000000..ad7a1d66 --- /dev/null +++ b/.micromamba/uninstall.sh @@ -0,0 +1,27 @@ +THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +MICROMAMBA=".micromamba" +if [[ "$(basename $THIS_DIR)" == "$MICROMAMBA" ]]; then + PROCESSES="bazel java python3 CodeChecke" + echo "Killing: $PROCESSES" + timeout 10s killall --quiet --wait $PROCESSES + killall --quiet -SIGKILL $PROCESSES + + echo "Removing micromamba from: $THIS_DIR" + rm -rf $THIS_DIR/bin + chmod -R +w $THIS_DIR/micromamba + rm -rf $THIS_DIR/micromamba + + # for directory in $THIS_DIR/*/; do + # if [[ -d "$directory" ]]; then + # echo "Removing: $directory" + # chmod -R +w $directory + # rm -rf $directory + # fi + # done + echo "Please exit current shell session" +else + echo "Error: wring location $THIS_DIR" + echo " $MICROMAMBA is not there" + exit 1 +fi From a82d8a8bcfdf3fb521e15892fdca219a55007123 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 25 Jan 2026 23:26:38 +0100 Subject: [PATCH 2/5] Add GitHub workflow --- .github/workflows/micromamba.yaml | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/micromamba.yaml diff --git a/.github/workflows/micromamba.yaml b/.github/workflows/micromamba.yaml new file mode 100644 index 00000000..96f57b85 --- /dev/null +++ b/.github/workflows/micromamba.yaml @@ -0,0 +1,45 @@ +# Copyright 2023 Ericsson AB +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: codechecker-bazel-micromamba-tests + +# Triggers the workflow on push or pull request events. +on: [push, pull_request] + +permissions: read-all + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + micromamba-test: + name: "Micromamba tests (Ubuntu)" + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: System Information + run: | + lsb_release -a + uname -a + + - name: Install micromamba and run tests + run: | + . .micromamba/init.sh -v + pytest test/unit -v From feaaffa5dd07128c20e7f35f9ea38d4a366b9c69 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 26 Jan 2026 04:31:48 +0100 Subject: [PATCH 3/5] Fix deactivate --- .micromamba/init.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.micromamba/init.sh b/.micromamba/init.sh index 1380ab33..50c6d950 100644 --- a/.micromamba/init.sh +++ b/.micromamba/init.sh @@ -71,6 +71,7 @@ fi # Create environment info "Creating environment [$ENV_NAME]..." +micromamba deactivate micromamba create --file $THIS_DIR/$ENV_NAME.yaml --name $ENV_NAME --yes $MAMBA_VERBOSITY # micromamba config set env_prompt "[{name}] " micromamba activate $ENV_NAME From 5a54127c14bbd4a436804ada79a2233f56556d4a Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 6 Feb 2026 21:37:21 +0100 Subject: [PATCH 4/5] Move .micromamba directory to .ci/micromamba Why: Better organize CI-related tooling by consolidating micromamba configuration and scripts under the .ci directory structure. What: - Moved .micromamba/ directory to .ci/micromamba/ using git mv - Updated init.sh path in .github/workflows/micromamba.yaml - Updated MICROMAMBA path in .ci/micromamba/uninstall.sh --- {.micromamba => .ci/micromamba}/dev.yaml | 0 {.micromamba => .ci/micromamba}/init.sh | 0 {.micromamba => .ci/micromamba}/uninstall.sh | 2 +- .github/workflows/micromamba.yaml | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename {.micromamba => .ci/micromamba}/dev.yaml (100%) rename {.micromamba => .ci/micromamba}/init.sh (100%) rename {.micromamba => .ci/micromamba}/uninstall.sh (96%) diff --git a/.micromamba/dev.yaml b/.ci/micromamba/dev.yaml similarity index 100% rename from .micromamba/dev.yaml rename to .ci/micromamba/dev.yaml diff --git a/.micromamba/init.sh b/.ci/micromamba/init.sh similarity index 100% rename from .micromamba/init.sh rename to .ci/micromamba/init.sh diff --git a/.micromamba/uninstall.sh b/.ci/micromamba/uninstall.sh similarity index 96% rename from .micromamba/uninstall.sh rename to .ci/micromamba/uninstall.sh index ad7a1d66..d4ceac5a 100644 --- a/.micromamba/uninstall.sh +++ b/.ci/micromamba/uninstall.sh @@ -1,6 +1,6 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -MICROMAMBA=".micromamba" +MICROMAMBA=".ci/micromamba" if [[ "$(basename $THIS_DIR)" == "$MICROMAMBA" ]]; then PROCESSES="bazel java python3 CodeChecke" echo "Killing: $PROCESSES" diff --git a/.github/workflows/micromamba.yaml b/.github/workflows/micromamba.yaml index 96f57b85..13c3ae83 100644 --- a/.github/workflows/micromamba.yaml +++ b/.github/workflows/micromamba.yaml @@ -41,5 +41,5 @@ jobs: - name: Install micromamba and run tests run: | - . .micromamba/init.sh -v + . .ci/micromamba/init.sh -v pytest test/unit -v From 0b086c3f61d98c29f402317fecd0a770b3fdc0a8 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 6 Feb 2026 22:10:26 +0100 Subject: [PATCH 5/5] Add README.md and address issues --- .ci/micromamba/README.md | 72 +++++++++++++++++++++++++++++++ .ci/micromamba/uninstall.sh | 13 ++---- .github/workflows/micromamba.yaml | 13 ++++-- .gitignore | 4 ++ 4 files changed, 89 insertions(+), 13 deletions(-) create mode 100644 .ci/micromamba/README.md diff --git a/.ci/micromamba/README.md b/.ci/micromamba/README.md new file mode 100644 index 00000000..dd765f16 --- /dev/null +++ b/.ci/micromamba/README.md @@ -0,0 +1,72 @@ +Micromamba +========== + +Micromamba is a fast, lightweight package manager compatible with conda packages. +Read more: https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html +You can use micromamba to quickly set up a development environment with all required tools. + + +Files +----- + +File | Description +--------------------------- | ----------- +.ci/micromamba/dev.yaml | Conda environment specification with all dependencies +.ci/micromamba/init.sh | Source this script to install micromamba and create environment +.ci/micromamba/uninstall.sh | Script to remove micromamba installation + + +How to use +---------- + +### Install & init + +To install micromamba and create the development environment: +```bash +source .ci/micromamba/init.sh +``` + +This script automatically: +- Downloads and installs micromamba to `.ci/micromamba/bin/` +- Creates a conda environment from `dev.yaml` +- Activates the environment + +> [!IMPORTANT] +> You must source the `init.sh` script (not just execute it) to properly activate +> the micromamba environment in your current shell session. + +For verbose output, use the `-v` or `-vv` flags: +```bash +source .ci/micromamba/init.sh -v +``` + +### After installation + +Once the environment is activated, all tools (Python, Bazel, CodeChecker, clang, etc.) +are available in your PATH. + +To deactivate the environment: +```bash +micromamba deactivate +``` + +To reactivate later without reinstalling: +```bash +source .ci/micromamba/init.sh +``` + +### Custom environments + +You can create additional environment files (e.g., `prod.yaml`) and activate them: +```bash +source .ci/micromamba/init.sh prod +``` + +### Uninstall + +To completely remove micromamba and all environments: +```bash +bash .ci/micromamba/uninstall.sh +``` + +Then exit your shell session to complete the cleanup. diff --git a/.ci/micromamba/uninstall.sh b/.ci/micromamba/uninstall.sh index d4ceac5a..5a64fb1b 100644 --- a/.ci/micromamba/uninstall.sh +++ b/.ci/micromamba/uninstall.sh @@ -1,8 +1,8 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -MICROMAMBA=".ci/micromamba" +MICROMAMBA="micromamba" if [[ "$(basename $THIS_DIR)" == "$MICROMAMBA" ]]; then - PROCESSES="bazel java python3 CodeChecke" + PROCESSES="bazel java python3 CodeChecker" echo "Killing: $PROCESSES" timeout 10s killall --quiet --wait $PROCESSES killall --quiet -SIGKILL $PROCESSES @@ -12,16 +12,9 @@ if [[ "$(basename $THIS_DIR)" == "$MICROMAMBA" ]]; then chmod -R +w $THIS_DIR/micromamba rm -rf $THIS_DIR/micromamba - # for directory in $THIS_DIR/*/; do - # if [[ -d "$directory" ]]; then - # echo "Removing: $directory" - # chmod -R +w $directory - # rm -rf $directory - # fi - # done echo "Please exit current shell session" else - echo "Error: wring location $THIS_DIR" + echo "Error: wrong location $THIS_DIR" echo " $MICROMAMBA is not there" exit 1 fi diff --git a/.github/workflows/micromamba.yaml b/.github/workflows/micromamba.yaml index 13c3ae83..23d3e7da 100644 --- a/.github/workflows/micromamba.yaml +++ b/.github/workflows/micromamba.yaml @@ -14,8 +14,15 @@ name: codechecker-bazel-micromamba-tests -# Triggers the workflow on push or pull request events. -on: [push, pull_request] +# Trigger the workflow manually +on: + workflow_dispatch: + inputs: + arguments: + description: "Arguments: test to run" + default: "pytest test/unit -v" + required: true + type: string permissions: read-all @@ -42,4 +49,4 @@ jobs: - name: Install micromamba and run tests run: | . .ci/micromamba/init.sh -v - pytest test/unit -v + ${{ inputs.arguments }} diff --git a/.gitignore b/.gitignore index ecc1cf1f..0f6154bf 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,10 @@ __pycache__ # Ignore Python virtual environment venv +# Ignore MicroMamba artifacts +.ci/micromamba/bin/ +.ci/micromamba/micromamba/ + # Ignore FOSS project clone dirs /test/foss/*/test-proj/