diff options
author | Josh Spicer <joshspicer@github.com> | 2022-05-27 20:20:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-27 20:20:32 +0300 |
commit | 54bb1d4e25732c91f33083b625c2b2512a03c472 (patch) | |
tree | 54efe7d2c5a97909126a92c2f215c03216ba88b9 | |
parent | 9611a036f2a971847d007b33f30e9eb506f515f3 (diff) |
update jupyter and ruby features (#26)jospicer/testing-multi-repo-auth
* jekyll and jupyter updates
* add ruby to jekylls pr test
* update jekyll and ruby test
* remove features that dont follow my rules
-rw-r--r-- | .github/workflows/test-all.yaml | 3 | ||||
-rw-r--r-- | .github/workflows/test-pr.yaml | 3 | ||||
-rw-r--r-- | src/gradle/feature.json | 30 | ||||
-rw-r--r-- | src/gradle/install.sh | 133 | ||||
-rw-r--r-- | src/jekyll/feature.json | 16 | ||||
-rw-r--r-- | src/jekyll/install.sh | 60 | ||||
-rw-r--r-- | src/jupyterlab/install.sh | 24 | ||||
-rw-r--r-- | src/maven/feature.json | 30 | ||||
-rw-r--r-- | src/maven/install.sh | 134 | ||||
-rw-r--r-- | test/gradle/test.sh | 12 | ||||
-rw-r--r-- | test/maven/test.sh | 12 | ||||
-rw-r--r-- | test/ruby/test.sh | 3 |
12 files changed, 12 insertions, 448 deletions
diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index 45114bf..296ddeb 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -24,13 +24,10 @@ jobs: "git-lfs", "github-cli", "go", - "java gradle", # Install 'java', then 'gradle' "hugo", "java", - "ruby jekyll", # Install 'ruby', then 'jekyll' "python jupyterlab", # Install 'python', then 'jupyterlab' "kubectl-helm-minikube", - "java maven", # Install 'java', then 'maven' "node", "php", "powershell", diff --git a/.github/workflows/test-pr.yaml b/.github/workflows/test-pr.yaml index f84c9b5..8dc097f 100644 --- a/.github/workflows/test-pr.yaml +++ b/.github/workflows/test-pr.yaml @@ -24,13 +24,10 @@ jobs: git-lfs: ./**/git-lfs/** github-cli: ./**/github-cli/** go: ./**/go/** - 'java gradle': ./**/gradle/** hugo: ./**/hugo/** java: ./**/java/** - jekyll: ./**/jekyll/** 'python jupyterlab': ./**/jupyterlab/** kubectl-helm-minikube: ./**/kubectl-helm-minikube/** - 'java maven': ./**/maven/** node: ./**/node/** php: ./**/php/** powershell: ./**/powershell/** diff --git a/src/gradle/feature.json b/src/gradle/feature.json deleted file mode 100644 index 879a8b5..0000000 --- a/src/gradle/feature.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "id": "gradle", - "name": "Gradle (via SDKMAN!)", - "documentationURL": "https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/gradle.md", - "options": { - "version": { - "type": "string", - "proposals": [ - "latest", - "none", - "7", - "6", - "5" - ], - "default": "latest", - "description": "Select or enter a Gradle version to install" - } - }, - "extensions": [ - "vscjava.vscode-java-pack" - ], - "containerEnv": { - "SDKMAN_DIR": "${SDKMAN_DIR:-\"/usr/local/sdkman\"}", - "PATH": "${SDKMAN_DIR}/bin:${SDKMAN_DIR}/candidates/gradle/current/bin:${PATH}" - }, - "install": { - "app": "", - "file": "install.sh" - } -}
\ No newline at end of file diff --git a/src/gradle/install.sh b/src/gradle/install.sh deleted file mode 100644 index 45ae55d..0000000 --- a/src/gradle/install.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env bash -#------------------------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. -#------------------------------------------------------------------------------------------------------------- -# -# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/gradle.md -# Maintainer: The VS Code and Codespaces Teams -# -# Syntax: ./gradle-debian.sh [Gradle version] [non-root user] [Update rc files flag] - -GRADLE_VERSION=${1:-"latest"} -USERNAME=${2:-"automatic"} -UPDATE_RC=${3:-"true"} -export SDKMAN_DIR=${SDKMAN_DIR:-"/usr/local/sdkman"} - -set -e - -if [ "$(id -u)" -ne 0 ]; then - echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' - exit 1 -fi - -# Ensure that login shells get the correct path if the user updated the PATH using ENV. -rm -f /etc/profile.d/00-restore-env.sh -echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh -chmod +x /etc/profile.d/00-restore-env.sh - -# Determine the appropriate non-root user -if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then - USERNAME="" - POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") - for CURRENT_USER in ${POSSIBLE_USERS[@]}; do - if id -u ${CURRENT_USER} > /dev/null 2>&1; then - USERNAME=${CURRENT_USER} - break - fi - done - if [ "${USERNAME}" = "" ]; then - USERNAME=root - fi -elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then - USERNAME=root -fi - -updaterc() { - if [ "${UPDATE_RC}" = "true" ]; then - echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then - echo -e "$1" >> /etc/bash.bashrc - fi - if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then - echo -e "$1" >> /etc/zsh/zshrc - fi - fi -} - -# Function to run apt-get if needed -apt_get_update_if_needed() -{ - if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then - echo "Running apt-get update..." - apt-get update - else - echo "Skipping apt-get update." - fi -} - -# Checks if packages are installed and installs them if not -check_packages() { - if ! dpkg -s "$@" > /dev/null 2>&1; then - apt_get_update_if_needed - apt-get -y install --no-install-recommends "$@" - fi -} - -# Use SDKMAN to install something using a partial version match -sdk_install() { - local install_type=$1 - local requested_version=$2 - local prefix=$3 - local suffix="${4:-"\\s*"}" - local full_version_check=${5:-".*-[a-z]+"} - if [ "${requested_version}" = "none" ]; then return; fi - # Blank will install latest stable version - if [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "default" ]; then - requested_version="" - elif echo "${requested_version}" | grep -oE "${full_version_check}" > /dev/null 2>&1; then - echo "${requested_version}" - else - local regex="${prefix}\\K[0-9]+\\.[0-9]+\\.[0-9]+${suffix}" - local version_list="$(. ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk list ${install_type} 2>&1 | grep -oP "${regex}" | tr -d ' ' | sort -rV)" - if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ]; then - requested_version="$(echo "${version_list}" | head -n 1)" - else - set +e - requested_version="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")" - set -e - fi - if [ -z "${requested_version}" ] || ! echo "${version_list}" | grep "^${requested_version//./\\.}$" > /dev/null 2>&1; then - echo -e "Version $2 not found. Available versions:\n${version_list}" >&2 - exit 1 - fi - fi - su ${USERNAME} -c "umask 0002 && . ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install ${install_type} ${requested_version} && sdk flush archives && sdk flush temp" -} - -export DEBIAN_FRONTEND=noninteractive - -# Install dependencies -check_packages curl ca-certificates zip unzip sed - -# Install sdkman if not installed -if [ ! -d "${SDKMAN_DIR}" ]; then - # Create sdkman group, dir, and set sticky bit - if ! cat /etc/group | grep -e "^sdkman:" > /dev/null 2>&1; then - groupadd -r sdkman - fi - usermod -a -G sdkman ${USERNAME} - umask 0002 - # Install SDKMAN - curl -sSL "https://get.sdkman.io?rcupdate=false" | bash - chown -R :sdkman ${SDKMAN_DIR} - find ${SDKMAN_DIR} -type d | xargs -d '\n' chmod g+s - # Add sourcing of sdkman into bashrc/zshrc files (unless disabled) - updaterc "export SDKMAN_DIR=${SDKMAN_DIR}\n. \${SDKMAN_DIR}/bin/sdkman-init.sh" -fi - -# Install gradle -sdk_install gradle ${GRADLE_VERSION} '\s\s' '\s\s' '^[0-9]+\.[0-9]+\.[0-9]+$' -updaterc '[ -z "${GRADLE_USER_HOME}" ] && export GRADLE_USER_HOME=${HOME}/.gradle' - -echo "Done!" diff --git a/src/jekyll/feature.json b/src/jekyll/feature.json deleted file mode 100644 index 852aa30..0000000 --- a/src/jekyll/feature.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "id": "jekyll", - "name": "Jekyll", - "options": { - "version": { - "type": "string", - "proposals": ["latest"], - "default": "latest", - "description": "Select or enter a version." - } - }, - "install": { - "app": "", - "file": "install.sh" - } -} diff --git a/src/jekyll/install.sh b/src/jekyll/install.sh deleted file mode 100644 index 53efa82..0000000 --- a/src/jekyll/install.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash -#------------------------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. -#------------------------------------------------------------------------------------------------------------- -# -# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/hugo.md -# Maintainer: The VS Code and Codespaces Teams -# -# Syntax: ./jekyll-debian.sh [Jekyll version] [Non-root user] [Add rc files flag] - -VERSION=${1:-"latest"} -USERNAME=${2:-"automatic"} - -set -e - -# If in automatic mode, determine if a user already exists, if not use codespace -if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then - USERNAME="" - POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") - for CURRENT_USER in ${POSSIBLE_USERS[@]}; do - if id -u ${CURRENT_USER} > /dev/null 2>&1; then - USERNAME=${CURRENT_USER} - break - fi - done - if [ "${USERNAME}" = "" ]; then - USERNAME=codespace - fi -elif [ "${USERNAME}" = "none" ]; then - USERNAME=root - USER_UID=0 - USER_GID=0 -fi - -# Use sudo to run as non-root user is not already running -sudoUserIf() -{ - if [ "$(id -u)" -eq 0 ] && [ "${USERNAME}" != "root" ]; then - sudo -u ${USERNAME} "$@" - else - "$@" - fi -} - -# If we don't yet have Ruby installed, exit. -if ! /usr/local/rvm/rubies/default/bin/ruby --version > /dev/null ; then - echo "You need to install Ruby before installing Jekyll." - exit 1 -fi - -# If we don't already have Jekyll installed, install it now. -if ! jekyll --version > /dev/null ; then - echo "Installing Jekyll..." - if [ "${VERSION}" = "latest" ]; then - PATH="/usr/local/rvm/rubies/default/bin:${PATH}" /usr/local/rvm/rubies/default/bin/gem install jekyll - else - PATH="/usr/local/rvm/rubies/default/bin:${PATH}" /usr/local/rvm/rubies/default/bin/gem install jekyll -v "${VERSION}" - fi -fi diff --git a/src/jupyterlab/install.sh b/src/jupyterlab/install.sh index 591a126..4d426a4 100644 --- a/src/jupyterlab/install.sh +++ b/src/jupyterlab/install.sh @@ -9,13 +9,18 @@ # # Syntax: ./jupyter-debian.sh -set -e +set -ex VERSION=${1:-"latest"} USERNAME=${2:-"automatic"} PYTHON=${3:-"python"} ALLOW_ALL_ORIGINS=${4:-""} +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + # If in automatic mode, determine if a user already exists, if not use vscode if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then USERNAME="" @@ -35,22 +40,13 @@ elif [ "${USERNAME}" = "none" ]; then USER_GID=0 fi -# Make sure we run the command as non-root user -sudoUserIf() { - if [ "$(id -u)" -eq 0 ] && [ "${USERNAME}" != "root" ]; then - sudo -u ${USERNAME} "$@" - else - "$@" - fi -} - addToJupyterConfig() { JUPYTER_DIR="/home/${USERNAME}/.jupyter" JUPYTER_CONFIG="${JUPYTER_DIR}/jupyter_notebook_config.py" # Make sure the config file exists - test -d ${JUPYTER_DIR} || sudoUserIf mkdir ${JUPYTER_DIR} - test -f ${JUPYTER_CONFIG} || sudoUserIf touch ${JUPYTER_CONFIG} + test -d ${JUPYTER_DIR} || mkdir ${JUPYTER_DIR} + test -f ${JUPYTER_CONFIG} || touch ${JUPYTER_CONFIG} # Don't write the same line more than once grep -q ${1} ${JUPYTER_CONFIG} || echo ${1} >> ${JUPYTER_CONFIG} @@ -65,9 +61,9 @@ fi # pip skips installation if JupyterLab is already installed echo "Installing JupyterLab..." if [ "${VERSION}" = "latest" ]; then - sudoUserIf ${PYTHON} -m pip install jupyterlab --no-cache-dir + ${PYTHON} -m pip install jupyterlab --no-cache-dir else - sudoUserIf ${PYTHON} -m pip install jupyterlab=="${VERSION}" --no-cache-dir + ${PYTHON} -m pip install jupyterlab=="${VERSION}" --no-cache-dir fi if [ "${ALLOW_ALL_ORIGINS}" = 'true' ]; then diff --git a/src/maven/feature.json b/src/maven/feature.json deleted file mode 100644 index 04c1774..0000000 --- a/src/maven/feature.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "id": "maven", - "name": "Maven (via SDKMAN!)", - "documentationURL": "https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/maven.md", - "options": { - "version": { - "type": "string", - "proposals": [ - "latest", - "none", - "3.8", - "3.6", - "3.5" - ], - "default": "latest", - "description": "Select or enter a Maven version to install" - } - }, - "extensions": [ - "vscjava.vscode-java-pack" - ], - "containerEnv": { - "SDKMAN_DIR": "${SDKMAN_DIR:-\"/usr/local/sdkman\"}", - "PATH": "${SDKMAN_DIR}/bin:${SDKMAN_DIR}/candidates/maven/current/bin:${PATH}" - }, - "install": { - "app": "", - "file": "install.sh" - } -}
\ No newline at end of file diff --git a/src/maven/install.sh b/src/maven/install.sh deleted file mode 100644 index 2d6e81f..0000000 --- a/src/maven/install.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env bash -#------------------------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. -#------------------------------------------------------------------------------------------------------------- -# -# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/maven.md -# Maintainer: The VS Code and Codespaces Teams -# -# Syntax: ./maven-debian.sh [maven version] [non-root user] [Update rc files flag] - -MAVEN_VERSION=${1:-"latest"} -USERNAME=${2:-"automatic"} -UPDATE_RC=${3:-"true"} - -export SDKMAN_DIR=${SDKMAN_DIR:-"/usr/local/sdkman"} - -set -e - -if [ "$(id -u)" -ne 0 ]; then - echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' - exit 1 -fi - -# Ensure that login shells get the correct path if the user updated the PATH using ENV. -rm -f /etc/profile.d/00-restore-env.sh -echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh -chmod +x /etc/profile.d/00-restore-env.sh - -# Determine the appropriate non-root user -if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then - USERNAME="" - POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") - for CURRENT_USER in ${POSSIBLE_USERS[@]}; do - if id -u ${CURRENT_USER} > /dev/null 2>&1; then - USERNAME=${CURRENT_USER} - break - fi - done - if [ "${USERNAME}" = "" ]; then - USERNAME=root - fi -elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then - USERNAME=root -fi - -updaterc() { - if [ "${UPDATE_RC}" = "true" ]; then - echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then - echo -e "$1" >> /etc/bash.bashrc - fi - if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then - echo -e "$1" >> /etc/zsh/zshrc - fi - fi -} - -# Function to run apt-get if needed -apt_get_update_if_needed() -{ - if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then - echo "Running apt-get update..." - apt-get update - else - echo "Skipping apt-get update." - fi -} - -# Checks if packages are installed and installs them if not -check_packages() { - if ! dpkg -s "$@" > /dev/null 2>&1; then - apt_get_update_if_needed - apt-get -y install --no-install-recommends "$@" - fi -} - -# Use SDKMAN to install something using a partial version match -sdk_install() { - local install_type=$1 - local requested_version=$2 - local prefix=$3 - local suffix="${4:-"\\s*"}" - local full_version_check=${5:-".*-[a-z]+"} - if [ "${requested_version}" = "none" ]; then return; fi - # Blank will install latest stable version - if [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "default" ]; then - requested_version="" - elif echo "${requested_version}" | grep -oE "${full_version_check}" > /dev/null 2>&1; then - echo "${requested_version}" - else - local regex="${prefix}\\K[0-9]+\\.[0-9]+\\.[0-9]+${suffix}" - local version_list="$(. ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk list ${install_type} 2>&1 | grep -oP "${regex}" | tr -d ' ' | sort -rV)" - if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ]; then - requested_version="$(echo "${version_list}" | head -n 1)" - else - set +e - requested_version="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")" - set -e - fi - if [ -z "${requested_version}" ] || ! echo "${version_list}" | grep "^${requested_version//./\\.}$" > /dev/null 2>&1; then - echo -e "Version $2 not found. Available versions:\n${version_list}" >&2 - exit 1 - fi - fi - su ${USERNAME} -c "umask 0002 && . ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install ${install_type} ${requested_version} && sdk flush archives && sdk flush temp" -} - -export DEBIAN_FRONTEND=noninteractive - -# Install dependencies -check_packages curl ca-certificates zip unzip sed - -# Install sdkman if not installed -if [ ! -d "${SDKMAN_DIR}" ]; then - # Create sdkman group, dir, and set sticky bit - if ! cat /etc/group | grep -e "^sdkman:" > /dev/null 2>&1; then - groupadd -r sdkman - fi - usermod -a -G sdkman ${USERNAME} - umask 0002 - # Install SDKMAN - curl -sSL "https://get.sdkman.io?rcupdate=false" | bash - chown -R :sdkman ${SDKMAN_DIR} - find ${SDKMAN_DIR} -type d | xargs -d '\n' chmod g+s - # Add sourcing of sdkman into bashrc/zshrc files (unless disabled) - updaterc "export SDKMAN_DIR=${SDKMAN_DIR}\n. \${SDKMAN_DIR}/bin/sdkman-init.sh" -fi - -# Install Maven -sdk_install maven ${MAVEN_VERSION} '\s\s' '\s\s' '^[0-9]+\.[0-9]+\.[0-9]+$' -updaterc '[ -z "$M2" ] && export M2=$HOME/.m2' - -echo "Done!"
\ No newline at end of file diff --git a/test/gradle/test.sh b/test/gradle/test.sh deleted file mode 100644 index 9a804e2..0000000 --- a/test/gradle/test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -# Optional: Import test library -source dev-container-features-test-lib - -# Definition specific tests -check "version" gradle --version - -# Report result -reportResults
\ No newline at end of file diff --git a/test/maven/test.sh b/test/maven/test.sh deleted file mode 100644 index 0cb99ea..0000000 --- a/test/maven/test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -# Optional: Import test library -source dev-container-features-test-lib - -# Definition specific tests -check "version" mvn --version - -# Report result -reportResults
\ No newline at end of file diff --git a/test/ruby/test.sh b/test/ruby/test.sh index 1927cb6..4c1cc36 100644 --- a/test/ruby/test.sh +++ b/test/ruby/test.sh @@ -6,7 +6,8 @@ set -e source dev-container-features-test-lib # Definition specific tests -check "version" ruby --version +check "ruby version" ruby --version +check "gem version" gem --version # Report result reportResults
\ No newline at end of file |