From a103dc9897fe9580214a53f6c41ffcb3c47f3b7d Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Mon, 31 Mar 2025 16:07:35 +0100 Subject: [PATCH 1/2] add conda environment file --- .github/workflows/test-conda-builds.yml | 71 +++++++++++++++++++++++++ conda-environment.yml | 21 ++++++++ 2 files changed, 92 insertions(+) create mode 100644 .github/workflows/test-conda-builds.yml create mode 100644 conda-environment.yml diff --git a/.github/workflows/test-conda-builds.yml b/.github/workflows/test-conda-builds.yml new file mode 100644 index 0000000000..40d0ca4151 --- /dev/null +++ b/.github/workflows/test-conda-builds.yml @@ -0,0 +1,71 @@ +name: conda builds + +on: + pull_request: + paths: + - 'conda-environment.yml' + - '.github/workflows/test_conda-build.yml' + schedule: + - cron: '17 22 * * 6' # Every Saturday at 22:17 + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +env: + FORCE_COLOR: 2 + +jobs: + test_conda_install: + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + python-version: ['3.8', '3'] + env: + ENV_FILE: conda-environment.yml + steps: + - name: checkout cylc-flow + uses: actions/checkout@v4 + + - name: modify conda env file + run: | + # write environment file + echo " - pip" >> "$ENV_FILE" # list pip as a dependency + echo " - pip:" >> "$ENV_FILE" # add a pip section + echo " - ." >> "$ENV_FILE" # install metomi-rose (pip install .) + cat "$ENV_FILE" + + - name: build conda env + uses: conda-incubator/setup-miniconda@v3 + with: + python-version: ${{ matrix.python-version }} + environment-file: ${{ env.ENV_FILE }} + + - name: check rose installation + shell: bash -el {0} + run: | + conda run -n test rose version --long + pip check + + - name: check for activate scripts + shell : bash -el {0} + run: | + # https://github.com/cylc/cylc-flow/issues/3704#issuecomment-897442365 + # locate all activate scripts + find "$CONDA_PREFIX" -name "activate.d" | tee > activates.txt + # ignore the conda activate script itself + sed -i "\|$CONDA_PREFIX/etc/conda/activate.d|d" activates.txt + # check to make sure no packages have contributed new activate scripts + # (we rely on having a conda activate-less environment) + if [[ $(wc -l < activates.txt) -ne 0 ]]; then + echo '::error::Found activate scripts in installation.' + cat activates.txt >&2 + exit 1 + fi diff --git a/conda-environment.yml b/conda-environment.yml new file mode 100644 index 0000000000..d21e8d3658 --- /dev/null +++ b/conda-environment.yml @@ -0,0 +1,21 @@ +name: rose-dev +channels: + - conda-forge +dependencies: + # outut: metomi-rose-base + - __unix + - python >= 3.7.0 + - aiofiles + - jinja2 >=2.10.1 + - keyring >=23,<24 + - ldap3 + - metomi-isodatetime >=1!3.0,<1!4.0 + - psutil >=5.6.0 + - requests + - sqlalchemy >=1,<2 + - importlib_metadata >=5.0 # py<3.12 TODO: selectors don't work for noarch packages + - importlib_resources >=2.0 # py<3.9 TODO: selectors don't work for noarch packages + # - tornado (rosie disco is temporally disabled) + + # output: metomi-rose + - pygraphviz >1.0,!=1.8 From bc4631152ac592556fb8251704768d0d34a9ccf6 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Tue, 1 Apr 2025 11:32:52 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> --- .github/workflows/test-conda-builds.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-conda-builds.yml b/.github/workflows/test-conda-builds.yml index 40d0ca4151..12a9273722 100644 --- a/.github/workflows/test-conda-builds.yml +++ b/.github/workflows/test-conda-builds.yml @@ -4,7 +4,7 @@ on: pull_request: paths: - 'conda-environment.yml' - - '.github/workflows/test_conda-build.yml' + - '.github/workflows/test-conda-builds.yml' schedule: - cron: '17 22 * * 6' # Every Saturday at 22:17 workflow_dispatch: @@ -31,7 +31,7 @@ jobs: env: ENV_FILE: conda-environment.yml steps: - - name: checkout cylc-flow + - name: checkout uses: actions/checkout@v4 - name: modify conda env file