Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
kjsanger committed Apr 4, 2023
2 parents c3874c5 + 314f9cf commit 861ac9b
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 273 deletions.
125 changes: 38 additions & 87 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,99 +4,55 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-18.04
continue-on-error: ${{ matrix.experimental }} # Experimental builds may fail

defaults:
run:
shell: bash -l -e -o pipefail {0}
runs-on: ubuntu-latest

env:
WSI_CONDA_CHANNEL: "https://dnap.cog.sanger.ac.uk/npg/conda/devel/generic"
CONDA_TEST_ENVIRONMENT: "testenv"
CK_DEFAULT_TIMEOUT: 20
continue-on-error: ${{ matrix.experimental }} # Experimental builds may fail

strategy:
matrix:
include:
- irods: "4.2.7"
server_image: "wsinpg/ub-16.04-irods-4.2.7:latest"
experimental: false
- irods: "4.2.7"
server_image: "wsinpg/ub-18.04-irods-4.2.10:latest"
experimental: true
- irods: "4.2.7"
server_image: "wsinpg/ub-18.04-irods-4.2.11:latest"
experimental: true

- irods: "4.2.10"
server_image: "wsinpg/ub-16.04-irods-4.2.7:latest"
experimental: true
- irods: "4.2.10"
server_image: "wsinpg/ub-18.04-irods-4.2.10:latest"
# iRODS 4.2.11 clients on bionic
- irods: "4.2.11"
build_image: "ghcr.io/wtsi-npg/ub-18.04-irods-clients-dev-4.2.11:latest"
server_image: "ghcr.io/wtsi-npg/ub-18.04-irods-4.2.11:latest"
experimental: false
- irods: "4.2.10"
server_image: "wsinpg/ub-18.04-irods-4.2.11:latest"
# iRODS 4.3.0 clients on bionic
- irods: "4.3.0"
build_image: "ghcr.io/wtsi-npg/ub-18.04-irods-clients-dev-4.3.0:latest"
server_image: "ghcr.io/wtsi-npg/ub-18.04-irods-4.3.0:latest"
experimental: true

- irods: "4.2.11"
server_image: "wsinpg/ub-16.04-irods-4.2.7:latest"
# iRODS 4.3.0 clients on focal
- irods: "4.3.0"
build_image: "ghcr.io/wtsi-npg/ub-20.04-irods-clients-dev-4.3.0:latest"
server_image: "ghcr.io/wtsi-npg/ub-18.04-irods-4.3.0:latest"
experimental: true
- irods: "4.2.11"
server_image: "wsinpg/ub-18.04-irods-4.2.10:latest"
experimental: true
- irods: "4.2.11"
server_image: "wsinpg/ub-18.04-irods-4.2.11:latest"
experimental: false

container:
image: ${{ matrix.build_image }}

services:
irods:
irods-server:
image: ${{ matrix.server_image }}
options: --name irods-server # A consistent container name is necessary
# to allow creation of bad replicas.
# 'irods-server' is the default container
# name in the bad replica script
ports:
- 1247:1247
- 20000-20199:20000-20199
- "1247:1247"
- "20000-20199:20000-20199"
options: >-
--health-cmd "nc -z -v localhost 1247"
--health-start-period 30s
--health-interval 10s
--health-timeout 20s
--health-retries 6
steps:
- uses: actions/checkout@v2

- name: "Initialize Miniconda"
run: |
echo 'source $CONDA/etc/profile.d/conda.sh' >> "$HOME/.bash_profile"
- name: "Configure Miniconda"
run: |
conda config --prepend pkgs_dirs "$HOME/conda/pkgs"
conda config --prepend envs_dirs "$HOME/conda/envs"
conda config --set auto_update_conda False
conda config --prepend channels "$WSI_CONDA_CHANNEL"
conda info
- name: "Install iRODS clients"
run: |
conda create -y -n "$CONDA_TEST_ENVIRONMENT"
conda install -y -n "$CONDA_TEST_ENVIRONMENT" python=3.9
conda install -y -n "$CONDA_TEST_ENVIRONMENT" sphinx=2.4
conda install -y -n "$CONDA_TEST_ENVIRONMENT" check
conda install -y -n "$CONDA_TEST_ENVIRONMENT" libjansson-dev
conda install -y -n "$CONDA_TEST_ENVIRONMENT" "irods-dev ==${{ matrix.irods }}"
conda install -y -n "$CONDA_TEST_ENVIRONMENT" "irods-icommands ==${{ matrix.irods }}"
- name: Checkout
uses: actions/checkout@v3

- name: "Configure iRODS clients"
run: |
conda activate "$CONDA_TEST_ENVIRONMENT"
mkdir -p "$HOME/.irods"
cat <<'EOF' > "$HOME/.irods/irods_environment.json"
{
"irods_host": "localhost",
"irods_host": "irods-server",
"irods_port": 1247,
"irods_user_name": "irods",
"irods_zone_name": "testZone",
Expand All @@ -105,29 +61,24 @@ jobs:
}
EOF
# Without this, Actions refuses the connection between the containers:
nc -z -v irods-server 1247
echo "irods" | script -q -c "iinit" /dev/null
ienv
ils
ilsresc
- name: "Build and test baton"
env:
CK_DEFAULT_TIMEOUT: 20
run: |
conda activate "$CONDA_TEST_ENVIRONMENT"
# Is there an environment variable for this?
CONDA_ENV="/home/runner/conda/envs/$CONDA_TEST_ENVIRONMENT"
CPPFLAGS="-I$CONDA_ENV/include -I$CONDA_ENV/include/irods"
LDFLAGS="-L$CONDA_ENV/lib -L$CONDA_ENV/lib/irods/externals"
PKG_CONFIG_PATH="$CONDA_ENV/lib/pkgconfig"
autoreconf -i
./configure CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$CONDA_ENV/lib"
# Avoid git exiting when Actions runs this:
git config --global --add safe.directory "$PWD"
make check
make distcheck DISTCHECK_CONFIGURE_FLAGS="CPPFLAGS=\"$CPPFLAGS\" LDFLAGS=\"$LDFLAGS\""
autoreconf -fi
./configure
make distcheck
- name: "Show test log"
if: ${{ failure() }}
Expand Down
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[Upcoming]

