Skip to content

chore: Update pyproject.toml to work with Poetry 2.x #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .containerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.[a-z]*
.venv/*
*.sh
*.xml
CHANGELOG.md
Dockerfile
tests/*
tmp/*
3 changes: 3 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ jobs:
linting:
uses: broadinstitute/shared-workflows/.github/workflows/python-lint.yaml@v2.4.0
with:
ruff_version: '0.8.6'
use_pylama: false
use_ruff: true
unit-tests:
uses: broadinstitute/shared-workflows/.github/workflows/python-unit-test.yaml@v2.4.0
with:
python_package_name: cert_manager
run_coverage: false
test_runner: pytest
2 changes: 0 additions & 2 deletions .green

This file was deleted.

6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -28,12 +28,12 @@ repos:
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.14
rev: v0.8.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.33.0
rev: v1.35.1
hooks:
- id: yamllint
args:
Expand Down
30 changes: 30 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM docker.io/node:bookworm AS prettier-install
RUN yarn add prettier@3

FROM python:3.11-slim-bookworm

ARG LOCAL_BIN=/root/.local/bin
ENV PATH=$LOCAL_BIN:$PATH

# Install prettier
RUN mkdir -p $LOCAL_BIN
COPY --from=prettier-install /usr/local/bin/node $LOCAL_BIN
COPY --from=prettier-install /node_modules/prettier /prettier
RUN ln -s /prettier/bin/prettier.cjs $LOCAL_BIN/prettier

COPY . /working/

WORKDIR /working

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -yq --no-install-recommends curl make \
&& curl -sSL https://install.python-poetry.org | python3 - \
&& poetry install \
&& rm -rf /tmp/* \
&& rm -rf /var/cache/apt/* \
&& rm -rf /var/tmp/*

ENTRYPOINT ["poetry", "run"]

CMD ["bash"]
20 changes: 0 additions & 20 deletions Dockerfile

This file was deleted.

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This library provides a [Python][1] interface to the [Sectigo][2] Certificate Ma

## Basics

`cert_manager` runs on [Python][1] >= 3.7
`cert_manager` runs on [Python][1] >= 3.9

## Features

Expand Down Expand Up @@ -109,15 +109,15 @@ Pull requests to add functionality and fix bugs are always welcome. Please chec

### Testing

We try to have a high level of test coverage on the code. Therefore, when adding anything to the repo, tests should be written to test a new feature or to test a bug fix so that there won't be a regression. This library is setup to be pretty simple to build a working development environment using [Docker][4]. Therefore, it is suggested that you have [Docker][4] installed where you clone this repository to make development easier.
We try to have a high level of test coverage on the code. Therefore, when adding anything to the repo, tests should be written to test a new feature or to test a bug fix so that there won't be a regression. This library is setup to be pretty simple to build a working development environment using [Docker][4]. Therefore, it is suggested that you have [Docker][4] installed where you clone this repository to make development easier.

To start a development environment, you should be able to just run the `dev.sh` script. This script will use the `Dockerfile` in this repository to build a [Docker][4] container with all the dependencies for development installed using [Pipenv][3].
To start a development environment, you should be able to just run the `dev.bash` script. This script will use the `Containerfile` in this repository to build a [Docker][4] container with all the dependencies for development installed using [Poetry][3].

```sh
./dev.sh
./dev.bash
```

The first time you run the script, it should build the [Docker][4] image and then drop you into the container's shell. The directory where you cloned this repository should be volume mounted in to `/usr/src`, which should also be the current working directory. From there, you can make changes as you see fit. Tests can be run from the `/usr/src` directory by simply typing `green` as [green][5] has been setup to with the correct parameters.
The first time you run the script, it should build the [Docker][4] image and then drop you into the container's shell. The directory where you cloned this repository should be volume mounted in to `/working`, which should also be the current working directory. From there, you can make changes as you see fit. Tests can be run from the `/working` directory by simply typing `pytest` as [pytest][5] has been setup to with the correct parameters.

## Changelog

Expand Down Expand Up @@ -162,7 +162,7 @@ git push --tags

[1]: https://www.python.org/ "Python"
[2]: https://sectigo.com/ "Sectigo"
[3]: https://pipenv.readthedocs.io/en/latest/ "Pipenv"
[3]: https://python-poetry.org/ "Poetry"
[4]: https://www.docker.com/ "Docker"
[5]: https://github.com/CleanCut/green "green"
[5]: https://docs.pytest.org/en/stable/ "pytest"
[6]: https://pypi.org/project/bump2version/ "bump2version"
89 changes: 89 additions & 0 deletions dev.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash

declare -g CHECKSUM_APP
declare -g CONTAINER_APP
declare -g CONTAINER_IMAGE='cert_manager:dev'
declare -g LABEL_PREFIX='org.broadinstitute.cert-manager'
declare -g SCRIPT_DIR
declare -ga TRACK_FILES=( Containerfile poetry.lock pyproject.toml )
declare -ga SUDO
declare -ag TTY

SCRIPT_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if hash sha256sum 2>/dev/null; then
CHECKSUM_APP='sha256sum'
elif hash shasum 2>/dev/null; then
CHECKSUM_APP='shasum -a 256'
elif hash md5sum 2>/dev/null; then
CHECKSUM_APP='md5sum'
else
echo 'Could not find a checksumming program. Exiting!'
exit 1
fi

if hash docker 2>/dev/null; then
CONTAINER_APP='docker'
elif hash podman 2>/dev/null; then
CONTAINER_APP='podman'
else
echo 'Container environment cannot be found. Exiting!'
exit 2
fi

if [[ "${TERM}" != 'dumb' ]]; then
TTY=( -it )
fi

if [[ "${CONTAINER_APP}" = 'docker' ]] && [[ "$( uname -s )" != 'Darwin' ]]; then
if [[ ! -w "${DOCKER_SOCKET}" ]]; then
SUDO=( sudo )
fi
fi

function build() {
if [[ -z "$1" ]]; then
echo 'Image name not provided to build. Exiting!'
exit 1
fi
CONTAINER_IMAGE=$1

if ! git diff --quiet; then
echo 'Branch is dirty. The build can only happen on an unmodified branch.'
exit 2
fi

local -a labels
for tfile in "${TRACK_FILES[@]}"; do
label="$( "${CHECKSUM_APP}" "${tfile}" | awk -v PREFIX="${LABEL_PREFIX}" '{print PREFIX"."$2"="$1}' )"
labels+=( --label "${label}" )
done

"${SUDO[@]}" "${CONTAINER_APP}" build --pull -t "${CONTAINER_IMAGE}" "${labels[@]}" .
}

pushd "${SCRIPT_DIR}" >/dev/null || exit 1
if ! "${SUDO[@]}" "${CONTAINER_APP}" image ls | awk '{print $1":"$2}' | grep --quiet -E "^(localhost\/)*${CONTAINER_IMAGE}"; then
build "${CONTAINER_IMAGE}"
fi

rebuild='0'
for tfile in "${TRACK_FILES[@]}"; do
current="$( "${CHECKSUM_APP}" "${tfile}" | cut -d' ' -f1 )"
stored="$( "${CONTAINER_APP}" image inspect --format="{{index .Config.Labels \"${LABEL_PREFIX}.${tfile}\"}}" "${CONTAINER_IMAGE}" )"

if [[ "${current}" != "${stored}" ]]; then
echo "${tfile} changed. Rebuilding."
rebuild='1'
fi
done

if [[ "${rebuild}" == '1' ]]; then
build "${CONTAINER_IMAGE}"
fi

"${SUDO[@]}" "${CONTAINER_APP}" run "${TTY[@]}" --rm \
-v "${SCRIPT_DIR}:/working" \
"${CONTAINER_IMAGE}" "$@"

popd >/dev/null || exit 1
26 changes: 0 additions & 26 deletions dev.sh

This file was deleted.

Loading
Loading