Skip to content
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

WIP - Update versioning #861

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8216895
:wrench: Change to dynamic version for conda-store
trallard Aug 12, 2024
cee18a7
Update pyproject - conda-store
trallard Aug 12, 2024
a3c3700
:wrench: Change to dynamic version - conda-store-server
trallard Aug 12, 2024
51c319c
:see_no_evil: Ensure we do not track version files
trallard Aug 12, 2024
12c3dcf
:heavy_plus_sign: Add dev dependencies
trallard Aug 12, 2024
152e502
:wrench: Update Docker to use scm version
trallard Aug 12, 2024
2460535
:building_construction: Update Dockerfiles to use dynamic version
trallard Aug 12, 2024
054d7a8
:wrench: Move Docker setup to reusable action
trallard Aug 13, 2024
858df46
:construction_worker: Update workflows to use reusable action
trallard Aug 13, 2024
0055529
Add vendoring string to conda-store-ui files
trallard Aug 13, 2024
46db401
We do not need cs version with hatch_build
trallard Aug 13, 2024
072a603
:construction_worker: Fix openapi action
trallard Aug 14, 2024
54f5017
Fetch: 0 so we can get the tags
trallard Aug 27, 2024
273ec5f
Merge branch 'main' into trallard/update-vendoring
trallard Nov 14, 2024
e27faec
Merge branch 'main' into trallard/update-vendoring
trallard Nov 18, 2024
40a1b0b
:construction_worker: Update Docker-related workflows
trallard Nov 18, 2024
c7f13a0
:pencil2: Nit- workflow syntax
trallard Nov 18, 2024
8aaa606
:memo: Update release instructions
trallard Nov 18, 2024
2e22d5b
Uncomment prod code
trallard Nov 18, 2024
1078e6b
Lint files
trallard Nov 18, 2024
bc1d041
Merge branch 'main' into trallard/update-vendoring
trallard Nov 18, 2024
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
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Git
.git
# .git
.gitignore
.gitattributes
# .gitattributes

# Docker
docker-compose.yml
Expand Down
3 changes: 0 additions & 3 deletions .github/ISSUE_TEMPLATE/new-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ Release captain responsible - <@gh_username>

