Skip to content

Commit

Permalink
Merge pull request #6 from biosimulators/main
Browse files Browse the repository at this point in the history
merge most recent changes
  • Loading branch information
AlexPatrie authored Mar 5, 2024
2 parents 75bb234 + 6239be2 commit 73d4237
Show file tree
Hide file tree
Showing 61 changed files with 5,533 additions and 3,261 deletions.
686 changes: 686 additions & 0 deletions .THIS-IS-FOR-CONTAINER-DEV-ONLY

Large diffs are not rendered by default.

168 changes: 168 additions & 0 deletions .github/workflows/buildDockerImage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Build and push Docker image

on:
push:
paths:
- '.github/workflows/buildDockerImage.yml'
- 'Dockerfile'
- 'Dockerfile-base'
- 'Dockerfile-assets/**'

jobs:
buildAndPushImage:
name: Build and push Docker image
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'allcontributors'"
runs-on: ubuntu-20.04

steps:
# Free disk space
# Inspiration
# - https://github.com/easimon/maximize-build-space/blob/master/action.yml
# - https://githubmemory.com/repo/ros-industrial/industrial_ci/issues/648
# - https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11
- name: Maximize build space
run: |
sudo apt-get -qq purge build-essential ghc*
sudo apt-get clean
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
docker system prune -f
# checkout repository
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1

# Build Docker image
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: "${{ secrets.DOCKER_REGISTRY_USERNAME }}"
password: "${{ secrets.DOCKER_REGISTRY_TOKEN }}"

- id: get-timestamp
name: Get timestamp
run: |
TIMESTAMP=$(date --rfc-3339=seconds | sed 's/ /T/')
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
- name: Copy Dockerfile to Dockerfile-assets
run: |
cp Dockerfile Dockerfile-assets/
cp Dockerfile-base Dockerfile-assets/
- name: Build base image
uses: docker/build-push-action@v2
with:
context: Dockerfile-assets
file: Dockerfile-base
pull: true
load: true
push: false
tags: |
ghcr.io/biosimulators/biosimulators-base:sha-${{github.sha}}
labels: |
org.opencontainers.image.revision=${{github.sha}}
org.opencontainers.image.created=${{steps.get-timestamp.outputs.timestamp}}"
cache-from: type=registry,ref=ghcr.io/biosimulators/biosimulators-base:buildcache
cache-to: type=registry,ref=ghcr.io/biosimulators/biosimulators-base:buildcache,mode=max

- name: Push base Docker image
run: docker image push ghcr.io/biosimulators/biosimulators-base:sha-${{github.sha}}

- name: Label base Docker image
run: docker image tag ghcr.io/biosimulators/biosimulators-base:sha-${{github.sha}} ghcr.io/biosimulators/biosimulators-base:latest

- name: Maximize build space
run: |
docker system prune -f
- name: Build image
uses: docker/build-push-action@v2
with:
context: Dockerfile-assets
file: Dockerfile
pull: false
load: true
push: false
tags: |
ghcr.io/biosimulators/biosimulators:sha-${{github.sha}}
labels: |
org.opencontainers.image.revision=${{github.sha}}
org.opencontainers.image.created=${{steps.get-timestamp.outputs.timestamp}}"
cache-from: type=registry,ref=ghcr.io/biosimulators/biosimulators:buildcache
cache-to: type=registry,ref=ghcr.io/biosimulators/biosimulators:buildcache,mode=max

- name: Push Docker image
run: docker image push ghcr.io/biosimulators/biosimulators:sha-${{github.sha}}

- name: Label Docker image
run: docker image tag ghcr.io/biosimulators/biosimulators:sha-${{github.sha}} ghcr.io/biosimulators/biosimulators:latest

