Skip to content

Create composite action to create constructor-based installers #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fb03202
Use more compact YAML formatting
marcoesters Apr 15, 2025
b46958e
Add composite action to build installers
marcoesters Apr 15, 2025
c4e57b8
Add recipe files for tests
marcoesters Apr 15, 2025
6959019
Remove unneeded pre-commit hooks
marcoesters Apr 15, 2025
177396b
Add tests for default builds
marcoesters Apr 15, 2025
05433a5
Add tests for environment.yaml files
marcoesters Apr 15, 2025
f8a6011
Add tests for signing Windows installers
marcoesters Apr 15, 2025
292d3a1
Add tests for micromamba
marcoesters Apr 15, 2025
9635607
Add test for builds in Docker images
marcoesters Apr 15, 2025
f0e56e8
Add documentation
marcoesters Apr 16, 2025
e974f94
Add test to check that action fails without conda
marcoesters Apr 16, 2025
bbbcd0b
Add input validation for environment files
marcoesters Apr 16, 2025
1f5f630
Remove accidentally added line to team charter
marcoesters Apr 16, 2025
ead21e6
Limit paths to for triggering test runs
marcoesters Apr 16, 2025
98b8b1b
Explicitly add GitHub workspace variable to recipe directory
marcoesters Apr 17, 2025
f2fe3a1
Remove constructor-generated tmp directory
marcoesters Apr 17, 2025
6835bdf
Use conda run instead of activating environment
marcoesters Apr 18, 2025
fbc1913
Fix incomplete comment
marcoesters Apr 30, 2025
5fa2229
Apply suggestions from code review
marcoesters May 5, 2025
e5345b2
Add sha to QEMU image
marcoesters May 5, 2025
fe75549
Replace recipe-directory with input-directory
marcoesters May 5, 2025
ff36acc
Remove comment that name must not be in the environment file
marcoesters May 6, 2025
4b329d1
Do not capture conda run output
marcoesters May 7, 2025
eb1af15
Restrict permissions of test workflows
marcoesters May 7, 2025
7fe7737
Replace template expansion with environment variables
marcoesters May 7, 2025
b8d8332
Validate inputs that refer to files or directories
marcoesters May 7, 2025
fc17a09
Replace remaining runner.temp with environment variable
marcoesters May 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions .github/workflows/test-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Test container builds

