-
Notifications
You must be signed in to change notification settings - Fork 21
CD integration for uploading to HotCRP #85
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
6e3c0b7
e124622
b6a6ce0
9ade059
f039e49
c8edc36
aed75d6
b9d3d2c
06e4183
9de19f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # HotCRP submission settings. | ||
| # HOTCRP_TOKEN is intentionally not stored here. Configure it as a GitHub | ||
| # Actions repository secret, or provide it in the local environment. | ||
| HOTCRP_ACTION_UPLOAD_ENABLED=false | ||
| HOTCRP_SITE_URL=https://asplos26.hotcrp.com | ||
| HOTCRP_PID=TODO | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,135 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| set -euo pipefail | ||||||
|
|
||||||
| default_config_file=".github/hotcrp.env" | ||||||
| config_file="${1:-$default_config_file}" | ||||||
|
|
||||||
| usage() { | ||||||
| cat <<'EOF' | ||||||
| Usage: | ||||||
| tools/upload-to-hotcrp.sh [CONFIG_FILE] | ||||||
| tools/upload-to-hotcrp.sh --help | ||||||
|
|
||||||
| Uploads a paper PDF to the configured HotCRP submission. | ||||||
|
|
||||||
| CONFIG_FILE is sourced as a shell env file. If omitted, .github/hotcrp.env is | ||||||
| sourced when it exists; otherwise existing environment variables are used. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this actually accurate w.r.t what's implemented?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now it is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👦 written not 🤖 |
||||||
|
|
||||||
| Required values: | ||||||
| HOTCRP_SITE_URL HotCRP site base URL, for example https://asplos26.hotcrp.com | ||||||
| HOTCRP_PID Numeric HotCRP paper ID | ||||||
| HOTCRP_TOKEN HotCRP API token | ||||||
|
|
||||||
| GitHub Actions control: | ||||||
| HOTCRP_ACTION_UPLOAD_ENABLED | ||||||
| In GitHub Actions, must be exactly true to upload. | ||||||
| Defaults to false. | ||||||
|
|
||||||
| Optional overrides: | ||||||
| HOTCRP_PDF PDF to upload. Defaults to submission.pdf. | ||||||
|
|
||||||
| Local example: | ||||||
| HOTCRP_TOKEN=... tools/upload-to-hotcrp.sh .github/hotcrp.env | ||||||
| HOTCRP_SITE_URL=... HOTCRP_PID=123 HOTCRP_TOKEN=... tools/upload-to-hotcrp.sh | ||||||
| EOF | ||||||
| } | ||||||
|
|
||||||
| die() { | ||||||
| printf 'error: %s\n' "$*" >&2 | ||||||
| exit 1 | ||||||
| } | ||||||
|
|
||||||
| require_var() { | ||||||
| local name="$1" | ||||||
| local value="${!name:-}" | ||||||
|
|
||||||
| if [ -z "$value" ] || [ "$value" = "TODO" ] || [ "$value" = "TODO_REPLACE_ME" ]; then | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Do we really need to check for two different todo values?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we now check for all the TODO values |
||||||
| die "$name is not set. Update $config_file or provide it in the environment." | ||||||
| fi | ||||||
| } | ||||||
|
|
||||||
| require_command() { | ||||||
| local name="$1" | ||||||
|
|
||||||
| command -v "$name" >/dev/null 2>&1 || die "required command is not available: $name" | ||||||
| } | ||||||
|
|
||||||
| case "${1:-}" in | ||||||
| -h|--help) | ||||||
| usage | ||||||
| exit 0 | ||||||
| ;; | ||||||
| esac | ||||||
|
|
||||||
| if [ "$#" -gt 0 ] || [ -f "$config_file" ]; then | ||||||
| [ -f "$config_file" ] || die "missing HotCRP config file: $config_file" | ||||||
|
|
||||||
| set -a | ||||||
| # shellcheck source=/dev/null | ||||||
| . "$config_file" | ||||||
| set +a | ||||||
| fi | ||||||
|
|
||||||
| HOTCRP_ACTION_UPLOAD_ENABLED="${HOTCRP_ACTION_UPLOAD_ENABLED:-false}" | ||||||
| HOTCRP_PDF="${HOTCRP_PDF:-submission.pdf}" | ||||||
|
|
||||||
| if [ "${GITHUB_ACTIONS:-false}" = "true" ] && [ "$HOTCRP_ACTION_UPLOAD_ENABLED" != "true" ]; then | ||||||
| printf 'HotCRP upload is disabled by %s; set HOTCRP_ACTION_UPLOAD_ENABLED=true to enable it.\n' "$config_file" | ||||||
| exit 0 | ||||||
| fi | ||||||
|
|
||||||
| require_var HOTCRP_SITE_URL | ||||||
| require_var HOTCRP_PID | ||||||
| require_var HOTCRP_TOKEN | ||||||
|
|
||||||
| require_command curl | ||||||
| require_command python3 | ||||||
| require_command zip | ||||||
|
|
||||||
| HOTCRP_SITE_URL="${HOTCRP_SITE_URL%/}" | ||||||
|
|
||||||
| case "$HOTCRP_PID" in | ||||||
| ''|*[!0-9]*) | ||||||
| die "HOTCRP_PID must be a numeric paper ID." | ||||||
| ;; | ||||||
| esac | ||||||
|
|
||||||
| [ -f "$HOTCRP_PDF" ] || die "missing PDF to upload: $HOTCRP_PDF" | ||||||
|
|
||||||
| workdir="$(mktemp -d)" | ||||||
| trap 'rm -rf "$workdir"' EXIT | ||||||
|
|
||||||
| cp "$HOTCRP_PDF" "$workdir/submission.pdf" | ||||||
|
|
||||||
| cat > "$workdir/data.json" <<EOF | ||||||
| { | ||||||
| "object": "paper", | ||||||
| "pid": $HOTCRP_PID, | ||||||
| "submission": { "content_file": "submission.pdf" } | ||||||
| } | ||||||
| EOF | ||||||
|
|
||||||
| ( | ||||||
| cd "$workdir" | ||||||
| zip -q upload.zip data.json submission.pdf | ||||||
| ) | ||||||
|
|
||||||
| curl -fsS \ | ||||||
| -H "Authorization: bearer $HOTCRP_TOKEN" \ | ||||||
| -H "Content-Type: application/zip" \ | ||||||
| --data-binary @"$workdir/upload.zip" \ | ||||||
| "$HOTCRP_SITE_URL/api/paper" \ | ||||||
| > hotcrp-response.json | ||||||
|
|
||||||
| python3 - <<'PY' | ||||||
| import json | ||||||
| import sys | ||||||
|
|
||||||
| with open("hotcrp-response.json") as f: | ||||||
| response = json.load(f) | ||||||
|
|
||||||
| print(json.dumps(response, indent=2)) | ||||||
|
|
||||||
| if not response.get("ok") or not response.get("valid", False): | ||||||
| sys.exit("HotCRP upload failed") | ||||||
| PY | ||||||
Uh oh!
There was an error while loading. Please reload this page.