Skip to content

Commit

Permalink
Trac #34623: Fix broken gitpod
Browse files Browse the repository at this point in the history
as reported in https://groups.google.com/g/sage-devel/c/JIiytzMsLCU

Here we
- improve error handling in the gitpod initialization scripts that
eliminates the guesswork when something goes wrong
- fix a mistake in the system package information for conda

URL: https://trac.sagemath.org/34623
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Tobias Diez
  • Loading branch information
Release Manager committed Oct 9, 2022
2 parents e91fd4a + 8b1063c commit de29679
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 46 deletions.
29 changes: 29 additions & 0 deletions .gitpod-setup-trac-remote.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Exit on error
set -e

# Setup trac as remote
## In order to push to trac, generate a new key with `ssh-keygen -f tempkey` and save the private key to gitpod `gp env PRIVATE_SSH_KEY="$(<tempkey)"` (or by following https://www.gitpod.io/docs/environment-variables#using-the-account-settings)
## then follow https://doc.sagemath.org/html/en/developer/trac.html#linking-your-public-key-to-your-trac-account to register the public key with trac.
## Afterwards, create a new gitpod workspace.
git remote remove trac 2> /dev/null || true # might still exists from a previous run/prebuild
if [[ -n "${PRIVATE_SSH_KEY}" ]]; then
# Setup ssh key for authentication with trac
mkdir -p ~/.ssh
echo $PRIVATE_SSH_KEY | sed 's/\(-----\(BEGIN\|END\) OPENSSH PRIVATE KEY-----\)/\n\1\n/g' > ~/.ssh/id_rsa
sed -i '/^$/d' ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "PubkeyAcceptedKeyTypes +ssh-rsa" > ~/.ssh/config
ssh-keyscan -H trac.sagemath.org >> ~/.ssh/known_hosts

# Setup trac repo
git remote add trac git@trac.sagemath.org:sage.git -t master -t develop -t $(git branch --show-current)
git remote set-url --push trac git@trac.sagemath.org:sage.git
git fetch trac
git branch -u trac/$(git branch --show-current)
else
# Fallback to sagemath mirror
git remote add trac https://github.com/sagemath/sagetrac-mirror.git -t master -t develop
git remote set-url --push trac pushing-needs-ssh-key
fi
61 changes: 16 additions & 45 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,24 @@ image:
# Start up tasks. https://www.gitpod.io/docs/config-start-tasks/
tasks:
- name: Setup
init: |
# Create conda environment
# Create conda environment, then configure and build sage
init: >-
./bootstrap-conda
mamba env create --file src/environment-dev.yml --prefix venv
conda config --append envs_dirs $(pwd)
conda activate $(pwd)/venv
# Build sage
./bootstrap
./configure --enable-build-as-root --with-python=$CONDA_PREFIX/bin/python --prefix=$CONDA_PREFIX
pip install --no-build-isolation -v -v -e ./pkgs/sage-conf ./pkgs/sage-setup
pip install --no-build-isolation -v -v -e ./src
command: |
# Activate conda environment
conda config --append envs_dirs $(pwd)
conda activate $(pwd)/venv
# RestructuredText extension recommends python extension, although we have already installed it
## So disable the recommendation dialog
&& mamba env create --file src/environment-dev.yml --prefix venv
&& conda config --append envs_dirs $(pwd)
&& conda activate $(pwd)/venv
&& ./bootstrap
&& ./configure --enable-build-as-root --with-python=$CONDA_PREFIX/bin/python --prefix=$CONDA_PREFIX
&& pip install --no-build-isolation -v -v -e ./pkgs/sage-conf ./pkgs/sage-setup
&& pip install --no-build-isolation -v -v -e ./src
# Activate conda environment, set up Trac remote
# RestructuredText extension recommends python extension, although we have already installed it
# So disable the recommendation dialog
command: >-
echo "{\"restructuredtext.pythonRecommendation.disabled\": true}" > /workspace/.vscode-remote/data/Machine/settings.json
# Setup trac as remote
## In order to push to trac, generate a new key with `ssh-keygen -f tempkey` and save the private key to gitpod `gp env PRIVATE_SSH_KEY="$(<tempkey)"` (or by following https://www.gitpod.io/docs/environment-variables#using-the-account-settings)
## then follow https://doc.sagemath.org/html/en/developer/trac.html#linking-your-public-key-to-your-trac-account to register the public key with trac.
## Afterwards, create a new gitpod workspace.
git remote remove trac 2> /dev/null # might still exists from a previous run/prebuild
if [[ -n "${PRIVATE_SSH_KEY}" ]]; then
# Setup ssh key for authentication with trac
mkdir -p ~/.ssh
echo $PRIVATE_SSH_KEY | sed 's/\(-----\(BEGIN\|END\) OPENSSH PRIVATE KEY-----\)/\n\1\n/g' > ~/.ssh/id_rsa
sed -i '/^$/d' ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "PubkeyAcceptedKeyTypes +ssh-rsa" > ~/.ssh/config
ssh-keyscan -H trac.sagemath.org >> ~/.ssh/known_hosts
# Setup trac repo
git remote add trac git@trac.sagemath.org:sage.git -t master -t develop -t $(git branch --show-current)
git remote set-url --push trac git@trac.sagemath.org:sage.git
git fetch trac
git branch -u trac/$(git branch --show-current)
else
# Fallback to sagemath mirror
git remote add trac https://github.com/sagemath/sagetrac-mirror.git -t master -t develop
git remote set-url --push trac pushing-needs-ssh-key
fi
&& conda config --append envs_dirs $(pwd)
&& conda activate $(pwd)/venv
&& ./.gitpod-setup-trac-remote.sh
env:
SAGE_NUM_THREADS: 8

Expand Down
1 change: 0 additions & 1 deletion build/pkgs/setuptools_scm_git_archive/distros/conda.txt

This file was deleted.

0 comments on commit de29679

Please sign in to comment.