From 9520627ddf1db0a59a8f9dca9f7249cb18d06757 Mon Sep 17 00:00:00 2001 From: finlayclark Date: Tue, 24 Sep 2024 14:38:48 +0100 Subject: [PATCH] Try different strategy to build env for docs deployment --- .github/workflows/docs.yaml | 75 +++++++++++++++++++++---------------- Makefile | 1 - 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index b5091fc..6b0a354 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -12,35 +12,46 @@ jobs: container: condaforge/mambaforge:latest steps: - - name: Prepare container - run: | - apt update && apt install -y git make - - - name: Checkout - uses: actions/checkout@v4 - - - name: Determine Version - shell: bash - run: | - if [ "$GITHUB_REF" = "refs/heads/main" ]; then - echo "VERSION=latest" >> $GITHUB_ENV - elif [ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ]; then - VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///') - echo "VERSION=$VERSION stable" >> $GITHUB_ENV - else - echo "Invalid ref: $GITHUB_REF" - exit 1 - fi - - - name: Build and Deploy Documentation - run: | - git config --global user.name 'GitHub Actions' - git config --global user.email 'actions@github.com' - git config --global --add safe.directory "$PWD" - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} - - git fetch --all --prune - - make env - - make docs-deploy VERSION="$VERSION" + - uses: actions/checkout@v4 + + - uses: mamba-org/setup-micromamba@v1 + with: + environment-file: devtools/conda-envs/test.yaml + environment-name: red + create-args: >- # beware the >- instead of |, we don't split on newlines but on spaces + python=3.12 + + - name: Install package + # conda setup requires this special shell + shell: bash -l {0} + run: | + micromamba install -y -n red -c conda-forge -c defaults git make + apt update && apt install -y git make + python -m pip install . --no-deps + micromamba list + + - name: Determine Version + shell: bash + run: | + if [ "$GITHUB_REF" = "refs/heads/main" ]; then + echo "VERSION=latest" >> $GITHUB_ENV + elif [ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ]; then + VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///') + echo "VERSION=$VERSION stable" >> $GITHUB_ENV + else + echo "Invalid ref: $GITHUB_REF" + exit 1 + fi + + - name: Build and Deploy Documentation + run: | + git config --global user.name 'GitHub Actions' + git config --global user.email 'actions@github.com' + git config --global --add safe.directory "$PWD" + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + + git fetch --all --prune + + make env + + make docs-deploy VERSION="$VERSION" diff --git a/Makefile b/Makefile index ff698a6..ab64078 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ TEST_ARGS := -v --cov=$(PACKAGE_NAME) --cov-report=term --cov-report=xml --junit env: mamba create --name $(PACKAGE_NAME) mamba env update --name $(PACKAGE_NAME) --file devtools/conda-envs/test.yaml - conda activate $(PACKAGE_NAME) $(CONDA_ENV_RUN) pip install --no-deps -e . $(CONDA_ENV_RUN) pre-commit install || true