Skip to content

Commit

Permalink
Merge branch 'main' into docs/add-docs-build-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kenibrewer committed Apr 25, 2024
2 parents 059267f + 0f4f8c4 commit 51a9f8a
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# re-included here for the benefit of manual dev environments.
poetry self add "poetry-dynamic-versioning[plugin]"
poetry config virtualenvs.in-project true --local
poetry install --with dev --all-extras
poetry install --with dev,docs --all-extras
poetry run pre-commit install --install-hooks
18 changes: 10 additions & 8 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
fail-fast: false
matrix:
os:
- macos-latest
- macos-13
- ubuntu-latest
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -201,13 +201,14 @@ jobs:
# Gather and prepare the dynamic version and other vars for use with work below.
# For example, 1.1.0.post6.dev0+bc093ef becomes 1.1.0.post6.dev0_bc093ef
- name: Gather dynamic version and set env var
if: (github.event_name == 'push'|| github.event_name == 'schedule') && github.ref == 'refs/heads/main'
id: env-vars
run: >-
echo "CLEAN_VERSION=$(echo ${{ env.sdist_filename }} | tr '+' '_' )" >> "$GITHUB_OUTPUT" &&
echo "CLEAN_VERSION=$(echo ${{ env.sdist_extracted_name }} | tr '+' '_' )" >> "$GITHUB_OUTPUT" &&
echo "DATE_TAG=$(date +'%y%m%d')" >> "$GITHUB_OUTPUT"
- name: Login to Docker Hub
# only run this task if we have a pull request merged or the schedule triggers from main
if: (github.event.pull_request.merged || github.event_name == 'schedule') && github.ref == 'refs/heads/main'
if: (github.event_name == 'push'|| github.event_name == 'schedule') && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
Expand All @@ -220,26 +221,27 @@ jobs:
with:
context: "${{ env.sdist_extracted_name }}"
push: true
file: ../build/docker/Dockerfile
file: ./build/docker/Dockerfile
target: production
tags: cytomining/pycytominer:${{ steps.env-vars.outputs.CLEAN_VERSION }}_${{ steps.env-vars.outputs.DATE_TAG }}
# Docker image push based on GitHub pushes to main
- name: Push-based docker image push
# only run this task if we have a pull request which is merged
if: github.event.pull_request.merged && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer'
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer'
uses: docker/build-push-action@v5
with:
context: "${{ env.sdist_extracted_name }}"
push: true
file: ../build/docker/Dockerfile
file: ./build/docker/Dockerfile
target: production
tags: cytomining/pycytominer:latest,cytomining/pycytominer:${{ steps.env-vars.outputs.CLEAN_VERSION }}
# update docker hub description using readme on merge
- name: Docker Hub
- name: Update Docker Hub repository description from readme
# only run this task if we have a pull request which is merged
if: github.event.pull_request.merged && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer'
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
repository: cytomining/pycytominer
readme-filepath: "${{ env.sdist_extracted_name }}/README.md"
59 changes: 39 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
# Minimal makefile for Sphinx documentation
#
install: .devcontainer/postCreateCommand.sh ## Install the poetry environment and install the pre-commit hooks
@echo "🛠️ Creating virtual environment using poetry and installing pre-commit hooks"
@bash .devcontainer/postCreateCommand.sh
@echo "🐢 Launching poetry shell"
@poetry shell

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = docs
BUILDDIR = build
.PHONY: check
check: ## Run code quality tools.
@echo "🔒 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check"
@poetry check --lock
@echo "🔎 Linting code: Running pre-commit"
@poetry run pre-commit run -a

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: test
test: ## Test the code with pytest
@echo "🧪 Testing code: Running pytest"
@poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml

.PHONY: docs
docs: ## Build the documentation
@echo "📚 Building documentation"
@poetry run sphinx-build docs build

.PHONY: build
build: clean-build ## Build wheel file using poetry
@echo "🛞 Creating wheel and sdist files"
@poetry build

.PHONY: help Makefile
.PHONY: clean-build
clean-build: ## clean build artifacts
@echo "🧹 Cleaning build artifacts"
@rm -rf dist

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: docker-build
test_docker_build: ## Build the docker image and run the tests
@echo "🐳 Building docker image and running tests"
@docker build -f build/docker/Dockerfile -t pycytominer:latest .
@docker run pycytominer:latest poetry run pytest

.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' "$(MAKEFILE_LIST)" | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

# note: presumes the existence of docker daemon to receive docker commands
test_docker_build:
docker build -f build/docker/Dockerfile -t pycytominer:latest . && \
docker run pycytominer:latest poetry run pytest
.DEFAULT_GOAL := help
6 changes: 5 additions & 1 deletion build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ RUN pip install --no-cache-dir poetry
FROM base as production

# copy the pycytominer source into image
COPY . .
COPY README.md pyproject.toml poetry.lock ./
COPY pycytominer ./pycytominer

# install pycytominer using poetry root dependencies and all extras
RUN poetry install --all-extras -v --no-interaction

# create stage for production build (no dev or non-essential deps)
FROM production as testing

# copy the tests dir for testing purposes
COPY tests ./tests

# install pycytominer from poetry with group deps and all extras for testing
RUN poetry install --with dev --all-extras -v --no-interaction
35 changes: 0 additions & 35 deletions make.bat

This file was deleted.

Loading

0 comments on commit 51a9f8a

Please sign in to comment.