Skip to content

Commit

Permalink
declare jobs & actions variables (DRY principle)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotfontaine committed Jul 1, 2024
1 parent 77bb499 commit ea298fb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
21 changes: 19 additions & 2 deletions .github/actions/install-conda-cylc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,28 @@ inputs:
env-path:
required: true
type: string
default: 'cylc-src/bioreactor-workflow/envs/cylc.yml'
description: 'Path to the conda environment file specifying the cylc environment.'
wrapper-path:
required: false
type: string
description: 'Directory path where the cylc and rose wrapper scripts should be written. Must be in PATH.'
default: '/usr/local/bin'

runs:
using: composite
steps:
- name: check conda env file
description: Check if the conda env file contains at least cylc-flow or cylc-flow-base
run: |
if ! grep -q 'name: cylc' "${{ inputs.env-path }}"; then
echo "The conda environment should be named 'cylc'."
exit 1
fi
if ! grep -q cylc-flow ${{ inputs.env-path }}; then
echo "'cylc-flow' or 'cylc-flow-base' not found in the conda env file."
exit 1
fi
- uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: false
Expand All @@ -25,7 +42,7 @@ runs:
shell: bash -el {0}
run: |
CONDA_ENVS=${CONDA}/envs
WRAPPER_DIR=/usr/local/bin
WRAPPER_DIR=${{ inputs.wrapper-path }}
cylc get-resources cylc ${WRAPPER_DIR} && chmod +x ${WRAPPER_DIR}/cylc
sed -i "s|^CYLC_HOME_ROOT=.*|CYLC_HOME_ROOT=${CONDA_ENVS}|" ${WRAPPER_DIR}/cylc
ln -s ${WRAPPER_DIR}/cylc ${WRAPPER_DIR}/rose
Expand Down
15 changes: 0 additions & 15 deletions .github/bin/cylc-lint-validate

This file was deleted.

10 changes: 7 additions & 3 deletions .github/workflows/cylc-lint-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
pull_request:
paths:
- '.github/workflows/cylc-lint-validate.yml'
- '.github/actions/install-conda-cylc/action.yml'
- 'cylc-src/**.cylc'
push:
branches: [main]
Expand All @@ -18,17 +19,20 @@ jobs:
cylc-validate:
name: Validate Cylc files
runs-on: ubuntu-latest
env:
conda_env_file: 'cylc-src/bioreactor-workflow/envs/cylc.yml'
workflow_path: './cylc-src/bioreactor-workflow'
defaults:
run:
shell: bash -eul {0}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-conda-cylc
with:
env-path: 'cylc-src/bioreactor-workflow/envs/cylc.yml'
env-path: ${{ env.conda_env_file }}
- name: cylc lint
run: |
cylc lint ./cylc-src/bioreactor-workflow
cylc lint -v ${workflow_path}
- name: cylc validate
run: |
cylc validate ./cylc-src/bioreactor-workflow
cylc validate -v ${workflow_path}

0 comments on commit ea298fb

Please sign in to comment.