- name: Maximize build space
run: |
docker system prune -f
# Test Docker image
- name: Test Docker image
run: |
cwd=$(pwd)
docker run \
--rm \
--entrypoint bash \
--mount type=bind,source=${cwd},target=/app/Biosimulators \
ghcr.io/biosimulators/biosimulators:latest \
-c "
pipenv install --dev --system --deploy
/bin/bash /xvfb-startup.sh python -m pytest --forked --verbose Biosimulators/tests/
"
# Get version number
- id: get-version-number
name: Get version number
if: startsWith(github.ref, 'refs/tags/')
env:
TAG: ${{ github.ref }}
run: |
version="${TAG/refs\/tags\//}"
echo "version=$version" >> $GITHUB_OUTPUT
# Create GitHub release
- name: Create GitHub release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get-version-number.outputs.version }}
release_name: Release ${{ steps.get-version-number.outputs.version }}

# Push Docker image
- name: Push Docker image
if: startsWith(github.ref, 'refs/tags/')
env:
VERSION: ${{ steps.get-version-number.outputs.version }}
run: |
docker image tag ghcr.io/biosimulators/biosimulators-base:sha-${{github.sha}} ghcr.io/biosimulators/biosimulators-base:${VERSION}
docker image tag ghcr.io/biosimulators/biosimulators:sha-${{github.sha}} ghcr.io/biosimulators/biosimulators:${VERSION}
docker push ghcr.io/biosimulators/biosimulators-base:${VERSION}
docker push ghcr.io/biosimulators/biosimulators-base:latest
docker push ghcr.io/biosimulators/biosimulators:${VERSION}
docker push ghcr.io/biosimulators/biosimulators:latest
165 changes: 165 additions & 0 deletions .github/workflows/buildImage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: Validate and/or commit simulator

on:
deployment

jobs:
validateCommit:
name: Validate and/or commit simulator
runs-on: ubuntu-20.04 # includes Docker
if: |
github.event.issue.state == 'open'
&& contains(github.event.issue.labels.*.name, 'Validate/submit simulator')
&& (
github.event.action == 'edited'
|| (
github.event.action == 'labeled'
&& github.event.label.name == 'Validate/submit simulator'
)
|| (
github.event.action == 'labeled'
&& github.event.label.name == 'Approved'
&& github.event.sender.login != 'biosimulators-daemon'
)
)
steps:
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: '3.10'

#- name: Setup pip cache
# uses: actions/cache@v2
# with:
# path: /opt/hostedtoolcache/Python
# key: ${{ runner.os }}-pip-${{ hashFiles('${GITHUB_WORKSPACE}/requirements.txt') }}-${{ hashFiles('${GITHUB_WORKSPACE}/requirements.optional.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-

- name: Install pip and setuptools
run: |
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py pip>=21.0.0
python -m pip install --upgrade setuptools
- name: Install Java # for pyNeuroML
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '15'

- name: Install Perl # for BioNetGen
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends perl
- name: Install XPP
run: |
sudo apt-get install -y --no-install-recommends xppaut
- name: Install Go (for Singularity)
uses: actions/setup-go@v3
with:
go-version: '^1.13.1' # The Go version to download (if necessary) and use.

- name: Install Singularity # to validate that the Docker image can be converted into a Singularity image
env:
GO_VERSION: 1.17.2
SINGULARITY_VERSION: 3.9.5
OS: linux
ARCH: amd64
run: |
sudo apt-get install -y --no-install-recommends \
build-essential \
libseccomp-dev \
pkg-config \
squashfs-tools \
cryptsetup
wget https://dl.google.com/go/go$GO_VERSION.$OS-$ARCH.tar.gz
sudo tar -C /usr/local -xzvf go$GO_VERSION.$OS-$ARCH.tar.gz
rm go$GO_VERSION.$OS-$ARCH.tar.gz
echo 'export PATH=/usr/local/go/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
echo "/usr/local/go/bin" >> $GITHUB_PATH
wget https://github.com/sylabs/singularity/releases/download/v${SINGULARITY_VERSION}/singularity-ce-${SINGULARITY_VERSION}.tar.gz
tar -xzf singularity-ce-${SINGULARITY_VERSION}.tar.gz
cd singularity-ce-${SINGULARITY_VERSION}
./mconfig
make -C builddir
sudo make -C builddir install
- name: Checkout BioSimulators test suite
uses: actions/checkout@v3
with:
repository: biosimulators/biosimulators_test_suite
fetch-depth: 1
ref: depFixes

