Skip to content

revert: remove test package scripts from dev branch #56

revert: remove test package scripts from dev branch

revert: remove test package scripts from dev branch #56

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pytest-mock flake8
- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 scripts cdm_ontologies --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings
flake8 scripts cdm_ontologies --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run unit tests
run: |
pytest tests/ -v --cov=scripts --cov=cdm_ontologies --cov-report=term-missing
- name: Test CLI
run: |
python -m cdm_ontologies --help
python -m cdm_ontologies analyze-core --help
build-and-push:
needs: unit-tests
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create lowercase image name for cache
id: lowercase
run: echo "IMAGE_NAME_LOWER=$(echo '${{ env.IMAGE_NAME }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.lowercase.outputs.IMAGE_NAME_LOWER }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ steps.lowercase.outputs.IMAGE_NAME_LOWER }}:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ steps.lowercase.outputs.IMAGE_NAME_LOWER }}:cache,mode=max
test-small-dataset:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create lowercase image name and determine tag
id: lowercase-test
run: |
echo "IMAGE_NAME_LOWER=$(echo '${{ env.IMAGE_NAME }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
# Use same tag format as docker/metadata-action: pr-{number} for PRs, branch name for pushes
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "DOCKER_TAG=pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
else
echo "DOCKER_TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- name: Run Docker test pipeline
run: |
docker run --rm \
-v ${{ github.workspace }}:/home/ontology/workspace \
-w /home/ontology/workspace \
-e DATASET_SIZE=test \
-e ONTOLOGIES_SOURCE_FILE=config/ontologies_source_test.txt \
-e ROBOT_JAVA_ARGS="-Xmx8g -XX:MaxMetaspaceSize=1g -XX:+UseG1GC" \
-e RELATION_GRAPH_JAVA_ARGS="-Xmx8g -XX:MaxMetaspaceSize=1g -XX:+UseG1GC" \
-e SEMSQL_MEMORY_LIMIT=8g \
-e PYTHON_MEMORY_LIMIT=8g \
-e JAVA_PARALLEL_GC=true \
-e ENABLE_MEMORY_MONITORING=true \
-e ENABLE_TSV_EXPORT=true \
-e ENABLE_PARQUET_EXPORT=true \
-e CREATE_UTILS_LOGS=true \
-e SKIP_RESOURCE_CHECK=true \
-e SKIP_NON_CORE_ANALYSIS=true \
-e PYTHONPATH=scripts \
-e HOST_UID=1001 \
-e HOST_GID=1001 \
${{ env.REGISTRY }}/${{ steps.lowercase-test.outputs.IMAGE_NAME_LOWER }}:${{ steps.lowercase-test.outputs.DOCKER_TAG }} \
python -m cdm_ontologies.cli run-all