Skip to content

Commit 1f9fee7

Browse files
authored
Merge pull request #337 from gkreitz/release_fix
Prepare for release 1.20250605 and for moving development from `devel` to `master`
2 parents 85db18e + 4674e2a commit 1f9fee7

File tree

6 files changed

+471
-39
lines changed

6 files changed

+471
-39
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2010-2019 Kattis and all respective contributors
3+
Copyright (c) Kattis and all respective contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Kattis Problem Tools
22

3-
master:
4-
![Master Build Status](https://github.com/kattis/problemtools/actions/workflows/python-app.yml/badge.svg?branch=master)
5-
develop:
6-
![Develop Build Status](https://github.com/kattis/problemtools/actions/workflows/python-app.yml/badge.svg?branch=develop)
3+
![Build Status](https://github.com/kattis/problemtools/actions/workflows/python-app.yml/badge.svg?branch=master)
4+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
75

8-
These are tools to manage problem packages using the Kattis problem package
9-
format.
6+
These are tools to manage problem packages using the Kattis [problem package
7+
format](https://www.kattis.com/problem-package-format/). The problem package
8+
specification is developed in the [problem package format
9+
repository](https://github.com/Kattis/problem-package-format).
1010

1111

1212
## Programs Provided
@@ -47,11 +47,15 @@ A few examples of problem packages can be found in [examples](examples).
4747
There are four supported ways of installing and running problemtools.
4848
(For non-Linux users, "Method 2" below, to use Docker, is probably the least painful.)
4949

50+
Note that in all methods except for "Method 2", you must manually install
51+
dependencies such as LaTeX and tools for any languages you want to use. See
52+
[Requirements and compatbility](#requirements-and-compatibility) for details.
53+
5054
### Method 1: Install the Python package using pipx
5155

5256
Run
5357
```
54-
pipx install git+https://github.com/kattis/problemtools
58+
pipx install problemtools
5559
```
5660

5761
In order to get the command line scripts, you need to make sure that the local
@@ -77,19 +81,30 @@ We maintain three official problemtools Docker images on Docker Hub:
7781

7882
- [`problemtools/minimal`](https://hub.docker.com/r/problemtools/minimal/): this image only contains problemtools, no additional programming languages. As such, it is not particularly useful on its own, but if you are organizing a contest and want to set up a problemtools environment containing exactly the right set of compilers/interpreters for your contest, this is the recommended starting point.
7983

80-
For example, suppose you want to use the `problemtools/icpc` image. To get started, install the [Docker CLI](https://docs.docker.com/install), and then pull the image:
84+
For example, suppose you want to use the `problemtools/icpc` image. To get started (or update to the latest release), install the [Docker CLI](https://docs.docker.com/install), and then pull the image:
8185

8286
docker pull problemtools/icpc
8387

84-
Once the image has finished downloading, you can check that it exists on your system using `docker images`. To launch an interactive container and play around with *verifyproblem*, *problem2pdf*, and *problem2html* run:
88+
The most convenient way to use the container is by creating shell script(s) similar to this and add it to your `$PATH`. If you call the script `verifyproblem.sh`, you could then `verifyproblem.sh examples/hello` to use the icpc docker image to verify examples/hello:
89+
```sh
90+
#!/bin/bash
91+
92+
if [ $1 -a -d $1 ]; then
93+
docker run --rm -t -v $(dirname $(readlink -f $1)):/work problemtools/icpc verifyproblem /work/$(basename $1)
94+
else
95+
echo No such directory: $1
96+
fi
97+
```
98+
99+
To instead launch an interactive container and play around with *verifyproblem*, *problem2pdf*, and *problem2html* run:
85100

86101
docker run --rm -it problemtools/icpc
87102

88103
By default, docker containers do _NOT_ persist storage between runs, so any files you create or modify will be lost when the container stops running. Two common ways of dealing with this are:
89104

90-
1) Use a [bind mount](https://docs.docker.com/storage/bind-mounts/) to mount a directory on your machine into the docker container. This can be done as follows (see Docker documentation for further details):
105+
1) Use a [bind mount](https://docs.docker.com/storage/bind-mounts/) to mount a directory on your machine into the docker container. Mounting the current directory to /kattis_work_dir can be done as follows (see Docker documentation for further details):
91106
```
92-
docker run --rm -it -v ${FULL_PATH_TO_MOUNT}:/kattis_work_dir problemtools/icpc
107+
docker run --rm -it -v $(pwd):/kattis_work_dir problemtools/icpc
93108
```
94109
2) Persist any changes you want to keep to a remote file system/source control (e.g., a remote Git repository; note, however, that you would first need to install Git in the image).
95110
@@ -211,7 +226,8 @@ problemtools' configuration:
211226
## Requirements and compatibility
212227
213228
To build and run the tools, you need Python 3 with the YAML and PlasTeX libraries,
214-
and a LaTeX installation.
229+
and a LaTeX installation. You must also install language tools (e.g., compilers)
230+
for any languages used in problem packages.
215231
216232
### Ubuntu
217233

admin/build_pypi_packages.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ set -e
44
ALLOW_DIRTY=false
55
TAG=develop
66

7+
echo N.B., this script is solely to allow for local testing of whl/src.
8+
echo To actually build and push things to pypi, trigger the pypi flow
9+
echo in github actions, https://github.com/Kattis/problemtools/actions
10+
711
while getopts "d" opt; do
812
case $opt in
913
d) ALLOW_DIRTY=true ;;

admin/make_release.sh

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#!/usr/bin/env bash
22
#
3-
# Uses git flow and gbp tools (available through Ubuntu packages
4-
# git-flow, git-buildpackage)
3+
# Uses gbp (available through Ubuntu package git-buildpackage)
54

65
set -e
76

7+
ALLOW_DIRTY=false
8+
while getopts "d" opt; do
9+
case $opt in
10+
d) ALLOW_DIRTY=true ;;
11+
\?) echo "Invalid option: -$opt" ;;
12+
esac
13+
done
14+
815
ROOT=$(readlink -f $(dirname $0)/..)
916
VERSION=1.$(date +%Y%m%d)
1017

@@ -16,20 +23,50 @@ if [ "$(git tag -l v$VERSION)" != "" ]; then
1623
VERSION=$VERSION-rev$REV
1724
fi
1825

19-
set -x
2026

21-
git flow release start --showcommands $VERSION
27+
# Steps:
28+
# Pick a version (done by the above loop)
29+
# Update debian/changelog using gbp
30+
# Create and merge pull request with the updated debian/changelog
31+
# Create a github release (using web UI) or gh
32+
# Push to pypi using github action
33+
# Push to docker using admin/update_docker.sh v$VERSION
34+
35+
CHANGELOG_VERSION=$(dpkg-parsechangelog -l $ROOT/debian/changelog --show-field Version)
36+
if [[ $CHANGELOG_VERSION == $VERSION ]]; then
37+
echo "Debian changelog seems updated"
38+
else
39+
echo "Updating debian changelog (this is surprisingly slow)"
40+
EMAIL=$(git config user.email) gbp dch $ROOT --release --new-version=$VERSION --ignore-branch --git-author --debian-tag='v%(version)s' --debian-branch=release/$VERSION --spawn-editor=never
41+
echo "Please commit the updated changelog, do a pull request, and get it merged, then run this script again on an up-to-date master branch"
42+
exit 0
43+
fi
2244

23-
# Update _version.py
24-
$ROOT/admin/update_version.py.sh $VERSION
45+
cd $(dirname $(readlink -f $0))
2546

26-
# Update debian/changelog
27-
gbp dch $ROOT --release --new-version=$VERSION --git-author --debian-tag='v%(version)s' --debian-branch=release/$VERSION --spawn-editor=never
47+
if [[ -n $(git status -s) ]]; then
48+
echo "Repository is dirty."
49+
git status -s
50+
[[ "${ALLOW_DIRTY}" != "true" ]] && exit 1
51+
fi
2852

29-
git add $ROOT/problemtools/_version.py $ROOT/debian/changelog
30-
git commit -m "Release of version $VERSION: bump version in problemtools/_version.py and debian/changelog"
53+
GITTAG=master
54+
if [[ $(git rev-parse --abbrev-ref HEAD) != ${GITTAG} && $(git describe --exact-match --tags 2>/dev/null) != ${GITTAG} ]]; then
55+
echo "Repository is currently not on branch/tag ${GITTAG}."
56+
[[ "${ALLOW_DIRTY}" != "true" ]] && exit 1
57+
fi
58+
59+
THIS_REPO_VERSION=$(git -C $(dirname -- "$0") rev-parse HEAD)
60+
UPSTREAM_VERSION=$(git -C $(dirname -- "$0") ls-remote upstream master | cut -f1)
61+
if [[ $THIS_REPO_VERSION != $UPSTREAM_VERSION ]]; then
62+
echo "Warning: git head of repo does not match upstream. You likely want to update this repo"
63+
[[ "${ALLOW_DIRTY}" != "true" ]] && exit 1
64+
fi
3165

32-
git flow release finish --showcommands --message "Release $VERSION" $VERSION
3366

34-
echo "After pushing changes to GitHub, please run"
35-
echo " $ROOT/admin/update_docker.sh v$VERSION"
67+
echo "Below is untested, echoing commands instead of running them"
68+
echo "Creating a draft release on github"
69+
echo gh -R Kattis/problemtools release create -d v$VERSION
70+
echo "After finalizing the release on GitHub, please:"
71+
echo " - trigger the pypi release workflow"
72+
echo " - run $ROOT/admin/update_docker.sh v$VERSION"

admin/update_docker.sh

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
set -e
33

44
ALLOW_DIRTY=false
5-
TAG=develop
5+
GITTAG=master
6+
DOCKERTAG=develop
67
UPDATE_LATEST=false
78

89
while getopts "d" opt; do
@@ -15,7 +16,8 @@ done
1516
shift $((OPTIND-1))
1617

1718
if [ "$1" != "" ]; then
18-
TAG=$1
19+
GITTAG=$1
20+
DOCKERTAG=$1
1921
UPDATE_LATEST=true
2022
fi
2123

@@ -27,19 +29,21 @@ if [[ -n $(git status -s) ]]; then
2729
[[ "${ALLOW_DIRTY}" != "true" ]] && exit 1
2830
fi
2931

30-
if [[ $(git rev-parse --abbrev-ref HEAD) != ${TAG} && $(git describe --exact-match --tags 2>/dev/null) != ${TAG} ]]; then
31-
echo "Repository is currently not on branch/tag ${TAG}."
32+
if [[ $(git rev-parse --abbrev-ref HEAD) != ${GITTAG} && $(git describe --exact-match --tags 2>/dev/null) != ${GITTAG} ]]; then
33+
echo "Repository is currently not on branch/tag ${GITTAG}."
3234
[[ "${ALLOW_DIRTY}" != "true" ]] && exit 1
3335
fi
3436

37+
echo "Updating Ubuntu base image"
38+
docker pull ubuntu:24.04
3539

3640
# Make our internal images, and our githubci image. Order is important, images depend on each other
3741
echo "Building intermediate images, plus githubci image"
3842
for IMAGE in runreqs build icpclangs fulllangs githubci; do
3943
docker build \
4044
-f Dockerfile.${IMAGE} \
41-
-t problemtools/${IMAGE}:${TAG} \
42-
--build-arg PROBLEMTOOLS_VERSION="${TAG}" \
45+
-t problemtools/${IMAGE}:${DOCKERTAG} \
46+
--build-arg PROBLEMTOOLS_VERSION="${DOCKERTAG}" \
4347
.
4448
done
4549

@@ -48,21 +52,21 @@ echo "Building deb"
4852
mkdir -p artifacts
4953
sudo rm -rf artifacts/deb
5054
# Use our build image to build a deb
51-
docker run --rm -v "$(pwd)/../..:/problemtools" -v "$(pwd)/artifacts/deb:/artifacts" problemtools/build:${TAG} \
55+
docker run --rm -v "$(pwd)/../..:/problemtools" -v "$(pwd)/artifacts/deb:/artifacts" problemtools/build:${DOCKERTAG} \
5256
/bin/bash -c "
5357
set -e ;
5458
mkdir /build ;
5559
cd /build ;
5660
git config --global --add safe.directory /problemtools/.git ;
57-
git clone --branch ${TAG} /problemtools ;
61+
git clone --branch ${GITTAG} /problemtools ;
5862
cd problemtools ;
5963
make builddeb ;
6064
cp ../*.deb /artifacts"
6165
sudo chown -R $USER:$USER artifacts/
6266

6367

6468
echo "Testing deb"
65-
if ! docker run --rm -t -v "$(pwd)/../..:/problemtools" -v "$(pwd)/artifacts/deb:/artifacts" problemtools/fulllangs:${TAG} \
69+
if ! docker run --rm -t -v "$(pwd)/../..:/problemtools" -v "$(pwd)/artifacts/deb:/artifacts" problemtools/fulllangs:${DOCKERTAG} \
6670
/bin/bash -c '
6771
set -e ;
6872
shopt -s extglob ;
@@ -78,17 +82,17 @@ echo "Building complete images with problemtools baked in"
7882
for IMAGE in minimal icpc full; do
7983
docker build \
8084
-f Dockerfile.${IMAGE} \
81-
-t problemtools/${IMAGE}:${TAG} \
82-
--build-arg PROBLEMTOOLS_VERSION="${TAG}" \
85+
-t problemtools/${IMAGE}:${DOCKERTAG} \
86+
--build-arg PROBLEMTOOLS_VERSION="${DOCKERTAG}" \
8387
.
8488
done
8589

8690

8791
if [ "${UPDATE_LATEST}" = "true" ]; then
8892
echo "Build complete. If you are happy with the images, run the following:"
8993
for IMAGE in minimal icpc full githubci; do
90-
echo " docker tag problemtools/${IMAGE}:${TAG} problemtools/${IMAGE}:latest"
91-
echo " docker push problemtools/${IMAGE}:${TAG}"
94+
echo " docker tag problemtools/${IMAGE}:${DOCKERTAG} problemtools/${IMAGE}:latest"
95+
echo " docker push problemtools/${IMAGE}:${DOCKERTAG}"
9296
echo " docker push problemtools/${IMAGE}:latest"
9397
done
9498
fi

0 commit comments

Comments
 (0)