Skip to content

Commit a3660b4

Browse files
authored
Add CentOS to CI (#19)
1 parent 6342544 commit a3660b4

18 files changed

+192
-73
lines changed

.ci/azure-pipelines/matrix.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33

44
parameters:
55
templates:
6-
Linux: unix.yml
6+
Ubuntu: unix.yml
7+
CentOS: unix.yml
78
macOS: unix.yml
89
Windows: windows.yml
910

10-
Linux:
11+
Ubuntu:
1112
CC: gcc-9
1213
FC: gfortran-9
14+
CentOS:
15+
CC: gcc
16+
FC: gfortran
1317
macOS:
1418
CC: gcc-9
1519
FC: gfortran-9
@@ -31,7 +35,7 @@ parameters:
3135

3236
# Loop/matrix parameters.
3337
# Note that these may be overridden by the including yml (typically azure-pipelines.yml).
34-
OS_NAMES: [Windows, Linux, macOS]
38+
OS_NAMES: [Windows, Ubuntu, CentOS, macOS]
3539
BUILD_SYSTEMS: [Make, CMake]
3640
BUILD_TYPES: [Debug, Release]
3741
# WPS in the Make variant does not support smpar out of the box, so ignore here.
@@ -60,9 +64,9 @@ jobs:
6064
- ${{ if eq(parameters.WATS_RUN, 'true') }}:
6165
- template: wats_diff.yml
6266
parameters:
63-
# For Windows, since there is no Make-based reference, compare against Linux.
67+
# For Windows, since there is no Make-based reference, compare against Ubuntu.
6468
${{ if eq(OS_NAME, 'Windows') }}:
65-
OS_NAME_LEFT: Linux
69+
OS_NAME_LEFT: Ubuntu
6670
${{ if ne(OS_NAME, 'Windows') }}:
6771
OS_NAME_LEFT: ${{ OS_NAME }}
6872
OS_NAME_RIGHT: ${{ OS_NAME }}
@@ -78,7 +82,7 @@ jobs:
7882
- ${{ each MODE in parameters.MODES }}:
7983
- template: wats_diff.yml
8084
parameters:
81-
OS_NAME_LEFT: Linux
85+
OS_NAME_LEFT: Ubuntu
8286
OS_NAME_RIGHT: macOS
8387
BUILD_SYSTEM_LEFT: Make
8488
BUILD_SYSTEM_RIGHT: Make

.ci/azure-pipelines/release.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ steps:
1212
displayName: Create distribution package
1313

1414
- ${{ if not(eq(parameters.OS_NAME, 'Windows')) }}:
15-
- bash: bash .ci/unix/delocate.sh
15+
- bash: $(run) .ci/unix/delocate.sh
1616
displayName: Delocate
1717

1818
- task: ArchiveFiles@2
@@ -24,9 +24,14 @@ steps:
2424
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.SourceBranchName)-$(NESTING)_nesting-$(MODE)-x64-$(OS_NAME)-$(BUILD_TYPE).tar.xz'
2525
displayName: Create distribution package
2626

27-
- pwsh: |
28-
dir $(Build.ArtifactStagingDirectory) -r | % { if ($_.Name -cne $_.Name.ToLower()) { ren $_.FullName $_.Name.ToLower() } }
29-
displayName: Rename to lowercase
27+
- bash: |
28+
set -ex
29+
cd "$(Build.ArtifactStagingDirectory)"
30+
# CentOS packages will run on most glibc-based Linux distributions
31+
find . -name '*CentOS*' -exec bash -c 'mv $0 ${0/CentOS/Linux}' {} \;
32+
# Rename all files to lowercase
33+
for file in $(ls); do mv ${file} $(echo ${file} | tr '[:upper:]' '[:lower:]'); done
34+
displayName: Rename package files
3035

3136
# not strictly needed
3237
- task: PublishBuildArtifacts@1

.ci/azure-pipelines/unix.yml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,30 @@ jobs:
88
timeoutInMinutes: 0
99

1010
pool:
11-
${{ if eq(parameters.OS_NAME, 'Linux') }}:
12-
vmImage: ubuntu-16.04
11+
${{ if or(eq(parameters.OS_NAME, 'Ubuntu'), eq(parameters.OS_NAME, 'CentOS')) }}:
12+
vmImage: ubuntu-latest
1313
${{ if eq(parameters.OS_NAME, 'macOS') }}:
14-
vmImage: macos-10.13
15-
16-
${{ if eq(parameters.OS_NAME, 'Linux') }}:
17-
container:
18-
image: ubuntu:16.04
19-
options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
14+
vmImage: macOS-10.14
2015

