CI #113
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: CI | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: | |
- "main" | |
pull_request: | |
branches: | |
- "main" | |
schedule: | |
- cron: "0 0 * * *" | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
test: | |
if: github.event.pull_request.draft == false | |
name: Unit-Test (${{ matrix.os }}, Python ${{ matrix.python-version }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-latest", "macOs-latest"] | |
python-version: ["3.9", "3.10"] | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Checkout Branch / Pull Request | |
uses: actions/checkout@v3 | |
- name: Install Mamba | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: environment.yml | |
create-args: >- | |
python=${{ matrix.python-version }} | |
- name: Install Package | |
run: python -m pip install -e . | |
- name: Test (OS -> ${{ matrix.os }} / Python -> ${{ matrix.python-version }}) | |
run: python -m pytest -v --cov=mosdef_dihedral_fit --cov-append --cov-config=setup.cfg --color yes --pyargs mosdef_dihedral_fit | |
- name: Upload Converage Report | |
uses: codecov/codecov-action@v2 | |
with: | |
name: mosdef_dihedral_fit-Coverage | |
verbose: true | |
docker: | |
runs-on: 'ubuntu-latest' | |
needs: test | |
name: 'Build Docker Image' | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Get Tagged Version | |
run: | | |
echo "DOCKER_TAGS=${{ secrets.DOCKERHUB_USERNAME }}/MoSDeF-dihedral-fit:${GITHUB_REF_NAME}, ${{ secrets.DOCKERHUB_USERNAME }}/MoSDeF-dihedral-fit:stable" >> $GITHUB_ENV | |
if: github.ref_type == 'tag' | |
- name: Get Push Version | |
run: | | |
echo "DOCKER_TAGS=${{ secrets.DOCKERHUB_USERNAME }}/MoSDeF-dihedral-fit:${GITHUB_REF_NAME}, ${{ secrets.DOCKERHUB_USERNAME }}/MoSDeF-dihedral-fit:latest" >> $GITHUB_ENV | |
if: github.ref_type == 'branch' | |
- name: Docker Image Info | |
run: | | |
echo Docker Image tags: ${DOCKER_TAGS} | |
- name: Build and Push | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: ${{ env.DOCKER_TAGS }} |