on:
pull_request:
paths:
- action.yaml
- recipes/**
- .github/workflows/test-container.yaml
push:
branches:
- main

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
build-installer:
name: Container builds (${{ matrix.artifact-suffix }})
runs-on: ubuntu-latest
env:
MICROMAMBA_VERSION: 2.0.8
MICROMAMBA_BUILD: 0
strategy:
fail-fast: false
matrix:
include:
- container-image: continuumio/miniconda3
container-architecture: linux/aarch64
artifact-suffix: miniconda-aarch64
- container-image: continuumio/miniconda3
artifact-suffix: miniconda-x86_64
- container-image: condaforge/linux-anvil-aarch64
container-architecture: linux/aarch64
target-platform: linux-aarch64
artifact-suffix: miniforge-aarch64

steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Download micromamba
id: download-micromamba
if: startswith(matrix.container-image, 'condaforge/')
env:
TARGET_PLATFORM: ${{ matrix.target-platform }}
run: |
# Use a custom script since setup-micromamba does not support
# cross-platform downloads.
MICROMAMBA_DIR="${{ runner.temp }}/micromamba"
MICROMAMBA_BIN="${MICROMAMBA_DIR}/micromamba"
VERSION="${MICROMAMBA_VERSION}-${MICROMAMBA_BUILD}"
MICROMAMBA_URL="https://github.com/mamba-org/micromamba-releases/releases/download/${VERSION}/micromamba-${TARGET_PLATFORM}"
mkdir -p "${MICROMAMBA_DIR}"
curl -L -o "${MICROMAMBA_BIN}" "${MICROMAMBA_URL}"
chmod 755 "${MICROMAMBA_BIN}"
echo "micromamba-path=${MICROMAMBA_BIN}" >> ${GITHUB_OUTPUT}
shell: bash

- name: Create installer
id: create-installer
uses: ./
with:
environment-yaml-string: |
channels:
- ${{ startswith(matrix.container-image, 'condaforge/') && 'conda-forge' || 'defaults' }}
dependencies:
- constructor
variables:
${{ startswith(matrix.container-image, 'condaforge/') && 'CONDA_OVERRIDE_GLIBC: 2.17' || '' }}
container-arch: ${{ matrix.container-architecture }}
container-image: ${{ matrix.container-image }}
standalone-location: ${{ steps.download-micromamba.outputs.micromamba-path }}
input-directory: ${{ startswith(matrix.container-image, 'condaforge/') && 'recipes/micromamba' || 'recipes/defaults' }}

- name: Upload installer to Github artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
path: ${{ steps.create-installer.outputs.artifacts-directory }}/*
name: container-test-${{ matrix.artifact-suffix }}
retention-days: 5

- name: Determine installer file name
id: installer-file
env:
ARTIFACTS_DIRECTORY: ${{ steps.create-installer.outputs.artifacts-directory }}
run: |
INSTALLER_FILE=$(find "${ARTIFACTS_DIRECTORY}" -name "*.sh" | head -n 1)
echo "installer-file=${INSTALLER_FILE}" >> ${GITHUB_OUTPUT}
shell: bash

- name: Verify hashes
env:
ARTIFACTS_DIRECTORY: ${{ steps.create-installer.outputs.artifacts-directory }}
INSTALLER_FILE: ${{ steps.installer-file.outputs.installer-file }}
run: |
cd ${ARTIFACTS_DIRECTORY}
sha256sum -c "${INSTALLER_FILE}.sha256"
shell: bash

- name: Create test container
id: test-container
env:
ARTIFACTS_DIRECTORY: ${{ steps.create-installer.outputs.artifacts-directory }}
INSTALLER_FILE: ${{ steps.installer-file.outputs.installer-file }}
run: |
docker run -d --rm -ti --name installer-test\
-v "${ARTIFACTS_DIRECTORY}:${ARTIFACTS_DIRECTORY}"\
-v "${RUNNER_TEMP}":"${RUNNER_TEMP}"\
${{ matrix.container-architecture && format('--platform {0}', matrix.container-architecture) || '' }}\
${{ startswith(matrix.container-image, 'condaforge') && '-e MICROMAMBA_VERSION' || '' }}\
-e INSTALLER_FILE\
debian:latest
shell: bash

- name: Test installer
run: |
export INSTALL_DIR="${HOME}/testinstall"
bash "${INSTALLER_FILE}" -b -p "${INSTALL_DIR}"
. ${INSTALL_DIR}/etc/profile.d/conda.sh
conda activate
conda info --json | python -c "import json, os, sys; from pathlib import Path; info = json.loads(sys.stdin.read()); assert Path(os.environ.get('INSTALL_DIR', '')) == Path(info['root_prefix'])"
${{ startswith(matrix.container-image, 'condaforge') && 'test "$(${INSTALL_DIR}/_conda --version)" == "${MICROMAMBA_VERSION}"' || '' }}
shell: docker exec -i installer-test /bin/bash -eo pipefail {0}
104 changes: 104 additions & 0 deletions .github/workflows/test-defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Test defaults

on:
pull_request:
paths:
- action.yaml
- recipes/defaults/construct.yaml
- .github/workflows/test-defaults.yaml
push:
branches:
- main

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
build-installer:
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
name: Miniconda, ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
with:
activate-environment: ''
run-post: false

- name: Create installer
id: create-installer
uses: ./
with:
environment-yaml-string: |
channels:
- defaults
dependencies:
- constructor
${{ matrix.os == 'windows' && '- nsis=*=*_log_*' || '' }}
variables:
${{ matrix.os == 'macos' && 'CONDA_OVERRIDE_OSX: 12.0' || '' }}
EXT: ${{ matrix.os == 'windows' && 'exe' || 'sh' }}
NSIS_USING_LOG_BUILD: 1
conda-root: ${{ env.CONDA }}
input-directory: recipes/defaults

- name: Upload installer to Github artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
path: ${{ steps.create-installer.outputs.artifacts-directory }}/*
name: defaults-test-${{ matrix.os }}
retention-days: 5

- name: Determine installer file name
id: installer-file
env:
ARTIFACTS_DIRECTORY: ${{ steps.create-installer.outputs.artifacts-directory }}
run: |
SHAFILE=$(find "${ARTIFACTS_DIRECTORY}" -name "*.sha256" | head -n 1)
echo "installer-file=${SHAFILE/\.sha256/}" >> ${GITHUB_OUTPUT}
shell: bash

- name: Verify hashes
env:
ARTIFACTS_DIRECTORY: ${{ steps.create-installer.outputs.artifacts-directory }}
INSTALLER_FILE: ${{ steps.installer-file.outputs.installer-file }}
run: |
UNAME=$(uname)
[[ "${UNAME}" == MINGW* ]] && ARTIFACTS_DIRECTORY=$(cygpath "${ARTIFACTS_DIRECTORY}")
[[ "${UNAME}" == "Darwin" ]] && SHACMD="shasum -a 256" || SHACMD=sha256sum
cd ${ARTIFACTS_DIRECTORY}
${SHACMD} -c "${INSTALLER_FILE}.sha256"
shell: bash

- name: Run installer
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
with:
activate-environment: ''
installation-dir: ${{ runner.temp }}/installer_test
installer-url: file://${{ steps.installer-file.outputs.installer-file }}

- name: Test installer
env:
INSTALL_DIR: ${{ runner.temp }}/installer_test
run: |
if [[ $(uname) == MINGW* ]]; then
CONDA=$(cygpath "${CONDA}")
fi
. ${CONDA}/etc/profile.d/conda.sh
conda activate
conda info --json | python -c "import json, os, sys; from pathlib import Path; info = json.loads(sys.stdin.read()); assert Path(os.environ.get('INSTALL_DIR', '')).samefile(info['root_prefix'])"
if [[ $(uname) == MINGW* ]]; then
test -f "${CONDA}/install.log"
fi
shell: bash
Loading
Loading