|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + packages: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + python-version: ['3.9', '3.12'] |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Set up Python ${{ matrix.python-version }} |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: ${{ matrix.python-version }} |
| 29 | + |
| 30 | + - name: Install system dependencies |
| 31 | + run: | |
| 32 | + sudo apt-get update |
| 33 | + sudo apt-get install -y poppler-utils |
| 34 | + |
| 35 | + - name: Upgrade pip, setuptools, and packaging |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip setuptools packaging |
| 38 | + |
| 39 | + - name: Cache src directory |
| 40 | + uses: actions/cache@v4 |
| 41 | + with: |
| 42 | + path: ./src/ |
| 43 | + key: ${{ runner.os }}-src-grch37 |
| 44 | + restore-keys: | |
| 45 | + ${{ runner.os }}-src- |
| 46 | + |
| 47 | + - name: Download GRCh37.tar.gz if not present |
| 48 | + run: | |
| 49 | + if [ ! -f ./src/GRCh37.tar.gz ]; then |
| 50 | + wget --connect-timeout=10 --tries=20 ftp://alexandrovlab-ftp.ucsd.edu/pub/tools/SigProfilerMatrixGenerator/GRCh37.tar.gz -P ./src/ |
| 51 | + fi |
| 52 | + |
| 53 | + - name: Install package with tests |
| 54 | + run: | |
| 55 | + pip install .[tests] |
| 56 | + |
| 57 | + - name: Install genome |
| 58 | + run: | |
| 59 | + python install_genome.py ${{ github.workspace }}/src/ |
| 60 | + |
| 61 | + - name: Run unit tests |
| 62 | + run: | |
| 63 | + pytest tests |
| 64 | + |
| 65 | + - name: Run integration test |
| 66 | + run: | |
| 67 | + python3 test.py |
| 68 | + |
| 69 | + - name: Build and push Docker image |
| 70 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' && matrix.python-version == '3.12' |
| 71 | + run: | |
| 72 | + echo "Starting Docker deployment to GHCR for sigprofilersuite..." |
| 73 | + |
| 74 | + VERSION_TAG=$(grep "VERSION = " setup.py | cut -d'"' -f2) |
| 75 | + |
| 76 | + # Get the repository name and convert it to lowercase |
| 77 | + REPO_NAME=$(basename ${{ github.repository }} | tr '[:upper:]' '[:lower:]') |
| 78 | + IMAGE_NAME="ghcr.io/sigprofilersuite/$REPO_NAME" |
| 79 | + |
| 80 | + echo "Building version: $VERSION_TAG for image: $IMAGE_NAME" |
| 81 | + |
| 82 | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io \ |
| 83 | + --username "${{ github.actor }}" \ |
| 84 | + --password-stdin |
| 85 | + |
| 86 | + docker build \ |
| 87 | + --build-arg COMMIT_SHA=${{ github.sha }} \ |
| 88 | + -t $IMAGE_NAME:$VERSION_TAG \ |
| 89 | + -t $IMAGE_NAME:latest . |
| 90 | + |
| 91 | + docker push $IMAGE_NAME:$VERSION_TAG |
| 92 | + docker push $IMAGE_NAME:latest |
| 93 | + |
| 94 | + echo "Docker deployment to GHCR successful" |
0 commit comments