From db23154301225c7d160767766064562172fe6b99 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Sun, 15 Nov 2026 13:31:12 +0100 Subject: [PATCH 1/4] chore: add zizmor (pre-commit) and fix its auditor findings --- .github/workflows/build-and-test.yml | 32 +++++++++++++++++++++++++--- .github/workflows/release.yaml | 24 ++++++++++++++++++--- .pre-commit-config.yaml | 17 +++++---------- 3 files changed, 55 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3f23832..715c702 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -13,6 +13,14 @@ on: - cron: '6 2 * * *' workflow_dispatch: +# A new push to the same branch/PR cancels the previous run. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + jobs: build-installer: name: Build installer @@ -31,6 +39,8 @@ jobs: os: macos-15-intel steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: prefix-dev/setup-pixi@ad1da6449d9e506fd127fd67ab2d054a769f6a94 # v0.11.2 with: cache: true @@ -74,6 +84,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: prefix-dev/setup-pixi@ad1da6449d9e506fd127fd67ab2d054a769f6a94 # v0.11.2 with: cache: true @@ -83,9 +95,11 @@ jobs: with: path: artifacts - name: Create release notes + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | pixi run -e release release-notes \ - --token="${{ secrets.GITHUB_TOKEN }}" \ + --token="${GH_TOKEN}" \ --artifacts-dir="${PWD}/artifacts" \ > release-notes.md cat release-notes.md @@ -122,12 +136,16 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Download installer uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: ${{ matrix.installer }} - name: Run tests - run: scripts/run_basic_tests.sh ${{ matrix.docker_image }} DIRACOS-*.sh + env: + DOCKER_IMAGE: ${{ matrix.docker_image }} + run: scripts/run_basic_tests.sh "$DOCKER_IMAGE" DIRACOS-*.sh macos-64-tests: name: macOS (x86_64) tests @@ -140,6 +158,8 @@ jobs: os: [macos-15-intel] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Download installer uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: @@ -162,6 +182,8 @@ jobs: os: [macos-15, macos-26] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Download installer uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: @@ -187,6 +209,8 @@ jobs: - integration steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: python-version: '3.15' @@ -195,9 +219,11 @@ jobs: with: name: installer-linux-64 - name: Prepare environment + env: + DIRAC_BRANCH: ${{ matrix.dirac-branch }} run: | pip install typer pyyaml gitpython packaging - git clone https://github.com/DIRACGrid/DIRAC.git -b "${{ matrix.dirac-branch }}" DIRACRepo + git clone https://github.com/DIRACGrid/DIRAC.git -b "${DIRAC_BRANCH}" DIRACRepo - name: Run tests run: | DIRACOS_TARBALL_PATH=$(echo ${PWD}/DIRACOS-*.sh) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a888c62..77f3fad 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,20 +12,38 @@ on: required: false default: '' +# Don't cancel: a queued run may be a release waiting to publish. +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +permissions: + contents: read + jobs: create-release: + name: create-release if: github.repository == 'DIRACGrid/DIRACOS2' runs-on: ubuntu-latest + permissions: + contents: write # create the GitHub release steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: prefix-dev/setup-pixi@ad1da6449d9e506fd127fd67ab2d054a769f6a94 # v0.11.2 with: cache: true environments: release - name: Create release + env: + # zizmor: ignore[secrets-outside-env] release creation; no GitHub environment needed + GH_TOKEN: ${{ secrets.GH_TOKEN }} + RUN_ID: ${{ github.event.inputs.run_id }} + VERSION_INPUT: ${{ github.event.inputs.version }} run: | pixi run -e release release-notes \ - --token="${{ secrets.GH_TOKEN }}" \ - --run-id="${{ github.event.inputs.run_id }}" \ - --version="${{ github.event.inputs.version }}" \ + --token="${GH_TOKEN}" \ + --run-id="${RUN_ID}" \ + --version="${VERSION_INPUT}" \ --make-release diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 907a488..b5d25bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,18 +2,11 @@ # See https://pre-commit.com/hooks.html for more hooks default_language_version: - python: python3.9 + python: python3.11 repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + - repo: https://github.com/zizmorcore/zizmor-pre-commit + rev: v1.32.0 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files - - - repo: https://github.com/psf/black - rev: 21.9b0 - hooks: - - id: black + - id: zizmor + args: ["--no-online-audits"] From b9280d4b14cb9f7e46ce2e92b10aacff5353dff0 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Mon, 16 Nov 2026 14:36:03 +0100 Subject: [PATCH 2/4] fix: export environment.yaml with micromamba (conda no longer shipped) The installer only bundles micromamba, so 'conda env export' fails with 'conda: command not found'. Reproduce the same conda-style environment.yaml (the format parsed by scripts/make_release.py) from 'micromamba list --json'. --- .github/workflows/build-and-test.yml | 35 +++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 715c702..3ac2f42 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -66,10 +66,43 @@ jobs: with: name: installer-${{ matrix.target_arch }} - name: Generate environment.yaml + # The installer only ships micromamba (no conda), so the environment + # is exported via "micromamba list" in conda env export format, which + # is what scripts/make_release.py parses for the release notes. run: | bash DIRACOS-*.sh source diracos/diracosrc - conda env export --file environment.yaml --prefix $DIRACOS + "$DIRACOS/bin/python" - <<'EOF' + import json + import os + import subprocess + + prefix = os.environ["DIRACOS"] + packages = json.loads( + subprocess.check_output( + [f"{prefix}/bin/micromamba", "list", "--prefix", prefix, "--json"], + text=True, + ) + )["packages"] + + channels = [] + for package in packages: + if package["channel"] not in channels: + channels.append(package["channel"]) + + with open("environment.yaml", "w") as env_file: + env_file.write(f"name: {prefix}\n") + env_file.write("channels:\n") + for channel in channels: + env_file.write(f" - {channel}\n") + env_file.write("dependencies:\n") + for package in packages: + env_file.write( + f" - {package['name']}={package['version']}" + f"={package['build_string']}\n" + ) + env_file.write(f"prefix: {prefix}\n") + EOF - name: Upload environment.yaml uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: From dba8c679565414aa86a170f0c7606ad5f41783a3 Mon Sep 17 00:00:00 2001 From: aldbr <19813740+aldbr@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:33:41 +0100 Subject: [PATCH 3/4] fix: restore the pre-commit hooks and align the environment.yaml export with #211 - trailing-whitespace, end-of-file-fixer, check-yaml, check-added-large-files and black were dropped together with their 2021 pins; restore them at current versions (pre-commit-hooks v6.0.0, black 26.10.1) and apply their three small fixes - default_language_version python3: no hook needs exactly Python 3.11 - use the same one-line micromamba env export as DIRACGrid/DIRACOS2#211, so the two PRs merge in either order Assisted-by: Claude:claude-opus-5-5 --- .github/workflows/build-and-test.yml | 35 +--------------------------- .pre-commit-config.yaml | 15 +++++++++++- scripts/make_release.py | 2 +- scripts/run_basic_tests.sh | 2 +- tests/test_import.py | 1 + 5 files changed, 18 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3ac2f42..5573e26 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -66,43 +66,10 @@ jobs: with: name: installer-${{ matrix.target_arch }} - name: Generate environment.yaml - # The installer only ships micromamba (no conda), so the environment - # is exported via "micromamba list" in conda env export format, which - # is what scripts/make_release.py parses for the release notes. run: | bash DIRACOS-*.sh source diracos/diracosrc - "$DIRACOS/bin/python" - <<'EOF' - import json - import os - import subprocess - - prefix = os.environ["DIRACOS"] - packages = json.loads( - subprocess.check_output( - [f"{prefix}/bin/micromamba", "list", "--prefix", prefix, "--json"], - text=True, - ) - )["packages"] - - channels = [] - for package in packages: - if package["channel"] not in channels: - channels.append(package["channel"]) - - with open("environment.yaml", "w") as env_file: - env_file.write(f"name: {prefix}\n") - env_file.write("channels:\n") - for channel in channels: - env_file.write(f" - {channel}\n") - env_file.write("dependencies:\n") - for package in packages: - env_file.write( - f" - {package['name']}={package['version']}" - f"={package['build_string']}\n" - ) - env_file.write(f"prefix: {prefix}\n") - EOF + micromamba env export --prefix "$DIRACOS" > environment.yaml - name: Upload environment.yaml uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5d25bf..6ed6b6c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,9 +2,22 @@ # See https://pre-commit.com/hooks.html for more hooks default_language_version: - python: python3.11 + python: python3 repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/psf/black + rev: 26.10.1 + hooks: + - id: black + - repo: https://github.com/zizmorcore/zizmor-pre-commit rev: v1.32.0 hooks: diff --git a/scripts/make_release.py b/scripts/make_release.py index aa77c6d..7bc0e85 100755 --- a/scripts/make_release.py +++ b/scripts/make_release.py @@ -21,7 +21,7 @@ "linux-64": "Linux-x86_64", "linux-aarch64": "Linux-aarch64", "osx-64": "Darwin-x86_64", - "osx-arm64": "Darwin-arm64" + "osx-arm64": "Darwin-arm64", } logging.basicConfig(level=logging.INFO) diff --git a/scripts/run_basic_tests.sh b/scripts/run_basic_tests.sh index a73b86e..c7b9f4b 100755 --- a/scripts/run_basic_tests.sh +++ b/scripts/run_basic_tests.sh @@ -11,7 +11,7 @@ exec docker run --rm --privileged -v "${PWD}":/diracos-repo "${IMAGE_NAME}" bash if ! command -v sudo >/dev/null 2>&1; then yum install -y sudo fi - + # Install as a non-root user with a read-only $HOME so that DIRACGrid/DIRACOS2#174 # (installer failing on mkdir ~/.conda when $HOME is not writable) would be # reproduced here. Root ignores permission bits, so this check only works as diff --git a/tests/test_import.py b/tests/test_import.py index 0a9e99d..c3349d2 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -2,6 +2,7 @@ """ Some imports to make sure that the DIRACOS environment is complete """ + from __future__ import absolute_import from __future__ import division from __future__ import print_function From 6ff72b1673de6be941753ee33d5c4511fdd09c27 Mon Sep 17 00:00:00 2001 From: aldbr <19813740+aldbr@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:34:04 +0100 Subject: [PATCH 4/4] ci: never cancel main runs; drop the unused release write permission - build-and-test: cancel superseded runs only on PRs; a push to main must not cancel the nightly run whose artifacts a release uses - release: the release is created with secrets.GH_TOKEN, so the GITHUB_TOKEN only needs contents: read; fix the concurrency comment (GitHub keeps one pending run per group, a newer dispatch replaces it) Assisted-by: Claude:claude-opus-5-5 --- .github/workflows/build-and-test.yml | 5 +++-- .github/workflows/release.yaml | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 5573e26..3ee0acd 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -13,10 +13,11 @@ on: - cron: '6 2 * * *' workflow_dispatch: -# A new push to the same branch/PR cancels the previous run. +# A new push to the same PR cancels the previous run. Runs on main (pushes +# and the nightly schedule) are never cancelled: releases use their artifacts. concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: contents: read diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 77f3fad..14f2328 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,7 +12,8 @@ on: required: false default: '' -# Don't cancel: a queued run may be a release waiting to publish. +# Never cancel a running release. GitHub keeps only one pending run per group, +# so a newer dispatch replaces a queued (not yet started) one. concurrency: group: ${{ github.workflow }} cancel-in-progress: false @@ -25,8 +26,9 @@ jobs: name: create-release if: github.repository == 'DIRACGrid/DIRACOS2' runs-on: ubuntu-latest + # The release is created with secrets.GH_TOKEN, not the GITHUB_TOKEN. permissions: - contents: write # create the GitHub release + contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: