diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3f23832..3ee0acd 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -13,6 +13,15 @@ on: - cron: '6 2 * * *' workflow_dispatch: +# 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: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + jobs: build-installer: name: Build installer @@ -31,6 +40,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 @@ -59,7 +70,7 @@ jobs: run: | bash DIRACOS-*.sh source diracos/diracosrc - conda env export --file environment.yaml --prefix $DIRACOS + micromamba env export --prefix "$DIRACOS" > environment.yaml - name: Upload environment.yaml uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: @@ -74,6 +85,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 +96,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 +137,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 +159,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 +183,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 +210,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 +220,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..14f2328 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,20 +12,40 @@ on: required: false default: '' +# 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 + +permissions: + contents: read + jobs: create-release: + 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: read 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..6ed6b6c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,11 +2,11 @@ # See https://pre-commit.com/hooks.html for more hooks default_language_version: - python: python3.9 + python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -14,6 +14,12 @@ repos: - id: check-added-large-files - repo: https://github.com/psf/black - rev: 21.9b0 + rev: 26.10.1 hooks: - id: black + + - repo: https://github.com/zizmorcore/zizmor-pre-commit + rev: v1.32.0 + hooks: + - id: zizmor + args: ["--no-online-audits"] 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