|
1 | | -# CircleCI build config to test different versions of Singuarity |
2 | 1 | version: 2.1 |
3 | 2 |
|
4 | | -orbs: |
5 | | - singularity: singularity/[email protected] |
| 3 | +# Modified from hpcng/singularity |
6 | 4 |
|
7 | 5 | workflows: |
8 | 6 | version: 2 |
9 | | - test: |
| 7 | + build_and_test: |
10 | 8 | jobs: |
11 | | - - run-spython-ci-tests: &base_job |
| 9 | + - test_singularity_python: |
12 | 10 | filters: |
13 | 11 | branches: |
14 | 12 | ignore: master |
15 | | - name: "Latest Singularity - Python 3" |
16 | | - run-linter: false |
17 | | - singularity: 3.5.0 |
18 | | - singularity-3: true |
19 | | - - run-spython-ci-tests: |
20 | | - <<: *base_job |
21 | | - name: "Singularity 3.2.1 - Python 3" |
22 | | - singularity: 3.2.1 |
23 | | - run-linter: true # run linter once, must be Python 3 |
24 | | - - run-spython-ci-tests: |
25 | | - <<: *base_job |
26 | | - name: "Singularity 3.1.0 - Python 3" |
27 | | - singularity: 3.1.0 |
28 | | - - run-spython-ci-tests: |
29 | | - <<: *base_job |
30 | | - name: "Singularity 2 - Python 3" |
31 | | - singularity: 2.6.1 |
32 | | - singularity-3: false |
33 | 13 |
|
34 | | -waitforapt: &waitforapt |
35 | | - name: Remove cloud init lock |
36 | | - command: | |
37 | | - while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 10; done |
38 | | - while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1; do echo 'Waiting for autoupdates to complete...'; sleep 10; done |
39 | | - echo 'Waiting for instance to really be ready...' |
40 | | - sleep 30 |
41 | | - sudo rm -rf /var/lib/apt/lists/lock |
42 | | - sudo rm /var/lib/dpkg/lock && sudo dpkg --configure -a |
| 14 | +setup_environment: &setup_environment |
| 15 | + name: Setup environment |
| 16 | + command: |- |
| 17 | + echo 'set -x' >> $BASH_ENV |
| 18 | + echo 'export GOPATH=$HOME/go' >> $BASH_ENV |
| 19 | + echo 'export GOROOT=/usr/local/go' >> $BASH_ENV |
| 20 | + echo 'export GOBIN=$HOME/go/bin' >> $BASH_ENV |
| 21 | + echo 'export PATH=$GOBIN:$GOROOT/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin' >> $BASH_ENV |
| 22 | + env | sed -e 's,^,ENV: ,' | sort |
| 23 | + test -e $BASH_ENV && sed -e 's,^,BASH_ENV: ,' < $BASH_ENV |
43 | 24 |
|
| 25 | +update_go: &update_go |
| 26 | + name: Update Go to 1.14.9 |
| 27 | + working_directory: /tmp |
| 28 | + command: |- |
| 29 | + wget https://dl.google.com/go/go1.14.9.linux-amd64.tar.gz |
| 30 | + sudo rm -rf $GOROOT |
| 31 | + sudo tar -C /usr/local -xzf go1.14.9.linux-amd64.tar.gz |
| 32 | + sudo ln -s $GOROOT/bin/go /usr/local/bin/go |
44 | 33 |
|
| 34 | +fetch_deb_deps: &fetch_deb_deps |
| 35 | + name: Fetch deps |
| 36 | + working_directory: /tmp |
| 37 | + command: |- |
| 38 | + # https://discuss.circleci.com/t/could-not-get-lock-var-lib-apt-lists-lock/28337/4 |
| 39 | + sudo killall -9 apt-get || true && \ |
| 40 | + sudo apt-get update -y && \ |
| 41 | + sudo apt-get install -y build-essential squashfs-tools libseccomp-dev cryptsetup |
| 42 | +
|
| 43 | +build_singularity: &install_singularity |
| 44 | + name: Build Singularity |
| 45 | + working_directory: ~/go/singularity |
| 46 | + command: |- |
| 47 | + cd ~/go |
| 48 | + wget https://github.com/hpcng/singularity/releases/download/v3.7.1/singularity-3.7.1.tar.gz && \ |
| 49 | + tar -xzvf singularity-3.7.1.tar.gz && \ |
| 50 | + cd singularity |
| 51 | + ./mconfig -p /usr/local && \ |
| 52 | + make -C builddir && \ |
| 53 | + sudo make -C builddir install |
| 54 | + |
45 | 55 | install_spython: &install_spython |
46 | 56 | name: install spython |
47 | | - command: | |
| 57 | + command: |- |
| 58 | + export PATH=~/conda/Python3/bin:$PATH |
| 59 | + which python |
48 | 60 | pip uninstall spython --yes || echo "Not installed" |
49 | 61 | python --version |
50 | 62 | python setup.py install |
51 | 63 |
|
52 | | -commands: |
53 | | - install_dependencies: |
54 | | - steps: |
55 | | - - run: | |
56 | | - PYTHON_VERSION=3 |
57 | | - CONDA_PATH="$HOME/conda/Python${PYTHON_VERSION}" |
58 | | - echo 'export PATH="'"$CONDA_PATH"'/bin:$PATH"' >> "$BASH_ENV" |
59 | | - source "$BASH_ENV" |
60 | | - if [ ! -d "$CONDA_PATH" ]; then |
61 | | - CONDA_SCRIPT=Miniconda${PYTHON_VERSION}-latest-Linux-x86_64.sh |
62 | | - wget https://repo.anaconda.com/miniconda/$CONDA_SCRIPT |
63 | | - /bin/bash $CONDA_SCRIPT -b -p $CONDA_PATH |
64 | | - else |
65 | | - echo "Miniconda is already installed, continuing to build." |
66 | | - fi |
67 | | - python --version |
68 | | - [ $(python -c'import sys;print(sys.version_info.major)') -eq $PYTHON_VERSION ] |
| 64 | +install_dependencies: &install_dependencies |
| 65 | + name: install dependencies |
| 66 | + command: |- |
| 67 | + PYTHON_VERSION=3 |
| 68 | + CONDA_PATH="$HOME/conda/Python${PYTHON_VERSION}" |
| 69 | + echo 'export PATH="'"$CONDA_PATH"'/bin:$PATH"' >> "$BASH_ENV" |
| 70 | + source "$BASH_ENV" |
| 71 | + if [ ! -d "$CONDA_PATH" ]; then |
| 72 | + CONDA_SCRIPT=Miniconda${PYTHON_VERSION}-latest-Linux-x86_64.sh |
| 73 | + wget https://repo.anaconda.com/miniconda/$CONDA_SCRIPT |
| 74 | + /bin/bash $CONDA_SCRIPT -b -p $CONDA_PATH |
| 75 | + else |
| 76 | + echo "Miniconda is already installed, continuing to build." |
| 77 | + fi |
| 78 | + python --version |
| 79 | + [ $(python -c'import sys;print(sys.version_info.major)') -eq $PYTHON_VERSION ] |
69 | 80 |
|
70 | | - pip install --upgrade pytest |
71 | | - pip install black || true |
| 81 | + pip install --upgrade pytest |
| 82 | + pip install black || true |
72 | 83 |
|
73 | 84 | run_linter: &run_linter |
74 | 85 | name: run linter |
75 | | - command: | |
| 86 | + command: |- |
| 87 | + export PATH=~/conda/Python3/bin:$PATH |
76 | 88 | cd ~/repo |
77 | 89 | black --check spython |
78 | 90 |
|
79 | 91 | test_spython: &test_spython |
80 | 92 | name: Test Singularity Python |
81 | | - command: pytest ~/repo/spython |
| 93 | + command: |- |
| 94 | + export PATH=~/conda/Python3/bin:$PATH |
| 95 | + pytest ~/repo/spython |
| 96 | +
|
82 | 97 |
|
83 | 98 | jobs: |
84 | | - run-spython-ci-tests: |
85 | | - parameters: |
86 | | - run-linter: |
87 | | - type: boolean |
88 | | - default: false |
89 | | - singularity: |
90 | | - type: string |
91 | | - description: "Singularity version" |
92 | | - singularity-3: |
93 | | - type: boolean |
94 | | - description: "Set to true for singularity 3, false for singularity 2" |
95 | | - default: true |
96 | | - machine: true |
| 99 | + test_singularity_python: |
97 | 100 | working_directory: ~/repo |
| 101 | + machine: |
| 102 | + image: ubuntu-2004:202008-01 |
98 | 103 | steps: |
99 | 104 | - checkout |
100 | 105 | - restore_cache: |
101 | 106 | keys: v2-dependencies |
102 | | - - install_dependencies |
103 | | - - run: *waitforapt |
104 | | - - when: |
105 | | - condition: << parameters.singularity-3 >> |
106 | | - steps: |
107 | | - - singularity/install-go: |
108 | | - go-version: "1.13" |
109 | | - - singularity/debian-install-3: |
110 | | - singularity-version: << parameters.singularity >> |
111 | | - - unless: |
112 | | - condition: << parameters.singularity-3 >> |
113 | | - steps: |
114 | | - - singularity/debian-install-2: |
115 | | - singularity-version: << parameters.singularity >> |
| 107 | + - run: *install_dependencies |
| 108 | + - run: *setup_environment |
| 109 | + - run: *update_go |
| 110 | + - run: *fetch_deb_deps |
| 111 | + - run: *install_singularity |
116 | 112 | - run: *install_spython |
117 | 113 | - save_cache: |
118 | 114 | paths: |
119 | 115 | - ~/conda |
120 | | - key: v2-dependencies |
121 | | - - when: |
122 | | - condition: << parameters.run-linter >> |
123 | | - steps: |
124 | | - - run: *run_linter |
| 116 | + key: v3-dependencies |
| 117 | + - run: *run_linter |
125 | 118 | - run: *test_spython |
0 commit comments