specify image for docker #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: bifrost sp ecoli workflow | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
repository_dispatch: # webhook event to trigger this action workflow upon push to the submodule ecoli_fbi | |
types: | |
- ecoli-fbi-webhook | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ["ubuntu-latest"] | |
python-version: ["3.11"] | |
steps: | |
# Step 1: Checkout repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'true' #Initialize and update submodules -> git submodule init && git submodule update | |
# Step 2: Update submodule to the latest commit | |
- name: Update submodule | |
run: | | |
cd bifrost_sp_ecoli/ecoli_fbi | |
# Show the current commit hash before updating | |
CURRENT_COMMIT=$(git rev-parse HEAD) | |
echo "Current commit hash of ecoli_fbi before update: $CURRENT_COMMIT" | |
echo "Fetching latest changes from origin" | |
git fetch origin --tags | |
echo "Switching to the main branch and pulling latest updates" | |
git checkout main # or the specific branch you want to track | |
git pull origin main --tags # pull the latest changes | |
# Show the new commit hash after the update | |
LATEST_COMMIT=$(git rev-parse HEAD) | |
echo "Updated commit hash of ecoli_fbi after update: $LATEST_COMMIT" | |
# print the latest tag of ecoli_fbi | |
LATEST_TAG_COMMIT=$(git tag --sort=-creatordate --format '%(objectname)'|head -1) | |
LATEST_TAG=$(git tag --sort=-creatordate|head -1) | |
echo "Checking commit hash for the latest tag of ecoli_fbi: $LATEST_TAG_COMMIT" | |
echo "Checking the lastest tag of ecoli_fbi: $LATEST_TAG" | |
git checkout $LATEST_TAG_COMMIT | |
# Step 4: Extract version from __init__.py and set ENV_NAME | |
- name: Set ENV_NAME | |
run: | | |
VERSION=$(grep "__version__" bifrost_sp_ecoli/__init__.py | cut -d "'" -f 2) | |
REPO_NAME=$(basename "${{ github.workspace }}") | |
ENV_NAME="${REPO_NAME}_v${VERSION}" | |
# Echo the ENV_NAME to the log for debugging | |
echo "Setting ENV_NAME to: $ENV_NAME" | |
echo "ENV_NAME=$ENV_NAME" >> $GITHUB_ENV | |
# Step 5: Build Docker image | |
- name: Build docker image | |
run: | | |
docker build --build-arg CONDA_ENV_NAME="${{ env.ENV_NAME }}" -t bifrost_sp_ecoli_image . | |
- name: Get_tests_data | |
run: > | |
git clone https://github.com/ssi-dk/bifrost_test_data.git; | |
cd bifrost_test_data/samples; | |
bash download_S1.sh | |
- name: Run_tests | |
run: > | |
docker run | |
--env BIFROST_DB_KEY=${{ secrets.MONGODB_ATLAS_CONNECTION }}/bifrost_test \ | |
--env CONDA_ENV_NAME="${{ env.ENV_NAME }}" \ | |
-w /bifrost/components/${{ github.event.repository.name }} \ | |
-v /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/bifrost_test_data:/bifrost/test_data \ | |
bifrost_sp_ecoli_image \ | |
-m pytest |