- [ ] Create a new git branch for the release `git checkout -b release-2024.9.1`
- [ ] Prepare the branch just in case `git clean -fxdq`
- [ ] Bump `conda-store` version in [`conda-store/conda-store/__init__.py`](https://github.com/conda-incubator/conda-store/blob/main/conda-store/conda_store/__init__.py)
- [ ] Bump `conda-store-server` version in [`conda-store-server/conda-store-server/__init__.py`](https://github.com/conda-incubator/conda-store/blob/main/conda-store/conda_store/__init__.py)
- [ ] Update the `conda-store-ui` version used in `conda-store-server` [`conda-store-server/hatch_build.py`](https://github.com/conda-incubator/conda-store/blob/main/conda-store-server/hatch_build.py)
- [ ] Update the [CHANGELOG.md](./CHANGELOG.md) file with the new version, release date, and relevant changes[^github-activity].
- [ ] Check the version locally with `hatch version`
Expand Down Expand Up @@ -67,7 +65,6 @@ Release captain responsible - <@gh_username>
- [The Docker images have been published](https://github.com/conda-incubator/conda-store/blob/main/.github/workflows/build_docker_image.yaml)
- [ ] Update the [conda-forge feedstock version](https://github.com/conda-forge/conda-store-feedstock) through a PR or review and merge the regro-bot PR.
- [ ] If needed - update `meta.yaml` or `recipe.yaml` and re-render the feedstock.
- [ ] Open a follow-up PR to bump `conda-store` and `conda-store-server` versions to the next dev-release number (for example `2024.10.1`).
- [ ] Open a follow-up PR to bump the `conda-store-server` version in the [`conda-store-ui` compose file](https://github.com/conda-incubator/conda-store-ui/blob/main/docker-compose.yml).
- [ ] Celebrate, you're done! 🎉

Expand Down
40 changes: 40 additions & 0 deletions .github/actions/docker-setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Setup Docker"
description: "Setup tasks needed to build and publish Docker images"

inputs:
docker-image:
description: "conda-store project to build the Docker image for: conda-store or conda-store-server"
required: true
outputs:
cs-version:
description: "conda-store current version - dirty tag"
value: ${{ steps.get-dev-version.outputs.cs-version }}

runs:
using: "composite"
steps:
- name: "Get dev version 🏷️"
id: get-dev-version
shell: bash
run: |
echo "cs-version=$(git describe --tags)" >> $GITHUB_OUTPUT

- name: "Get project's default Python version 🏷️"
shell: bash
run: |
echo "PYTHON_VERSION_DEFAULT=$(cat .python-version-default)" >> $GITHUB_ENV

- name: "Lint Dockerfiles 🔍"
uses: jbergstroem/hadolint-gh-action@v1
with:
dockerfile: ${{ inputs.docker-image }}/Dockerfile
output_format: tty
error_level: 0

- name: "Set up Docker Buildx 🏗"
uses: docker/setup-buildx-action@v3

- name: "Copy .dockerignore"
run: |
cp .dockerignore ${{ inputs.docker-image }}/.dockerignore
shell: bash
21 changes: 13 additions & 8 deletions .github/workflows/build_docker_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ jobs:
steps:
- name: "Checkout Repository 🛎"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Get project's default Python version 🏷️"
run: |
echo "PYTHON_VERSION_DEFAULT=$(cat .python-version-default)" >> $GITHUB_ENV
- name: "Setup CI environment - Docker 🛠"
uses: ./.github/actions/docker-setup
id: setup-ci-docker
with:
docker-image: ${{ matrix.docker-image }}

- name: "Retrieve secret from Vault 🗝"
uses: hashicorp/vault-action@v3
Expand All @@ -45,9 +49,6 @@ jobs:
kv/data/repository/conda-incubator/conda-store/shared_secrets QUAY_QUANSIGHT_USERNAME | QUAY_USERNAME;
kv/data/repository/conda-incubator/conda-store/shared_secrets QUAY_QUANSIGHT_PASSWORD | QUAY_PASSWORD;

- name: "Set up Docker Buildx 🏗"
uses: docker/setup-buildx-action@v3

- name: "Login to Docker Hub 🐳"
uses: docker/login-action@v3
with:
Expand All @@ -72,8 +73,11 @@ jobs:
type=ref,event=tag
type=sha

# we need this as we are setting the context to subproject directory
- name: "Copy .dockerignore"
- name: "Get project's default Python version 🏷️"
run: |
echo "PYTHON_VERSION_DEFAULT=$(cat .python-version-default)" >> $GITHUB_ENV

- name: "Copy .dockerignore 📄"
run: |
cp .dockerignore ${{ matrix.docker-image }}/.dockerignore
shell: bash
Expand All @@ -92,4 +96,5 @@ jobs:
cache-to: type=gha,mode=max
build-args: |
python_version=${{ env.PYTHON_VERSION_DEFAULT }}
PSEUDO_VERSION=${{ steps.setup-ci-docker.outputs.cs-version }}
platforms: ${{ matrix.platform }}
1 change: 1 addition & 0 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Check conda builds 📦"
uses: jaimergp/conda-build-action@main
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate_api_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
jq . --sort-keys docusaurus-docs/static/openapi.json > docusaurus-docs/static/openapi.json.formatted
mv docusaurus-docs/static/openapi.json.formatted docusaurus-docs/static/openapi.json

- name: Create Pull Request
- name: "Create Pull Request"
uses: peter-evans/create-pull-request@v7
with:
title: "[AUTO] Update openapi.json"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
types: [published]
push:
tags: ["*"]
# needed to publish to test PyPI when merging to main
branches:
- main
workflow_dispatch:

env:
Expand Down
34 changes: 16 additions & 18 deletions .github/workflows/test_build_docker_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ on:
branches:
- main


# ensuring only one instance is running at a given time
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand All @@ -38,25 +37,14 @@ jobs:
steps:
- name: "Checkout Repository 🛎"
uses: actions/checkout@v4

- name: "Get project's default Python version 🏷️"
run: |
echo "PYTHON_VERSION_DEFAULT=$(cat .python-version-default)" >> $GITHUB_ENV

- name: "Set up Docker Buildx 🏗"
uses: docker/setup-buildx-action@v3

- name: "Lint Dockerfiles 🔍"
uses: jbergstroem/hadolint-gh-action@v1
with:
dockerfile: ${{ matrix.docker-image }}/Dockerfile
output_format: tty
error_level: 0
fetch-depth: 0

- name: "Copy .dockerignore"
run: |
cp .dockerignore ${{ matrix.docker-image }}/.dockerignore
shell: bash
- name: "Setup CI environment - Docker 🛠"
uses: ./.github/actions/docker-setup
id: setup-ci-docker
with:
docker-image: ${{ matrix.docker-image }}

- name: "Add Docker metadata 📝"
id: meta
Expand All @@ -67,6 +55,15 @@ jobs:
tags: |
type=sha

- name: "Get project's default Python version 🏷️"
run: |
echo "PYTHON_VERSION_DEFAULT=$(cat .python-version-default)" >> $GITHUB_ENV

- name: "Copy .dockerignore 📄"
run: |
cp .dockerignore ${{ matrix.docker-image }}/.dockerignore
shell: bash

- name: "Build Docker images 🐳"
uses: docker/build-push-action@v5
with:
Expand All @@ -81,4 +78,5 @@ jobs:
cache-to: type=gha,mode=max
build-args: |
python_version=${{ env.PYTHON_VERSION_DEFAULT }}
PSEUDO_VERSION=${{ steps.setup-ci-docker.outputs.cs-version }}
platforms: ${{ matrix.platform }}
2 changes: 2 additions & 0 deletions .github/workflows/test_conda_store_server_unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
steps:
- name: "Checkout Repository 🛎"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Set up Python 🐍"
uses: actions/setup-python@v5
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ dist
build
*.egg-info
.pytest_cache
**/_version.py
_version.py

# data from deployments
data
Expand Down
2 changes: 1 addition & 1 deletion .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
ignored:
- DL3008 # we do not pin apt deps
- DL3003 # already use workkdir
- DL3003 # already use workdir
- DL3042 # already use --no-cache--dir
9 changes: 6 additions & 3 deletions conda-store-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ENV PATH=/opt/conda/condabin:/opt/conda/envs/conda-store-server/bin:/opt/conda/b
ENV TZ=Etc/UTC

# must be passed at build environment (should use .python-version-default)
ARG python_version
ARG python_version="3.12"
ARG conda_env_name="conda-store-server"
ARG user_no=1000

Expand Down Expand Up @@ -62,8 +62,8 @@ COPY ./ /opt/conda-store-server/

USER 0:0
RUN chown -R ${user_no}:${user_no} /opt/conda-store-server/ && \
mkdir -p /.local/share/conda-store && \
chown -R ${user_no}:${user_no} /.local/share/conda-store
mkdir -p /.local/share/conda-store && \
chown -R ${user_no}:${user_no} /.local/share/conda-store

USER ${user_no}:${user_no}

Expand All @@ -84,6 +84,9 @@ WORKDIR /var/lib/conda-store
# ---------------------------------------------------------------------------------
# for development images we install conda-store-server in editable mode
FROM base AS dev
ARG PSEUDO_VERSION=1.0.0
# we need to set the environment variable for setuptools_scm to work
ENV SETUPTOOLS_SCM_PRETEND_VERSION=${PSEUDO_VERSION}

WORKDIR /opt/conda-store-server
RUN which python && \
Expand Down
39 changes: 32 additions & 7 deletions conda-store-server/conda_store_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,43 @@
import datetime
import hashlib
import typing

import platformdirs
from pathlib import Path

if typing.TYPE_CHECKING:
from ._internal.orm import Build
from .app import CondaStore


__version__ = "2024.11.2-dev"


CONDA_STORE_DIR = platformdirs.user_data_path(appname="conda-store")
# For runtime, we use platformdirs to get the user data directory and ensure
# this is cross-platform
try:
import platformdirs

CONDA_STORE_DIR = platformdirs.user_data_path(appname="conda-store")
# at build time, we use Path.home() to default to the user's home directory
# this is a workaround as we cannot import platformdirs at build time
except ImportError:
CONDA_STORE_DIR = Path.home() / ".conda-store"

# Since we are now using vcs we need to define the variable '__version__':
try:
# If setuptools_scm is installed (e.g. in a development environment with
# an editable install), then use it to determine the version dynamically.
from setuptools_scm import get_version

# This will fail with LookupError if the package is not installed in
# editable mode or if Git is not installed.
__version__ = get_version(root="../..", relative_to=__file__)
except (ImportError, LookupError):
# As a fallback, use the version that is hard-coded in the file.
try:
from conda_store_server._version import __version__ # noqa: F401
except ModuleNotFoundError:
# The user is probably trying to run this without having installed
# the package, so complain.
raise RuntimeError(
"conda-store-server is not correctly installed. "
"Please install it with pip."
)


class BuildKey:
Expand Down
1 change: 1 addition & 0 deletions conda-store-server/environment-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ dependencies:
- pip:
- pytest-playwright
- build
- setuptools-scm>=6.4.0
14 changes: 11 additions & 3 deletions conda-store-server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# license that can be found in the LICENSE file.
[build-system]
# https://github.com/ofek/hatch-vcs
requires = ["hatchling>=1.14.0", "hatch-vcs"]
requires = ["hatchling>=1.14.0", "hatch-vcs", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"

[project]
Expand Down Expand Up @@ -81,11 +81,16 @@ dynamic = ["version"]

[project.urls]
Homepage = "https://conda.store/"
Source = "https://github.com/conda-incubator/conda-store"
Source = "https://github.com/conda-incubator/conda-store/conda-store-server"
Issues = "https://github.com/conda-incubator/conda-store/issues"

[tool.hatch.version]
path = "conda_store_server/__init__.py"
source = "vcs"
# need to specify root as .git is one level up
raw-options = { root = "../", relative_to = "pyproject.toml", local_scheme = "node-and-date" }

[tool.hatch.build.hooks.vcs]
version-file = "conda_store_server/_version.py"

[tool.hatch.envs.dev]
dependencies = [
Expand All @@ -100,13 +105,16 @@ dependencies = [
"twine>=5.0.0",
"pkginfo>=1.10", # Needed to support metadata 2.3
"pytest-cov",
"setuptools-scm>=6.4.0"
]

[tool.hatch.envs.lint]
dependencies = ["pre-commit"]

[tool.hatch.envs.lint.scripts]
lint = ["pre-commit run --all"]

[tool.hatch.envs.test.scripts]
unit-test = "pytest -m 'not extended_prefix and not user_journey' tests"
playwright-test = [
"playwright install",
Expand Down
1 change: 1 addition & 0 deletions conda-store/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules/
*.tsbuildinfo
__pycache__
.DS_Store
**/_version.py
Loading
Loading