Minor updates. #146
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lingfei Wang, 2022. All rights reserved. | |
name: Installation script test | |
on: | |
schedule: | |
- cron: '20 7 * * 1' | |
push: | |
paths: | |
- '.github/workflows/ci-install.yml' | |
- '.github/actions/install-bash/**' | |
- README.rst | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'Commit or branch to run action on' | |
required: true | |
default: 'dev' | |
jobs: | |
install-script-bash: | |
runs-on: ubuntu-latest | |
outputs: | |
run: ${{ steps.runscript.outputs.run }} | |
steps: | |
- name: Show version | |
id: version | |
run: | | |
if [ "a${{ inputs.ref }}" != "a" ]; then | |
v="${{ inputs.ref }}" | |
elif [ "a${GITHUB_REF}" != "a" ]; then | |
v="${GITHUB_REF}" | |
elif [ "a${{ github.event.repository.default_branch }}" != "a" ]; then | |
v="${{ github.event.repository.default_branch }}" | |
else | |
exit 1 | |
fi | |
echo "$v" | |
echo "version=$v" >> $GITHUB_OUTPUT | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.version.outputs.version }} | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- name: Obtain install script | |
id: runscript | |
run: | | |
# Install command in README.rst (indented in Installation section) | |
# Get first code-block in section Installation | |
linestart=$(grep -n '^Installation' README.rst | awk -F: '{print $1}' | head -n 1) | |
lineend=$(tail -n +$(( linestart + 2 )) README.rst | grep -n '^==' | awk -F: '{print $1}' | head -n 1) | |
linestart2=$(tail -n +$linestart README.rst | head -n $lineend | grep -n '^Option [0-9]: with .*bash script' | awk -F: '{print $1}' | head -n 1) | |
echo "Step 1" | |
tail -n +$linestart README.rst | head -n $lineend | |
linestart=$(( linestart + linestart2 )) | |
lineend=$(tail -n +$(( linestart + 2 )) README.rst | head -n $lineend | grep -n '^--' | awk -F: '{print $1}' | head -n 1) | |
echo "Step 2" | |
tail -n +$(( linestart + 2 )) README.rst | head -n $lineend | |
linestart2=$(tail -n +$linestart README.rst | head -n $lineend | grep -n '^.. code-block::' | awk -F: '{print $1}' | head -n 1) | |
echo "Step 3" | |
tail -n +$linestart README.rst | head -n $lineend | |
lineend2=$(tail -n +$linestart README.rst | head -n $lineend | tail -n +$(( linestart2 + 1 )) | grep -n '^.. code-block::' | awk -F: '{print $1}' | head -n 1) | |
echo "Step 4" | |
tail -n +$linestart README.rst | head -n $lineend | |
echo "Step 5" | |
tail -n +$linestart README.rst | head -n $lineend | tail -n +$(( linestart2 + 1 )) | |
s1="$(tail -n +$linestart README.rst | head -n $lineend | tail -n +$linestart2 | head -n $lineend2 | grep '^[[:blank:]]' | sed 's/^[[:space:]]*//g')" | |
echo "Step 6" | |
tail -n +$linestart README.rst | head -n $lineend | |
echo "Step 7" | |
tail -n +$linestart README.rst | head -n $lineend | tail -n +$linestart2 | head -n $lineend2 | |
echo "Step 8" | |
echo "$s1" | |
#If failed here: update this line and the same line in /.github/actions/install-bash/action.yml to match the lines in /README.rst | |
cmp <(echo "$s1") <(echo "wget https://tinyurl.com/dictys -O - | bash") || exit 1 | |
echo "run=$s1" >> $GITHUB_OUTPUT | |
install-linux-bash: | |
runs-on: ubuntu-latest | |
needs: install-script-bash | |
steps: | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- name: Add conda to system path | |
run: | | |
# $CONDA is an environment variable pointing to the root of the miniconda directory | |
echo $CONDA/bin >> $GITHUB_PATH | |
- name: Test install | |
run: | | |
echo '::group::Test install output' | |
${{ needs.install-script-bash.outputs.run }} | |
echo '::endgroup::' | |
install-script-conda: | |
runs-on: ubuntu-latest | |
outputs: | |
run: ${{ steps.runscript.outputs.run }} | |
steps: | |
- name: Show version | |
id: version | |
run: | | |
if [ "a${{ inputs.ref }}" != "a" ]; then | |
v="${{ inputs.ref }}" | |
elif [ "a${GITHUB_REF}" != "a" ]; then | |
v="${GITHUB_REF}" | |
elif [ "a${{ github.event.repository.default_branch }}" != "a" ]; then | |
v="${{ github.event.repository.default_branch }}" | |
else | |
exit 1 | |
fi | |
echo "$v" | |
echo "version=$v" >> $GITHUB_OUTPUT | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.version.outputs.version }} | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- name: Obtain install script | |
id: run0 | |
run: | | |
# Install command in README.rst (indented in Installation section) | |
# Get first code-block in section Installation | |
linestart=$(grep -n '^Installation' README.rst | awk -F: '{print $1}' | head -n 1) | |
lineend=$(tail -n +$(( linestart + 2 )) README.rst | grep -n '^==' | awk -F: '{print $1}' | head -n 1) | |
echo "Step 1" | |
tail -n +$linestart README.rst | head -n $lineend | |
linestart2=$(tail -n +$linestart README.rst | head -n $lineend | grep -n '^Option [0-9]: with .*conda$' | awk -F: '{print $1}' | head -n 1) | |
linestart=$(( linestart + linestart2 )) | |
echo "Step 2" | |
tail -n +$(( linestart + 2 )) README.rst | head -n $lineend | |
lineend=$(tail -n +$(( linestart + 2 )) README.rst | head -n $lineend | grep -n '^--' | awk -F: '{print $1}' | head -n 1) | |
linestart2=$(tail -n +$linestart README.rst | head -n $lineend | grep -n '^.. code-block::' | awk -F: '{print $1}' | head -n 1) | |
echo "Step 3" | |
tail -n +$linestart README.rst | head -n $lineend | tail -n +$(( linestart2 + 1 )) | |
lineend2=$(tail -n +$linestart README.rst | head -n $lineend | tail -n +$(( linestart2 + 1 )) | grep -n '^.. code-block::' | awk -F: '{print $1}' | head -n 1) | |
echo "Step 4" | |
echo "$linestart" | |
echo "$lineend" | |
tail -n +$linestart README.rst | head -n $lineend | |
echo "Step 5" | |
echo "$linestart2" | |
echo "$lineend2" | |
tail -n +$linestart README.rst | head -n $lineend | tail -n +$linestart2 | head -n $lineend2 | |
s1="$(tail -n +$linestart README.rst | head -n $lineend | tail -n +$linestart2 | head -n $lineend2 | grep '^[[:blank:]]' | sed 's/^[[:space:]]*//g')" | |
#If failed here: update this line and the same line in /.github/actions/install-conda/action.yml to match the lines in /README.rst | |
cmp <(echo "$s1") <(echo "conda create -y -n dictys -c conda-forge python=3.9 mamba"; echo ". activate dictys"; echo "mamba install -y -c lingfeiwang -c bioconda -c conda-forge -c pytorch dictys pytorch torchvision torchaudio cpuonly") || exit 1 | |
echo "run<<EOF" >> $GITHUB_ENV | |
echo "$s1" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- id: runscript | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
core.setOutput("run", `${{ env.run }}`); | |
install-linux-conda: | |
runs-on: ubuntu-latest | |
needs: install-script-conda | |
steps: | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- name: Add conda to system path | |
run: | | |
# $CONDA is an environment variable pointing to the root of the miniconda directory | |
echo $CONDA/bin >> $GITHUB_PATH | |
- name: Test install | |
run: | | |
echo '::group::Test install output' | |
${{ needs.install-script-conda.outputs.run }} | |
echo '::endgroup::' | |
install-linux: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9","3.10",""] | |
cuda-version: ["11.3",""] | |
steps: | |
- name: Show version | |
id: version | |
run: | | |
if [ "a${{ inputs.ref }}" != "a" ]; then | |
v="${{ inputs.ref }}" | |
elif [ "a${GITHUB_REF}" != "a" ]; then | |
v="${GITHUB_REF}" | |
elif [ "a${{ github.event.repository.default_branch }}" != "a" ]; then | |
v="${{ github.event.repository.default_branch }}" | |
else | |
exit 1 | |
fi | |
echo "$v" | |
echo "version=$v" >> $GITHUB_OUTPUT | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.version.outputs.version }} | |
- name: Install | |
uses: ./.github/actions/install-bash | |
with: | |
python-version: ${{ matrix.python-version }} | |
cuda-version: ${{ matrix.cuda-version }} |