From ea3e56337201db4dab82e7f607d3a476f5f9f719 Mon Sep 17 00:00:00 2001 From: pdiakumis Date: Thu, 15 Aug 2024 00:24:54 +1000 Subject: [PATCH] conda setup --- .bumpversion.cfg | 12 ++++ .github/workflows/conda-deploy.yaml | 97 +++++++++++++++++++++++++++++ conda/env/lock/README.md | 1 + conda/env/yaml/condabuild.yaml | 10 +++ conda/env/yaml/rportal.yaml | 9 +++ conda/recipe/build.sh | 9 +++ conda/recipe/meta.yaml | 67 ++++++++++++++++++++ 7 files changed, 205 insertions(+) create mode 100644 .github/workflows/conda-deploy.yaml create mode 100644 conda/env/lock/README.md create mode 100644 conda/env/yaml/condabuild.yaml create mode 100644 conda/env/yaml/rportal.yaml create mode 100644 conda/recipe/build.sh create mode 100644 conda/recipe/meta.yaml diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 358c4b2..a4bbbd0 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -5,3 +5,15 @@ commit = True [bumpversion:file:DESCRIPTION] search = Version: {current_version} replace = Version: {new_version} + +[bumpversion:file:.github/workflows/conda-deploy.yaml] +search = VERSION: '{current_version}' +replace = VERSION: '{new_version}' + +[bumpversion:file:conda/env/yaml/rportal.yaml] +search = r-rportal =={current_version} +replace = r-rportal =={new_version} + +[bumpversion:file:conda/recipe/meta.yaml] +search = version: {current_version} +replace = version: {new_version} diff --git a/.github/workflows/conda-deploy.yaml b/.github/workflows/conda-deploy.yaml new file mode 100644 index 0000000..0352e23 --- /dev/null +++ b/.github/workflows/conda-deploy.yaml @@ -0,0 +1,97 @@ +name: conda-docker-docs + +on: + push: + branches: + - main +env: + atoken: ${{ secrets.ANACONDA_UPLOAD_TOKEN }} + recipe_path: conda/recipe + env_yaml_path: conda/env/yaml + env_lock_path: conda/env/lock + VERSION: '0.1.1' # versioned by bump2version + +jobs: + condarise: + # When merging to main and the commit message starts with 'Bump version:' + if: "startsWith(github.event.head_commit.message, 'Bump version:')" + name: Condarise + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + + steps: + - name: Code checkout + uses: actions/checkout@v4 + - name: Micromamba setup + uses: mamba-org/setup-micromamba@v1 + with: + environment-file: ${{ env.env_yaml_path }}/condabuild.yaml + - name: 🐍 Conda pkg build and upload + run: | + conda mambabuild --R 4.3.3 ${recipe_path} -c conda-forge --token ${atoken} + - name: 🔒 Conda lock + run: | + conda-lock lock --file ${env_yaml_path}/rportal.yaml -p linux-64 + conda-lock render --kind explicit -p linux-64 conda-lock.yml --filename-template 'rportal-{platform}.lock' && rm conda-lock.yml + mv rportal-*.lock ${env_lock_path}/ + - name: 💾 Commit lockfile + run: | + git status + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + MSG="[bot] Updating conda-lock file (v${VERSION})" + git add . + git commit -m "${MSG}" + git push + + - name: 📥 Pull lock commit + id: pull_lock_commit + run: | + git pull --no-rebase + git --no-pager log --decorate=short --pretty=oneline -n3 + LATEST_COMMIT_HASH="$(git --no-pager log -1 --format='%H')" + echo "latest_commit_hash=${LATEST_COMMIT_HASH}" >> $GITHUB_OUTPUT + - name: 🔖 Create tag + uses: actions/github-script@v7 + env: + LATEST_COMMIT_HASH: ${{ steps.pull_lock_commit.outputs.latest_commit_hash }} + with: + script: | + const the_tag_name = 'refs/tags/v' + process.env.VERSION + const the_sha = process.env.LATEST_COMMIT_HASH + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: the_tag_name, + sha: the_sha + }) + + # work with tag from above + - name: Code checkout + uses: actions/checkout@v4 + with: + ref: v${{ env.VERSION }} + - name: 🏰 QEMU setup + uses: docker/setup-qemu-action@v3 + - name: 🏯 Buildx setup + uses: docker/setup-buildx-action@v3 + with: + install: true + config-inline: | + [worker.oci] + max-parallelism = 2 + - name: 🐙 GitHub CR login + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: 🐳 Docker img build and push + uses: docker/build-push-action@v6 + with: + tags: ghcr.io/${{ github.repository }}:${{ env.VERSION }} + context: . + push: true + platforms: linux/amd64 diff --git a/conda/env/lock/README.md b/conda/env/lock/README.md new file mode 100644 index 0000000..94c2503 --- /dev/null +++ b/conda/env/lock/README.md @@ -0,0 +1 @@ +For `conda-lock` see diff --git a/conda/env/yaml/condabuild.yaml b/conda/env/yaml/condabuild.yaml new file mode 100644 index 0000000..e13c59c --- /dev/null +++ b/conda/env/yaml/condabuild.yaml @@ -0,0 +1,10 @@ +name: cbuildenv + +channels: + - conda-forge +dependencies: + - conda-build + - conda-lock + - conda-verify + - anaconda-client + - boa diff --git a/conda/env/yaml/rportal.yaml b/conda/env/yaml/rportal.yaml new file mode 100644 index 0000000..ed79175 --- /dev/null +++ b/conda/env/yaml/rportal.yaml @@ -0,0 +1,9 @@ +name: rportal + +channels: + - umccr + - conda-forge + - bioconda + +dependencies: + - r-rportal ==0.1.1 # versioned by bump2version diff --git a/conda/recipe/build.sh b/conda/recipe/build.sh new file mode 100644 index 0000000..310a5c9 --- /dev/null +++ b/conda/recipe/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export DISABLE_AUTOBREW=1 +${R} CMD INSTALL --build . ${R_ARGS} + +# Copy CLI to conda bin +mkdir -p ${PREFIX}/bin +cp ${SRC_DIR}/inst/scripts/datashare/datashare.R ${PREFIX}/bin +chmod +x ${PREFIX}/bin/datashare.R diff --git a/conda/recipe/meta.yaml b/conda/recipe/meta.yaml new file mode 100644 index 0000000..10f60bb --- /dev/null +++ b/conda/recipe/meta.yaml @@ -0,0 +1,67 @@ +package: + name: r-rportal + version: 0.1.1 # bump2version + +source: + path: ../.. + +build: + number: 0 + noarch: generic + rpaths: + - lib/R/lib/ + - lib/ + +requirements: + build: + - git + host: + - python + - boto3 + - r-base + - r-assertthat + - r-cli + - r-dbi + - r-dplyr + - umccr::r-dracarys + - r-fs + - r-glue + - r-jsonlite + - r-optparse + - r-purrr + - r-rathena + - r-readr + - r-rlang + - r-tibble + - r-tidyr + + run: + - python + - boto3 + - r-base + - r-assertthat + - r-cli + - r-dbi + - r-dplyr + - umccr::r-dracarys + - r-fs + - r-glue + - r-jsonlite + - r-optparse + - r-purrr + - r-rathena + - r-readr + - r-rlang + - r-tibble + - r-tidyr + +test: + commands: + - $R -e "library('rportal')" + - datashare.R --version + - python -c "import boto3" + +about: + home: https://github.com/umccr/rportal + license: MIT + summary: UMCCR data portal R functionality