2116
variables:
2217
${{ insert }}: ${{ parameters }}
18+
${{ if eq(parameters.OS_NAME, 'Ubuntu') }}:
19+
IMAGE: ubuntu:16.04
20+
run: .ci/unix/run-in-docker.sh
21+
${{ if eq(parameters.OS_NAME, 'CentOS') }}:
22+
IMAGE: quay.io/pypa/manylinux2010_x86_64:latest
23+
run: .ci/unix/run-in-docker.sh
24+
${{ if eq(parameters.OS_NAME, 'macOS') }}:
25+
run: ''
2326

24-
steps:
25-
- ${{ if eq(parameters.OS_NAME, 'Linux') }}:
26-
# https://github.com/Microsoft/azure-pipelines-agent/issues/2043#issuecomment-489692810
27-
- script: |
28-
/tmp/docker exec -t -u 0 ci-container \
29-
sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
30-
displayName: Set up sudo
31-
32-
- script: .ci/unix/dump-vm-specs.sh
27+
steps:
28+
- script: $(run) .ci/unix/dump-vm-specs.sh
3329
displayName: Dump VM specs
3430

35-
- script: printenv
31+
- script: $(run) printenv | sort
3632
displayName: Dump environment variables
3733

38-
- ${{ if eq(parameters.OS_NAME, 'Linux') }}:
34+
- ${{ if eq(parameters.OS_NAME, 'Ubuntu') }}:
3935
- script: |
4036
sudo apt-get update && sudo apt-get install -y curl
4137
displayName: Install curl
@@ -47,13 +43,13 @@ jobs:
4743
curl -L --retry 3 https://github.com/$WRF_REPO/archive/$WRF_COMMIT.tar.gz | tar xz --strip-components=1
4844
displayName: Download WRF
4945
50-
- script: ../WRF/.ci/unix/setup-dependencies.sh
46+
- script: $(run) ../WRF/.ci/unix/setup-dependencies.sh
5147
displayName: Setup dependencies
5248

53-
- script: ../WRF/.ci/unix/install-wrf.sh
49+
- script: $(run) ../WRF/.ci/unix/install-wrf.sh
5450
displayName: Install WRF
5551

56-
- script: .ci/unix/install-wps.sh
52+
- script: $(run) .ci/unix/install-wps.sh
5753
displayName: Install WPS
5854

5955
- ${{ if eq(parameters.WATS_RUN, 'true') }}:

.ci/azure-pipelines/wats_diff.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
displayName: 'WATS ${{ parameters.OS_NAME_LEFT }}/${{ parameters.OS_NAME_RIGHT }} ${{ parameters.BUILD_SYSTEM_LEFT }}/${{ parameters.BUILD_SYSTEM_RIGHT }}: ${{ parameters.BUILD_TYPE }}, ${{ parameters.MODE }}'
77

88
pool:
9-
vmImage: ubuntu-16.04
9+
vmImage: ubuntu-latest
1010

1111
dependsOn:
1212
- ${{ parameters.OS_NAME_LEFT }}_${{ parameters.BUILD_SYSTEM_LEFT }}_${{ parameters.BUILD_TYPE }}_${{ parameters.MODE }}
@@ -19,11 +19,7 @@ jobs:
1919
- bash: .ci/unix/use-conda.sh
2020
displayName: Enable Conda
2121

22-
- bash: |
23-
set -ex
24-
mkdir wats && cd wats
25-
curl -L --retry 3 https://github.com/$WATS_REPO/archive/$WATS_BRANCH.tar.gz | tar xz --strip-components=1
26-
conda env update -n base -f environment.yml
22+
- bash: .ci/unix/install-wats.sh
2723
displayName: Install WATS
2824

2925
- task: DownloadBuildArtifacts@0

.ci/azure-pipelines/wats_pkg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
displayName: Publish WATS Package
1212

1313
pool:
14-
vmImage: ubuntu-16.04
14+
vmImage: ubuntu-latest
1515

1616
dependsOn:
1717
- ${{ parameters.OS_NAME }}_${{ parameters.BUILD_SYSTEM }}_${{ parameters.BUILD_TYPE }}_${{ parameters.MODE }}

.ci/azure-pipelines/wats_run.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,13 @@
22
# Copyright 2019 M. Riechert and D. Meyer. Licensed under the MIT License.
33

44
steps:
5-
- bash: .ci/unix/use-conda.sh
5+
- bash: $(run) .ci/unix/use-conda.sh
66
displayName: Enable Conda
77

