Skip to content

Commit fc38073

Browse files
committed
CI: Use environment variables CRATEDB_VERSION and SQLALCHEMY_VERSION
Instead of using GNU getopt in the `setup_ci.sh` program, the needed information is propagated using environment variables.
1 parent 015e7d0 commit fc38073

File tree

4 files changed

+42
-56
lines changed

4 files changed

+42
-56
lines changed

.github/workflows/nightly.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ jobs:
1818
os: [ubuntu-latest]
1919
python-version: ['3.7', '3.8', '3.9', '3.10']
2020
cratedb-version: ['nightly']
21-
sqla-version: ['1.3.24']
21+
sqla-version: ['1.4.37']
2222
fail-fast: false
23+
env:
24+
CRATEDB_VERSION: ${{ matrix.cratedb-version }}
25+
SQLALCHEMY_VERSION: ${{ matrix.sqla-version }}
2326

2427
steps:
2528
- uses: actions/checkout@v3
@@ -28,13 +31,15 @@ jobs:
2831
with:
2932
python-version: ${{ matrix.python-version }}
3033

31-
- name: Propagate matrix information
32-
run: |
33-
source bootstrap.sh
34-
./devtools/setup_ci.sh --cratedb-version=${{ matrix.cratedb-version }} --sqlalchemy-version=${{ matrix.sqla-version }}
35-
3634
- name: Invoke tests
3735
run: |
36+
37+
# Bootstrap environment.
3838
source bootstrap.sh
39+
40+
# Propagate build matrix information.
41+
./devtools/setup_ci.sh
42+
43+
# Invoke validation tasks.
3944
flake8 src bin
4045
coverage run bin/test -vv1

.github/workflows/tests.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
cratedb-version: ['4.8.0']
2222
sqla-version: ['1.3.24', '1.4.37']
2323
fail-fast: true
24+
env:
25+
CRATEDB_VERSION: ${{ matrix.cratedb-version }}
26+
SQLALCHEMY_VERSION: ${{ matrix.sqla-version }}
2427

2528
steps:
2629
- uses: actions/checkout@v3
@@ -29,22 +32,20 @@ jobs:
2932
with:
3033
python-version: ${{ matrix.python-version }}
3134

32-
- name: Adjust environment for macOS
33-
if: matrix.os == 'macos-latest'
35+
- name: Invoke tests
3436
run: |
35-
brew install gnu-getopt
36-
echo "/usr/local/opt/gnu-getopt/bin" >> $GITHUB_PATH
3737
38-
- name: Propagate matrix information
39-
run: |
38+
# Bootstrap environment.
4039
source bootstrap.sh
41-
./devtools/setup_ci.sh --cratedb-version=${{ matrix.cratedb-version }} --sqlalchemy-version=${{ matrix.sqla-version }}
4240
43-
- name: Invoke tests
44-
run: |
45-
source bootstrap.sh
41+
# Propagate build matrix information.
42+
./devtools/setup_ci.sh
43+
44+
# Invoke validation tasks.
4645
flake8 src bin
4746
coverage run bin/test -vv1
47+
48+
# Set the stage for the Codecov step.
4849
coverage xml
4950
5051
# https://github.com/codecov/codecov-action

bootstrap.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
# Trace all invocations.
1717
# set -x
1818

19+
# Default variables.
20+
BUILDOUT_VERSION=${BUILDOUT_VERSION:-2.13.7}
21+
CRATEDB_VERSION=${CRATEDB_VERSION:-4.8.1}
22+
SQLALCHEMY_VERSION=${SQLALCHEMY_VERSION:-1.4.37}
23+
1924

2025
function print_header() {
2126
printf '=%.0s' {1..42}; echo
@@ -50,8 +55,8 @@ function before_setup() {
5055
#
5156
pip install wheel
5257

53-
BUILDOUT_VERSION=${BUILDOUT_VERSION:-2.13.7}
54-
pip install "zc.buildout==${BUILDOUT_VERSION}"
58+
# Install Buildout with designated version, allowing pre-releases.
59+
pip install --pre "zc.buildout==${BUILDOUT_VERSION}"
5560

5661
}
5762

@@ -70,7 +75,10 @@ function finalize() {
7075

7176
# Some steps before dropping into the activated virtualenv.
7277
echo
73-
python -c 'import sqlalchemy; print(f"SQLAlchemy version: {sqlalchemy.__version__}")'
78+
echo "Sandbox environment ready"
79+
echo -n "Using SQLAlchemy version: "
80+
python -c 'import sqlalchemy; print(sqlalchemy.__version__)'
81+
echo
7482

7583
}
7684

@@ -84,7 +92,7 @@ function main() {
8492
}
8593

8694
function lint() {
87-
flake8
95+
flake8 "$@" src bin
8896
}
8997

9098
main

devtools/setup_ci.sh

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,31 @@
22

33
set -e
44

5-
function args() {
6-
options=$(getopt --long cratedb-version: --long sqlalchemy-version: -- "$@")
7-
[ $? -eq 0 ] || {
8-
echo "Incorrect options provided"
9-
exit 1
10-
}
11-
eval set -- "$options"
12-
while true; do
13-
case "$1" in
14-
--cratedb-version)
15-
shift;
16-
cratedb_version=$1
17-
;;
18-
--sqlalchemy-version)
19-
shift;
20-
sqlalchemy_version=$1
21-
;;
22-
--)
23-
shift
24-
break
25-
;;
26-
esac
27-
shift
28-
done
29-
}
30-
315
function main() {
326

33-
# Read command line arguments.
34-
args $0 "$@"
35-
367
# Sanity checks.
37-
[ -z ${cratedb_version} ] && {
8+
[ -z ${CRATEDB_VERSION} ] && {
389
echo "--cratedb-version must be given"
10+
echo "Environment variable 'CRATEDB_VERSION' needed"
3911
exit 1
4012
}
41-
[ -z ${sqlalchemy_version} ] && {
42-
echo "--sqlalchemy-version must be given"
13+
[ -z ${SQLALCHEMY_VERSION} ] && {
14+
echo "Environment variable 'SQLALCHEMY_VERSION' needed"
4315
exit 1
4416
}
4517

4618
# Let's go.
47-
echo "Invoking tests with CrateDB ${cratedb_version} and SQLAlchemy ${sqlalchemy_version}"
19+
echo "Invoking tests with CrateDB ${CRATEDB_VERSION} and SQLAlchemy ${SQLALCHEMY_VERSION}"
4820

4921
# Install designated SQLAlchemy version.
50-
pip install "sqlalchemy==${sqlalchemy_version}"
22+
pip install "sqlalchemy==${SQLALCHEMY_VERSION}"
5123

5224
# Replace CrateDB version.
53-
if [ ${cratedb_version} = "nightly" ]; then
25+
if [ ${CRATEDB_VERSION} = "nightly" ]; then
5426
sed -ir "s/releases/releases\/nightly/g" buildout.cfg
5527
sed -ir "s/crate_server.*/crate_server = latest/g" versions.cfg
5628
else
57-
sed -ir "s/crate_server.*/crate_server = ${cratedb_version}/g" versions.cfg
29+
sed -ir "s/crate_server.*/crate_server = ${CRATEDB_VERSION}/g" versions.cfg
5830
fi
5931

6032
}

0 commit comments

Comments
 (0)