create CI for checking that recipes can be built #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: [ "main" ] | |
# Publish semver tags as releases. | |
tags: [ 'v*.*.*' ] | |
paths-ignore: | |
- 'README.md' | |
pull_request: | |
branches: [ "main" ] | |
paths-ignore: | |
- 'README.md' | |
jobs: | |
# adapted from https://docs.github.com/en/actions/learn-github-actions/expressions#example-returning-a-json-object | |
get_dirs: | |
name: Get directory names | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
outputs: | |
matrix: ${{ steps.output-dirs.outputs.matrix }} # contains a list of the module names encoded as a json array | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: get directory names | |
id: output-dirs | |
# adapted from https://stackoverflow.com/a/71687652 | |
run: | | |
matrix=$(cd recipes && ls -d */ | jq --raw-input --slurp --compact-output 'split("/\n")[:-1]') | |
echo "$matrix" | |
echo "matrix=$matrix" >> $GITHUB_OUTPUT | |
build-and-push: | |
needs: get_dirs | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
packagename: ${{ fromJson(needs.get_dirs.outputs.matrix) }} | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Setup Mambaforge | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
activate-environment: biobuild | |
miniforge-variant: Mambaforge | |
channels: conda-forge,bioconda,defaults | |
auto-activate-base: false | |
miniforge-version: latest | |
use-mamba: true | |
- name: Get Date | |
id: get-date | |
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Cache Conda env | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CONDA }}/envs | |
key: | |
conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ env.CACHE_NUMBER }} | |
env: | |
# Increase this value to reset cache if dev-env.yml has not changed | |
CACHE_NUMBER: 0 | |
id: cache | |
- name: Install dev environment | |
run: | |
mamba create -y -n biobuild -c conda-forge -c bioconda -c nodefaults bioconda-utils | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Run test | |
shell: bash -el {0} | |
run: | | |
bioconda-utils build --packages ${{ matrix.packagename }} | |
- name: Upload built package | |
uses: "actions/upload-artifact@v4" | |
with: | |
name: ${{ matrix.packagename }} | |
path: ${{ env.CONDA }}/envs/biobuild/conda-bld/ |