8-
- bash: |
9-
set -ex
10-
mkdir wats && cd wats
11-
curl -L --retry 3 https://github.com/$WATS_REPO/archive/$WATS_BRANCH.tar.gz | tar xz --strip-components=1
12-
conda env update -n base -f environment.yml
8+
- bash: $(run) .ci/unix/install-wats.sh
139
displayName: Install WATS
1410

15-
- bash: |
16-
set -ex
17-
if [[ $MODE == dm* ]]; then mpi_flag="--mpi"; fi
18-
if [[ $OS_NAME == macOS ]]; then
19-
# Work around Open MPI issue
20-
# https://github.com/open-mpi/ompi/issues/6518
21-
# https://github.com/open-mpi/ompi/issues/5798
22-
# https://www.mail-archive.com/devel@lists.open-mpi.org/msg20760.html
23-
export OMPI_MCA_btl=self,tcp
24-
fi
25-
if [[ $BUILD_SYSTEM == "CMake" ]]; then dir_suffix="build/install"; fi
26-
python wats/wats/main.py run --mode $WATS_MODE --wrf-dir ../WRF/$dir_suffix --wps-dir ./$dir_suffix --work-dir wats_work $mpi_flag
11+
- bash: $(run) .ci/unix/run-wats.sh
2712
displayName: Run WATS
2813

2914
- task: PublishBuildArtifacts@1

.ci/azure-pipelines/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
timeoutInMinutes: 0
99

1010
pool:
11-
vmImage: windows-2019
11+
vmImage: windows-latest
1212

1313
variables:
1414
${{ insert }}: ${{ parameters }}

.ci/unix/delocate.sh

100644100755
Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,37 @@ cd $SCRIPTDIR/../..
1010

1111
if [ "$(uname)" == "Darwin" ]; then
1212

13-
pip3 install delocate
13+
pip install delocate
1414
delocate-listdeps --all --depending build/install
1515
delocate-path build/install
1616
delocate-listdeps --all --depending build/install
1717

