Skip to content

Commit 51a9f8a

Browse files
committed
Merge branch 'main' into docs/add-docs-build-checks
2 parents 059267f + 0f4f8c4 commit 51a9f8a

File tree

11 files changed

+191
-180
lines changed

11 files changed

+191
-180
lines changed

.devcontainer/postCreateCommand.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# re-included here for the benefit of manual dev environments.
44
poetry self add "poetry-dynamic-versioning[plugin]"
55
poetry config virtualenvs.in-project true --local
6-
poetry install --with dev --all-extras
6+
poetry install --with dev,docs --all-extras
77
poetry run pre-commit install --install-hooks

.github/workflows/integration-test.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
fail-fast: false
6464
matrix:
6565
os:
66-
- macos-latest
66+
- macos-13
6767
- ubuntu-latest
6868
python-version: ["3.8", "3.9", "3.10", "3.11"]
6969
runs-on: ${{ matrix.os }}
@@ -201,13 +201,14 @@ jobs:
201201
# Gather and prepare the dynamic version and other vars for use with work below.
202202
# For example, 1.1.0.post6.dev0+bc093ef becomes 1.1.0.post6.dev0_bc093ef
203203
- name: Gather dynamic version and set env var
204+
if: (github.event_name == 'push'|| github.event_name == 'schedule') && github.ref == 'refs/heads/main'
204205
id: env-vars
205206
run: >-
206-
echo "CLEAN_VERSION=$(echo ${{ env.sdist_filename }} | tr '+' '_' )" >> "$GITHUB_OUTPUT" &&
207+
echo "CLEAN_VERSION=$(echo ${{ env.sdist_extracted_name }} | tr '+' '_' )" >> "$GITHUB_OUTPUT" &&
207208
echo "DATE_TAG=$(date +'%y%m%d')" >> "$GITHUB_OUTPUT"
208209
- name: Login to Docker Hub
209210
# only run this task if we have a pull request merged or the schedule triggers from main
210-
if: (github.event.pull_request.merged || github.event_name == 'schedule') && github.ref == 'refs/heads/main'
211+
if: (github.event_name == 'push'|| github.event_name == 'schedule') && github.ref == 'refs/heads/main'
211212
uses: docker/login-action@v3
212213
with:
213214
username: ${{ secrets.DOCKER_USER }}
@@ -220,26 +221,27 @@ jobs:
220221
with:
221222
context: "${{ env.sdist_extracted_name }}"
222223
push: true
223-
file: ../build/docker/Dockerfile
224+
file: ./build/docker/Dockerfile
224225
target: production
225226
tags: cytomining/pycytominer:${{ steps.env-vars.outputs.CLEAN_VERSION }}_${{ steps.env-vars.outputs.DATE_TAG }}
226227
# Docker image push based on GitHub pushes to main
227228
- name: Push-based docker image push
228229
# only run this task if we have a pull request which is merged
229-
if: github.event.pull_request.merged && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer'
230+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer'
230231
uses: docker/build-push-action@v5
231232
with:
232233
context: "${{ env.sdist_extracted_name }}"
233234
push: true
234-
file: ../build/docker/Dockerfile
235+
file: ./build/docker/Dockerfile
235236
target: production
236237
tags: cytomining/pycytominer:latest,cytomining/pycytominer:${{ steps.env-vars.outputs.CLEAN_VERSION }}
237238
# update docker hub description using readme on merge
238-
- name: Docker Hub
239+
- name: Update Docker Hub repository description from readme
239240
# only run this task if we have a pull request which is merged
240-
if: github.event.pull_request.merged && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer'
241+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer'
241242
uses: peter-evans/dockerhub-description@v3
242243
with:
243244
username: ${{ secrets.DOCKER_USER }}
244245
password: ${{ secrets.DOCKER_TOKEN }}
245246
repository: cytomining/pycytominer
247+
readme-filepath: "${{ env.sdist_extracted_name }}/README.md"

Makefile

+39-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
1-
# Minimal makefile for Sphinx documentation
2-
#
1+
install: .devcontainer/postCreateCommand.sh ## Install the poetry environment and install the pre-commit hooks
2+
@echo "🛠️ Creating virtual environment using poetry and installing pre-commit hooks"
3+
@bash .devcontainer/postCreateCommand.sh
4+
@echo "🐢 Launching poetry shell"
5+
@poetry shell
36

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

11-
# Put it first so that "make" without argument is like "make help".
12-
help:
13-
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
.PHONY: test
15+
test: ## Test the code with pytest
16+
@echo "🧪 Testing code: Running pytest"
17+
@poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml
18+
19+
.PHONY: docs
20+
docs: ## Build the documentation
21+
@echo "📚 Building documentation"
22+
@poetry run sphinx-build docs build
23+
24+
.PHONY: build
25+
build: clean-build ## Build wheel file using poetry
26+
@echo "🛞 Creating wheel and sdist files"
27+
@poetry build
1428

15-
.PHONY: help Makefile
29+
.PHONY: clean-build
30+
clean-build: ## clean build artifacts
31+
@echo "🧹 Cleaning build artifacts"
32+
@rm -rf dist
1633

17-
# Catch-all target: route all unknown targets to Sphinx using the new
18-
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19-
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
34+
.PHONY: docker-build
35+
test_docker_build: ## Build the docker image and run the tests
36+
@echo "🐳 Building docker image and running tests"
37+
@docker build -f build/docker/Dockerfile -t pycytominer:latest .
38+
@docker run pycytominer:latest poetry run pytest
39+
40+
.PHONY: help
41+
help:
42+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' "$(MAKEFILE_LIST)" | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
2143

22-
# note: presumes the existence of docker daemon to receive docker commands
23-
test_docker_build:
24-
docker build -f build/docker/Dockerfile -t pycytominer:latest . && \
25-
docker run pycytominer:latest poetry run pytest
44+
.DEFAULT_GOAL := help

build/docker/Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ RUN pip install --no-cache-dir poetry
2525
FROM base as production
2626

2727
# copy the pycytominer source into image
28-
COPY . .
28+
COPY README.md pyproject.toml poetry.lock ./
29+
COPY pycytominer ./pycytominer
2930

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

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

37+
# copy the tests dir for testing purposes
38+
COPY tests ./tests
39+
3640
# install pycytominer from poetry with group deps and all extras for testing
3741
RUN poetry install --with dev --all-extras -v --no-interaction

make.bat

-35
This file was deleted.

0 commit comments

Comments
 (0)