GitHub Action for checking a conda environment for upgradable packages

󰃭 2023-01-23

When experimenting with GitHub Actions, I made workflow called check-conda-envs for checking conda environment definition files (in YAML format) for available package upgrades. The action will create a table in the workflow summary page containing the current and latest version number for each package, and also a link to the changelog for many bioinformatics packages.

Here is an example output from a workflow run in the ont-assembly-snake repository:

Example output table

The workflow will fail, when a package definition is found to not use = or == before the version number, e.g. the snakemake>=6.15.5 in above example.

It’s very easy to include the workflow in a repository, either by adding the file check-conda-envs.yml to the .github/workflows/ folder or by adding this job to an existing workflow:

  check-conda-upgrades:
    runs-on: "ubuntu-latest"

    # this defines the repository folder in which the conda environment files (*.y[a]ml) are located
    # multiple folders can be set with: TARGET: "env1 subfolder/env2"
    env:
      TARGET: "env"

    steps:
      # checkout this repository
      - uses: actions/checkout@v3

      # checkout pmenzel/gh-actions
      - uses: actions/checkout@v3
        with:
          repository: pmenzel/gh-actions
          ref: master
          path: ./external/gh-actions

      # https://github.com/marketplace/actions/setup-miniconda
      - uses: conda-incubator/setup-miniconda@v2
        with:
          channels: conda-forge,bioconda
      - run: |
          conda info

      - name: Run gh-actions/check-conda-envs/check-all-conda-envs.sh
        run: ./external/gh-actions/check-conda-envs/check-all-conda-envs.sh ${{env.TARGET}}