18+
elif [ "$(lsb_release -i -s)" == "CentOS" ]; then
19+
20+
# Assumes we're in the manylinux Docker image.
21+
pys=(/opt/python/cp*)
22+
# Use the newest Python available in the image (last item).
23+
py=${pys[@]:(-1)}/bin/python
24+
25+
root_dir=$(pwd)
26+
tmp_dir=$(mktemp -d)
27+
cd $tmp_dir
28+
29+
echo "from setuptools import setup; setup(name='app', packages=['main'], package_data={'main': ['*.exe']})" > setup.py
30+
ln -s $root_dir/build/install main
31+
$py setup.py bdist_wheel
32+
33+
# CentOS uses /usr/lib64 but some manually installed dependencies end up in /usr/lib
34+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib
35+
36+
auditwheel repair dist/*.whl --no-update-tags
37+
cd wheelhouse
38+
unzip *.whl
39+
40+
# /bin/cp as cp is aliased to 'cp -i' and would ask before overwriting
41+
/bin/cp -r main/. $root_dir/build/install
42+
1843
else
19-
echo "Unknown OS: $(uname)"
44+
echo "Unsupported OS: $(uname)"
2045
exit 1
2146
fi

.ci/unix/dump-vm-specs.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ if [ "$(uname)" == "Darwin" ]; then
1515
sudo scutil --get LocalHostName || true
1616
elif [ "$(uname)" == "Linux" ]; then
1717
if [ "$(which lsb_release)" == "" ]; then
18-
sudo apt install -y lsb-release
18+
if [ -f /etc/redhat-release ]; then
19+
sudo yum install -y redhat-lsb-core
20+
else
21+
sudo apt install -y lsb-release
22+
fi
1923
fi
2024
lsb_release -a
2125
free -m

.ci/unix/install-wats.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
# WRF-CMake (https://github.com/WRF-CMake/wps).
4+
# Copyright 2019 M. Riechert and D. Meyer. Licensed under the MIT License.
5+
6+
set -ex
7+
8+
SCRIPTDIR=$(dirname "$0")
9+
cd $SCRIPTDIR/../..
10+
11+
curl -L --retry 3 https://github.com/$WATS_REPO/archive/$WATS_BRANCH.tar.gz | tar xz
12+
mv wats-$WATS_BRANCH wats
13+
conda env update -n base -f wats/environment.yml

.ci/unix/install-wps.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ elif [ $BUILD_SYSTEM == "Make" ]; then
3838
*) echo "Invalid: $MODE" ;;
3939
esac
4040

41-
if [ "$(lsb_release -c -s)" == "trusty" ]; then
41+
if [ "$(lsb_release -c -s)" == "trusty" -o "$(lsb_release -i -s)" == "CentOS" ]; then
4242
export NETCDF=/usr
4343
else
4444
# Need to create symlinked folder hierarchy that WRF expects...
@@ -52,7 +52,11 @@ elif [ $BUILD_SYSTEM == "Make" ]; then
5252

5353
## As the zlib and PNG libraries are not in a standard path that will be checked automatically by the compiler,
5454
## we include them with the JASPER include and library path
55-
export JASPERLIB="/usr/lib/x86_64-linux-gnu"
55+
if [ "$(lsb_release -i -s)" == "CentOS" ]; then
56+
export JASPERLIB="/usr/lib64"
57+
else
58+
export JASPERLIB="/usr/lib/x86_64-linux-gnu"
59+
fi
5660
export JASPERINC="/usr/include/jasper -I/usr/include"
5761

5862
elif [ "$(uname)" == "Darwin" ]; then
@@ -69,6 +73,11 @@ elif [ $BUILD_SYSTEM == "Make" ]; then
6973
export JASPERLIB=$(brew --prefix jasper)/lib
7074
export JASPERINC=$(brew --prefix jasper)/include
7175

76+
# Otherwise libpng is not found.
77+
# Note that LIBRARY_PATH and CPATH applies to all compiler invocations.
78+
export LIBRARY_PATH=/usr/local/lib
79+
export CPATH=/usr/local/include
80+
7281
else
7382
echo "The environment is not recognised"
7483
exit 1

.ci/unix/run-in-docker.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
# WRF-CMake (https://github.com/WRF-CMake/wps).
4+
# Copyright 2018 M. Riechert and D. Meyer. Licensed under the MIT License.
5+
6+
set -e
7+
8+
SCRIPTDIR=$(dirname "$0")
9+
REPODIR=$(realpath $SCRIPTDIR/../..)
10+
# above repo root as this is where WRF is cloned into
11+
MOUNTDIR=$(realpath $SCRIPTDIR/../../..)
12+
13+
container=wps-ci
14+
15+
# Create container if it doesn't exist
16+
if [ ! "$(docker ps -q -f name=$container)" ]; then
17+
echo "Creating Docker container $container"
18+
set -x
19+
docker run --name $container -t -d -v $MOUNTDIR:$MOUNTDIR -w $REPODIR -e DOCKER=1 $IMAGE
20+
set +x
21+
22+
echo "Installing sudo inside container"
23+
if [[ $OS_NAME == CentOS ]]; then
24+
docker exec $container sh -c "yum install -y sudo"
25+
else
26+
docker exec $container sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
27+
fi
28+
fi
29+
30+
echo "Running inside container: $@"
31+
host_envs=$(env | cut -f1 -d= | sed 's/^/-e /' | grep -v -e PATH -e HOME)
32+
# Use login shell so that ~/.bash_profile is read.
33+
# use-conda.sh appends to that file to modify the PATH.
34+
docker exec $host_envs $container bash --login -c "$@"

.ci/unix/run-wats.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
# WRF-CMake (https://github.com/WRF-CMake/wps).
4+
# Copyright 2018 M. Riechert and D. Meyer. Licensed under the MIT License.
5+
6+
set -ex
7+
8+
SCRIPTDIR=$(dirname "$0")
9+
cd $SCRIPTDIR/../..
10+
11+
if [ "$(uname)" == "Linux" ]; then
12+
if [ "$(lsb_release -i -s)" == "CentOS" ]; then
13+
# CentOS uses /usr/lib64 but some manually installed dependencies end up in /usr/lib
14+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib
15+
fi
16+
fi
17+
18+
if [[ $MODE == dm* ]]; then
19+
mpi_flag="--mpi"
20+
fi
21+
22+
if [[ $OS_NAME == macOS ]]; then
23+
# Work around Open MPI issue
24+
# https://github.com/open-mpi/ompi/issues/6518
25+
# https://github.com/open-mpi/ompi/issues/5798
26+
# https://www.mail-archive.com/devel@lists.open-mpi.org/msg20760.html
27+
export OMPI_MCA_btl=self,tcp
28+
# Disable new shared memory component of Open MPI to work around issue
29+
# https://github.com/open-mpi/ompi/issues/7516
30+
export PMIX_MCA_gds=hash
31+
fi
32+
33+
if [[ $BUILD_SYSTEM == "CMake" ]]; then
34+
dir_suffix="build/install"
35+
fi
36+
37+
python wats/wats/main.py run \
38+
--mode $WATS_MODE \
39+
--wrf-dir ../WRF/$dir_suffix \
40+
--wps-dir ./$dir_suffix \
41+
--work-dir wats_work \
42+
$mpi_flag

0 commit comments

Comments
 (0)