-
Notifications
You must be signed in to change notification settings - Fork 145
151 lines (123 loc) · 6.91 KB
/
scripts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Tests for scripts
on: [push, pull_request]
concurrency:
group: ${{format('{0}:{1}:{2}', github.repository, github.ref, github.workflow)}}
cancel-in-progress: true
jobs:
scripts:
runs-on: ubuntu-latest
strategy:
matrix:
repo: [easybuild-framework, easybuild-easyblocks, easybuild-easyconfigs, easybuild]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: install EasyBuild (framework-only)
run: |
pip install easybuild-framework
eb --version
- name: install modules tool
run: |
sudo apt-get install lua5.2 liblua5.2-dev lua-filesystem lua-posix tcl-dev
# fix for lua-posix packaging issue, see https://bugs.launchpad.net/ubuntu/+source/lua-posix/+bug/1752082
# needed for Ubuntu 18.04, but not for Ubuntu 20.04, so skipping symlinking if posix.so already exists
if [ ! -e /usr/lib/x86_64-linux-gnu/lua/5.2/posix.so ] ; then
sudo ln -s /usr/lib/x86_64-linux-gnu/lua/5.2/posix_c.so /usr/lib/x86_64-linux-gnu/lua/5.2/posix.so
fi
# use script provided by easybuild-framework to install recent Lmod
source install_eb_dep.sh Lmod-8.3.8 $HOME
echo $MOD_INIT > $HOME/mod_init
echo $PATH > $HOME/path
- name: clone repo
run: |
cd $HOME
git clone https://github.com/easybuilders/${{matrix.repo}}.git
- name: test create_source_tarball.sh script
run: |
source $(cat $HOME/mod_init); type module
export PATH=$(cat $HOME/path)
cd $HOME/${{matrix.repo}}
git checkout main
# file to figure out the version from depends on repo
if [[ ${{matrix.repo}} == "easybuild-framework" ]]; then
version_file=easybuild/tools/version.py
elif [[ ${{matrix.repo}} == "easybuild-easyblocks" ]]; then
version_file=easybuild/easyblocks/__init__.py
else
version_file=setup.py
fi
version=$(grep '^.*VERSION[ ]*=' $version_file | head -1 |sed 's/[^0-9]*\([0-9a-zA-Z.]*\).*/\1/g')
echo "${{matrix.repo}} version: $version"
echo "testing with '$GITHUB_WORKSPACE/scripts/create_source_tarball.sh ${{matrix.repo}} $version'"
out=$HOME/out.txt
echo "================================================================================================"
# check use of script outside correct directory
cd $HOME
($GITHUB_WORKSPACE/scripts/create_source_tarball.sh ${{matrix.repo}} $version 2>&1 | tee $out) || true
grep "ERROR: Expected to be in ${{matrix.repo}} directory" $out
echo "Expected error found in output: OK!"
echo "================================================================================================"
cd ${{matrix.repo}}
# script should make sure we're on main branch
git checkout develop &> /dev/null
($GITHUB_WORKSPACE/scripts/create_source_tarball.sh ${{matrix.repo}} $version 2>&1 | tee $out) || true
grep "ERROR: Not on main branch" $out
echo "Expected error found in output: OK!"
git checkout main &> /dev/null
echo "================================================================================================"
# specified version should match with current version
($GITHUB_WORKSPACE/scripts/create_source_tarball.sh ${{matrix.repo}} 0.0.0 2>&1 | tee $out) || true
grep "ERROR: Found version '${version}'" $out
echo "Expected error found in output: OK!"
echo "================================================================================================"
# existing source tarball in dist should result in an error
mkdir -p dist
touch dist/${{matrix.repo}}-${version}.tar.gz
($GITHUB_WORKSPACE/scripts/create_source_tarball.sh ${{matrix.repo}} $version 2>&1 | tee $out) || true
grep "ERROR: Found dist/${{matrix.repo}}-${version}.tar.gz" $out
echo "Expected error found in output: OK!"
rm dist/${{matrix.repo}}-${version}.tar.gz
echo "================================================================================================"
# check for error when script is run in a dirty working copy
touch dirty.txt
($GITHUB_WORKSPACE/scripts/create_source_tarball.sh ${{matrix.repo}} $version 2>&1 | tee $out) || true
grep "ERROR: Working directory not clean" $out
echo "Expected error found in output: OK!"
rm dirty.txt
echo "================================================================================================"
# create fake 'python3' command:
# just exits when 1st argument is setup.py, but calls out to origin Python command otherwise;
# this is important w.r.t. the Python version checks run by the 'eb' script
mkdir -p /tmp/$USER/bin
export PATH=/tmp/$USER/bin:$PATH
echo '#!/bin/bash' > /tmp/$USER/bin/python3
chmod u+x /tmp/$USER/bin/python3
echo 'orig_python3=$(which -a python3 | head -2 | tail -1)' >> /tmp/$USER/bin/python3
echo 'if [[ "$1" == "setup.py" ]]; then exit 0; else $orig_python3 "$@"; fi' >> /tmp/$USER/bin/python3
# script should fail if expected source tarball did not get created in dist/
($GITHUB_WORKSPACE/scripts/create_source_tarball.sh ${{matrix.repo}} $version 2>&1 | tee $out) || true
grep "ERROR: No source tarball for ${{matrix.repo}} ${version} found" $out
echo "Expected error found in output: OK!"
# clean up index file, to avoid check for dirty working directory failing
rm -f easybuild/easyconfigs/.eb-path-index
echo "================================================================================================"
# make fake python command fail if 1st argument is setup.py
sed -i 's/exit 0/exit 1/g' /tmp/$USER/bin/python3
# script should deal well with failing 'python3 setup.py sdist'
($GITHUB_WORKSPACE/scripts/create_source_tarball.sh ${{matrix.repo}} $version 2>&1 | tee $out) || true
grep "ERROR: Creating source tarball failed" $out
echo "Expected error found in output: OK!"
# cleanup
rm -f /tmp/$USER/bin/python3 easybuild/easyconfigs/.eb-path-index
echo "================================================================================================"
# check use of script in correct way, should yield "SUCCESS" in output
$GITHUB_WORKSPACE/scripts/create_source_tarball.sh ${{matrix.repo}} $version 2>&1 | tee $out
egrep "SUCCESS|Source tarball for ${{matrix.repo}} ${version} is ready for publishing with" $out
# no errors in output
errors=$(grep ERROR $out || true)
if [ ! -z $errors ]; then "Errors found: $errors"; fi
echo "Correct run of script OK!"