Fix and update Dockerfile #1812
Workflow file for this run
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 | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
branches: | |
- "main" | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
test: | |
if: github.event.pull_request.draft == false | |
name: mBuild Tests (python) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Branch / Pull Request | |
- name: Install Mamba (Linux) | |
uses: mamba-org/setup-micromamba@v2 | |
with: | |
environment-file: environment-dev.yml | |
create-args: >- | |
python=${{ matrix.python-version }} | |
if: runner.os != 'Windows' | |
- name: Install Mamba (Windows) | |
uses: mamba-org/setup-micromamba@v2 | |
with: | |
environment-file: environment-dev-win.yml | |
create-args: >- | |
python=${{ matrix.python-version }} | |
if: runner.os == 'Windows' | |
- name: Install Package | |
run: python -m pip install -e . | |
- name: Test (OS -> ${{ matrix.os }} / Python -> ${{ matrix.python-version }}) | |
run: python -m pytest -v --cov=mbuild --cov-report=xml --cov-append --cov-config=setup.cfg --color yes --pyargs mbuild | |
- name: Upload Coverage Report | |
uses: codecov/codecov-action@v5 | |
with: | |
name: mBuild-Coverage | |
verbose: true | |
files: ./coverage.xml | |
arch-test: | |
if: github.event.pull_request.draft == false | |
name: mBuild Tests (arch) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macOS-latest, macOS-13, ubuntu-latest, windows-latest] | |
python-version: ["3.12"] | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Branch / Pull Request | |
- name: Install Mamba (Linux) | |
uses: mamba-org/setup-micromamba@v2 | |
with: | |
environment-file: environment-dev.yml | |
create-args: >- | |
python=${{ matrix.python-version }} | |
if: runner.os != 'Windows' | |
- name: Install Mamba (Windows) | |
uses: mamba-org/setup-micromamba@v2 | |
with: | |
environment-file: environment-dev-win.yml | |
create-args: >- | |
python=${{ matrix.python-version }} | |
if: runner.os == 'Windows' | |
- name: Install Package | |
run: python -m pip install -e . | |
- name: Test (OS -> ${{ matrix.os }} / Python -> ${{ matrix.python-version }}) | |
run: python -m pytest -v --cov=mbuild --cov-report=xml --cov-append --cov-config=setup.cfg --color yes --pyargs mbuild | |
bleeding-edge-test: | |
if: github.event.pull_request.draft == false | |
name: Bleeding Edge mosdef Tests for mBuild | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Branch / Pull Request | |
- name: Install Mamba | |
uses: mamba-org/setup-micromamba@v2 | |
with: | |
environment-file: environment-dev.yml | |
create-args: python=3.12 | |
- name: Install Packages from Source | |
run: | | |
pip install -e . | |
- name: Run Bleeding Edge Tests | |
run: | | |
python -m pytest -v --color yes --pyargs mbuild | |
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@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Get Tagged Version | |
run: | | |
echo "DOCKER_TAGS=mosdef/mbuild:${GITHUB_REF_NAME}, mosdef/mbuild:stable" >> $GITHUB_ENV | |
if: github.ref_type == 'tag' | |
- name: Get Push Version | |
run: | | |
echo "DOCKER_TAGS=mosdef/mbuild:${GITHUB_REF_NAME}, mosdef/mbuild: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@v6 | |
with: | |
push: true | |
tags: ${{ env.DOCKER_TAGS }} | |
build_docker_on_change: | |
runs-on: ubuntu-latest | |
name: Build Docker Image (no push) | |
steps: | |
# Checkout the repository | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Check if Dockerfile was changed | |
- name: Check for Dockerfile changes | |
id: dockerfile_check | |
run: | | |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q "^Dockerfile$"; then | |
echo "Dockerfile changed" | |
echo "changed=true" >> $GITHUB_ENV | |
else | |
echo "Dockerfile not changed" | |
echo "changed=false" >> $GITHUB_ENV | |
fi | |
# Skip remaining steps if Dockerfile wasn't changed | |
- name: Stop if no changes | |
if: env.changed == 'false' | |
run: echo "No Dockerfile changes detected. Skipping build." | |
# Set up Docker Buildx | |
- name: Set up Docker Buildx | |
if: env.changed == 'true' | |
uses: docker/setup-buildx-action@v3 | |
# Get Push Version | |
- name: Get Push Version | |
if: env.changed == 'true' && github.ref_type == 'branch' | |
run: | | |
echo "DOCKER_TAGS=mosdef/mbuild:${GITHUB_REF_NAME}, mosdef/mbuild:latest" >> $GITHUB_ENV | |
# Docker Image Info | |
- name: Docker Image Info | |
if: env.changed == 'true' | |
run: | | |
echo Docker Image tags: ${DOCKER_TAGS} | |
# Build Docker Image | |
- name: Build Docker Image | |
if: env.changed == 'true' | |
uses: docker/build-push-action@v6 | |
with: | |
push: false | |
tags: ${{ env.DOCKER_TAGS }} |