[4.0.1]

Fix missing format string in logging which caused a segfault when
log message arugments contained a printf placeholder.

[4.0.0]

Improve connection management by closing the connection while
Expand Down
62 changes: 62 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM ubuntu:bionic

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
apt-get update && \
apt-get install -q -y --no-install-recommends \
apt-utils \
ca-certificates \
curl \
gpg \
gpg-agent \
lsb-release \
locales && \
locale-gen en_GB en_GB.UTF-8 && \
localedef -i en_GB -c -f UTF-8 -A /usr/share/locale/locale.alias en_GB.UTF-8

ENV LANG=en_GB.UTF-8 \
LANGUAGE=en_GB \
LC_ALL=en_GB.UTF-8

ENV IRODS_VERSION=4.2.11-1~bionic

RUN curl -sSL https://packages.irods.org/irods-signing-key.asc | apt-key add - && \
echo "deb [arch=amd64] https://packages.irods.org/apt/ $(lsb_release -sc) main" |\
tee /etc/apt/sources.list.d/renci-irods.list && \
apt-get update && \
apt-get install -q -y --no-install-recommends \
irods-dev="$IRODS_VERSION" \
irods-runtime="$IRODS_VERSION" \
irods-icommands="$IRODS_VERSION"

RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
autoconf \
automake \
build-essential \
check \
gdb \
git \
jq \
lcov \
less \
libjansson-dev \
libtool \
pkg-config \
ssh \
valgrind \
unattended-upgrades && \
unattended-upgrade -d -v

ARG USER=baton
ARG UID=1000
ARG GID=$UID

RUN groupadd --gid $GID $USER && \
useradd --uid $UID --gid $GID --shell /bin/bash --create-home $USER

USER $USER

ENV CPPFLAGS="-I/usr/include/irods" \
CK_DEFAULT_TIMEOUT=20

CMD ["/bin/bash"]
11 changes: 11 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ Installation:
make clean install


Development:

To set up a development environment in Docker, use the provided
docker-compose.yml and corresponding Dockerfile. These create a Linux
C development and testing environment with an accompanying iRODS server.
The recommended way to use this is by remote development in the container
using VSCode. VSCode's manual explains how to do this, see:

https://code.visualstudio.com/docs/remote/containers


Synopsis:

For full details of the JSON accepted and returned by the programs in
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
irods-server:
container_name: irods-server
image: "ghcr.io/wtsi-npg/ub-18.04-irods-${IRODS_VERSION:-4.2.11}:${DOCKER_TAG:-latest}"
restart: always
ports:
- "1247:1247"
- "20000-20199:20000-20199"

baton:
image: baton
platform: linux/amd64
build:
context: .
dockerfile: ./Dockerfile
volumes:
- "${PWD}:/code"
environment:
IRODS_ENVIRONMENT_FILE: "/code/tests/.irods/irods_environment.json"
depends_on:
- irods-server
14 changes: 7 additions & 7 deletions src/baton.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2013, 2014, 2015, 2016, 2017, 2020 Genome Research
* Copyright (C) 2013, 2014, 2015, 2016, 2017, 2020, 2023 Genome Research
* Ltd. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -560,7 +560,7 @@ json_t *search_metadata(rcComm_t *conn, json_t *query, char *zone_name,
return results;

error:
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);

if (results) json_decref(results);
if (collections) json_decref(collections);
Expand Down Expand Up @@ -589,7 +589,7 @@ json_t *search_specific(rcComm_t *conn, json_t *query, char *zone_name,
return results;

error:
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);

if (results) json_decref(results);

Expand Down Expand Up @@ -658,11 +658,11 @@ int modify_permissions(rcComm_t *conn, rodsPath_t *rods_path,

error:
if (conn->rError) {
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);
log_rods_errstack(ERROR, conn->rError);
}
else {
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);
}

return error->code;
Expand Down Expand Up @@ -775,11 +775,11 @@ int modify_metadata(rcComm_t *conn, rodsPath_t *rods_path,

error:
if (conn->rError) {
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);
log_rods_errstack(ERROR, conn->rError);
}
else {
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);
}

return error->code;
Expand Down
11 changes: 5 additions & 6 deletions src/json_query.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2013, 2014, 2015, 2016, 2019, 2021 Genome Research
* Copyright (C) 2013, 2014, 2015, 2016, 2019, 2021, 2023 Genome Research
* Ltd. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -473,11 +473,11 @@ json_t *do_query(rcComm_t *conn, genQueryInp_t *query_in,

error:
if (conn->rError) {
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);
log_rods_errstack(ERROR, conn->rError);
}
else {
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);
}

if (query_out) free_query_output(query_out);
Expand Down Expand Up @@ -572,11 +572,11 @@ json_t *do_squery(rcComm_t *conn, specificQueryInp_t *squery_in,

error:
if (conn->rError) {
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);
log_rods_errstack(ERROR, conn->rError);
}
else {
logmsg(ERROR, error->message);
logmsg(ERROR, "%s", error->message);
}

if (query_out) free_query_output(query_out);
Expand Down Expand Up @@ -1369,4 +1369,3 @@ json_t *revmap_replicate_results(rcComm_t *conn, json_t *results,

return NULL;
}

Loading

0 comments on commit 861ac9b

Please sign in to comment.