Skip to content

Commit

Permalink
Merge pull request #37 from mrakitin/ci-minor-tweaks
Browse files Browse the repository at this point in the history
CI: some tweaks to the steps; switch to miniconda action
  • Loading branch information
mrakitin authored Sep 7, 2021
2 parents 9e00501 + 658e493 commit 392275e
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 155 deletions.
117 changes: 62 additions & 55 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,82 @@
name : tests
name: tests

on:
push:
pull_request:
schedule:
- cron: '00 4 * * *' # daily at 4AM
- cron: '00 4 * * *' # daily at 4AM

jobs:
build:

name: Test sirepo-bluesky with Python ${{ matrix.python-version }}
runs-on: ubuntu-latest

strategy:
matrix:
matrix:
python-version: [3.7, 3.8, 3.9]

fail-fast: false
steps:

- uses: actions/checkout@v2
steps:
- name: Set env.REPOSITORY_NAME # just the repo, as opposed to org/repo
shell: bash -l {0}
run: |
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV
- name: start MongoDB
uses: supercharge/mongodb-github-action@1.6.0
- name: Checkout the code
uses: actions/checkout@v2

- name: start Sirepo-Bluesky container
run: |
set -vxeuo pipefail
. scripts/start_docker.sh -d
export SIREPO_DOCKER_CONTAINER_ID
echo "SIREPO_DOCKER_CONTAINER_ID=${SIREPO_DOCKER_CONTAINER_ID}" >> $GITHUB_ENV
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.6.0

- name: is Sirepo-Bluesky running?
run: docker ps -a
- name: Start Sirepo Docker container
shell: bash -l {0}
run: |
# For reference: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html.
set -vxeuo pipefail
. scripts/start_sirepo.sh -d
export SIREPO_DOCKER_CONTAINER_ID
echo "SIREPO_DOCKER_CONTAINER_ID=${SIREPO_DOCKER_CONTAINER_ID}" >> $GITHUB_ENV
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Check Sirepo state
run: |
set -vxeuo pipefail
docker images
docker ps -a
docker logs ${SIREPO_DOCKER_CONTAINER_ID}
- name: Create conda environment
run: |
# For reference: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html.
set -vxeuo pipefail
source $CONDA/etc/profile.d/conda.sh
conda create -n test -c conda-forge python=${{ matrix.python-version }} shadow3 srwpy
- name: Set up Python ${{ matrix.python-version }} with conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ${{ env.REPOSITORY_NAME }}-py${{ matrix.python-version }}
auto-update-conda: true
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}

- name: Install
shell: bash -l {0}
run: |
# For reference: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html.
set -vxeuo pipefail
source $CONDA/etc/profile.d/conda.sh
conda activate test
conda env list
pip install --upgrade pip wheel
pip install .
pip install -r requirements-dev.txt
pip list
conda list
- name: Install the package and its dependencies
shell: bash -l {0}
run: |
# set -vxeuo pipefail
# Do not check for unbound variables (the '-u' flag) as it fails on
# conda deactivate command:
# /usr/share/miniconda3/envs/sirepo-bluesky-py3.9/etc/conda/deactivate.d/glib_deactivate.sh:
# line 1: GSETTINGS_SCHEMA_DIR_CONDA_BACKUP: unbound variable
set -vxeo pipefail
conda env list
conda install -c conda-forge shadow3 srwpy
pip install --upgrade pip wheel
pip install .
pip install -r requirements-dev.txt
pip list
conda list
- name: Test with pytest
shell: bash -l {0}
run: |
# For reference: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html.
set -vxeuo pipefail
source $CONDA/etc/profile.d/conda.sh
conda activate test
pytest -s -vv sirepo_bluesky/tests
status=$?
echo "Sirepo Docker container id: ${SIREPO_DOCKER_CONTAINER_ID}"
docker logs ${SIREPO_DOCKER_CONTAINER_ID}
if [ $status -gt 0 ]; then
exit $status
fi
- name: Test with pytest
shell: bash -l {0}
run: |
set -vxeuo pipefail
pytest -s -vv
status=$?
echo "Sirepo Docker container id: ${SIREPO_DOCKER_CONTAINER_ID}"
docker logs ${SIREPO_DOCKER_CONTAINER_ID}
if [ $status -gt 0 ]; then
exit $status
fi
91 changes: 0 additions & 91 deletions .travis.yml

This file was deleted.

22 changes: 21 additions & 1 deletion scripts/start_mongo.sh
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
docker run -it --rm -p 27017:27017 mongo
#!/bin/bash

set -vxeuo pipefail

error_msg="Specify '-it' or '-d' on the command line as a first argument."

arg="${1:-}"

if [ -z "${arg}" ]; then
echo "${error_msg}"
exit 1
elif [ "${arg}" != "-it" -a "${arg}" != "-d" ]; then
echo "${error_msg} Specified argument: ${arg}"
exit 2
fi

docker_image="mongo"

docker pull ${docker_image}
docker images
docker run ${arg} --rm -p 27017:27017 --name mongo ${docker_image}
17 changes: 9 additions & 8 deletions scripts/start_docker.sh → scripts/start_sirepo.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/bin/bash

# set -vxeuo pipefail
set -e

error_msg="Specify '-it' or '-d' on the command line as a first argument."

if [ -z "$1" ]; then
arg="${1:-}"

if [ -z "${arg}" ]; then
echo "${error_msg}"
exit 1
elif [ "$1" != "-it" -a "$1" != "-d" ]; then
echo "${error_msg} Specified argument: ${1}"
elif [ "${arg}" != "-it" -a "${arg}" != "-d" ]; then
echo "${error_msg} Specified argument: ${arg}"
exit 2
fi

Expand All @@ -20,23 +23,21 @@ year=$(date +"%Y")

today="${HOME}/tmp/data/${year}/${month}/${day}"

docker_image="radiasoft/sirepo:beta"

if [ -d "${today}" ]; then
echo "Directory ${today} exists."
else
echo "Creating Directory ${today}"
mkdir -p "${today}"
fi

# ls -l $HOME/tmp
docker_image="radiasoft/sirepo:beta"

docker pull ${docker_image}

docker images

in_docker_cmd="mkdir -v -p /sirepo/ && cp -Rv /SIREPO_SRDB_ROOT/* /sirepo/ && sirepo service http"
cmd="docker run $1 --init --rm --name sirepo \
cmd="docker run ${arg} --init --rm --name sirepo \
-e SIREPO_AUTH_METHODS=bluesky:guest \
-e SIREPO_AUTH_BLUESKY_SECRET=bluesky \
-e SIREPO_SRDB_ROOT=/sirepo \
Expand All @@ -46,7 +47,7 @@ cmd="docker run $1 --init --rm --name sirepo \
${docker_image} bash -l -c \"${in_docker_cmd}\""

echo -e "Command to run:\n\n${cmd}\n"
if [ "$1" == "-d" ]; then
if [ "${arg}" == "-d" ]; then
SIREPO_DOCKER_CONTAINER_ID=$(eval ${cmd})
export SIREPO_DOCKER_CONTAINER_ID
echo "Container ID: ${SIREPO_DOCKER_CONTAINER_ID}"
Expand Down

0 comments on commit 392275e

Please sign in to comment.