|
| 1 | +name: conda builds |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'conda-environment.yml' |
| 7 | + - '.github/workflows/test_conda-build.yml' |
| 8 | + schedule: |
| 9 | + - cron: '17 22 * * 6' # Every Saturday at 22:17 |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +defaults: |
| 17 | + run: |
| 18 | + shell: bash |
| 19 | + |
| 20 | +env: |
| 21 | + FORCE_COLOR: 2 |
| 22 | + |
| 23 | +jobs: |
| 24 | + test_conda_install: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + timeout-minutes: 10 |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + python-version: ['3.8', '3'] |
| 31 | + env: |
| 32 | + ENV_FILE: conda-environment.yml |
| 33 | + steps: |
| 34 | + - name: checkout cylc-flow |
| 35 | + uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: modify conda env file |
| 38 | + run: | |
| 39 | + # write environment file |
| 40 | + echo " - pip" >> "$ENV_FILE" # list pip as a dependency |
| 41 | + echo " - pip:" >> "$ENV_FILE" # add a pip section |
| 42 | + echo " - ." >> "$ENV_FILE" # install metomi-rose (pip install .) |
| 43 | + cat "$ENV_FILE" |
| 44 | +
|
| 45 | + - name: build conda env |
| 46 | + uses: conda-incubator/setup-miniconda@v3 |
| 47 | + with: |
| 48 | + python-version: ${{ matrix.python-version }} |
| 49 | + environment-file: ${{ env.ENV_FILE }} |
| 50 | + |
| 51 | + - name: check rose installation |
| 52 | + shell: bash -el {0} |
| 53 | + run: | |
| 54 | + conda run -n test rose version --long |
| 55 | + pip check |
| 56 | +
|
| 57 | + - name: check for activate scripts |
| 58 | + shell : bash -el {0} |
| 59 | + run: | |
| 60 | + # https://github.com/cylc/cylc-flow/issues/3704#issuecomment-897442365 |
| 61 | + # locate all activate scripts |
| 62 | + find "$CONDA_PREFIX" -name "activate.d" | tee > activates.txt |
| 63 | + # ignore the conda activate script itself |
| 64 | + sed -i "\|$CONDA_PREFIX/etc/conda/activate.d|d" activates.txt |
| 65 | + # check to make sure no packages have contributed new activate scripts |
| 66 | + # (we rely on having a conda activate-less environment) |
| 67 | + if [[ $(wc -l < activates.txt) -ne 0 ]]; then |
| 68 | + echo '::error::Found activate scripts in installation.' |
| 69 | + cat activates.txt >&2 |
| 70 | + exit 1 |
| 71 | + fi |
0 commit comments