- name: Install simulator validation utilities
working-directory: ${{ github.workspace }}
run: |
python -m pip cache purge
python -m pip install --no-cache-dir "biosimulators_utils @ git+https://github.com/biosimulators/Biosimulators_utils@depFixes#egg=biosimulators_utils[containers,bngl,cellml,lems,neuroml,sbml,smoldyn]"
python -m pip install git+https://github.com/biosimulators/RBApy.git#egg=rbapy
python -m pip install -e .[all]
python --version
python -m pip freeze
- name: Login into Docker registries
run: |
# Docker Hub
docker login \
--username ${{ secrets.DOCKER_HUB_USERNAME }} \
--password ${{ secrets.DOCKER_HUB_TOKEN }}
# BioSimulators Docker registry (GHCR)
docker login ${{ secrets.DOCKER_REGISTRY_URL }} \
--username ${{ secrets.DOCKER_REGISTRY_USERNAME }} \
--password ${{ secrets.DOCKER_REGISTRY_TOKEN }}
- id: validateCommitSimulator
name: Validate and commit simulator
uses: GabrielBB/xvfb-action@v1
env:
GH_REPO: ${{ github.repository }}
GH_ACTION_RUN_ID: ${{ github.run_id }}
GH_ISSUE_NUMBER: ${{ github.event.issue.number }}
GH_ISSUES_USER: ${{ secrets.GH_ISSUES_USER }}
GH_ISSUES_ACCESS_TOKEN: ${{ secrets.GH_ISSUES_ACCESS_TOKEN }}

DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}

DOCKER_REGISTRY_URL: ${{ secrets.DOCKER_REGISTRY_URL }}
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

BIOSIMULATORS_API_CLIENT_ID: ${{ secrets.BIOSIMULATORS_API_CLIENT_ID }}
BIOSIMULATORS_API_CLIENT_SECRET: ${{ secrets.BIOSIMULATORS_API_CLIENT_SECRET }}
# BIOSIMULATORS_API_ENDPOINT: https://api.biosimulators.dev/ # uncomment to use the dev deployment of the BioSimulators API

RUNBIOSIMULATIONS_API_CLIENT_ID: ${{ secrets.RUNBIOSIMULATIONS_API_CLIENT_ID }}
RUNBIOSIMULATIONS_API_CLIENT_SECRET: ${{ secrets.RUNBIOSIMULATIONS_API_CLIENT_SECRET }}
# RUNBIOSIMULATIONS_API_ENDPOINT: https://api.biosimulations.dev/ # uncomment to use the dev deployment of the BioSimulators API
with:
working-directory: ${{ github.workspace }}
run: |
python -m pip install --upgrade biosimulators_utils
python -c "from biosimulators_test_suite.exec_gh_action import ValidateCommitSimulatorGitHubAction; ValidateCommitSimulatorGitHubAction().run(); exit();"
- name: Setup tmate session 3 (if failed)
uses: mxschmitt/action-tmate@v3
if: ${{ failure() }}
timeout-minutes: 40

- name: Save test results
uses: actions/upload-artifact@v2
if: success() || failure()
with:
name: Validation test results
path: ${{ github.workspace }}/.biosimulators-test-suite-results.json
if-no-files-found: warn
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@main
with:
ref: main
fetch-depth: 0
# fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@main
Expand All @@ -37,4 +37,4 @@ jobs:
- name: Test with pytest
run: |
pytest --cov=biosimulator_processes
pytest
23 changes: 0 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
.python-version
__pycache__/
.idea/
*.ipynb_checkpoints/
dist/
.DS_Store
*.egg-info/
refresh-env.sh
smoldyn-2.72-mac/
build/
commit.sh
install.sh
push-image.sh
release.sh
run.sh
ray_job.sh
__pycache__
.pytest_cache
submit-biosimulators-container.sh
.vagrant
._vagrant
.THIS-IS-FOR-CONTAINER-DEV-ONLY
buildDockerImage.yml
.env
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/biosimulator-processes.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 73d4237

Please sign in to comment.