Skip to content

Commit 9d1ee53

Browse files
committed
Fix challenge config for branches
1 parent 164f991 commit 9d1ee53

File tree

3 files changed

+70
-10
lines changed

3 files changed

+70
-10
lines changed

.github/workflows/validate-and-process.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push: {}
55
pull_request:
66
types: [opened, synchronize, reopened, edited]
7-
branches:
8-
- 'challenge'
97

108
permissions:
119
contents: read
@@ -32,23 +30,23 @@ jobs:
3230
echo "challenge_branch=$BRANCH" >> $GITHUB_OUTPUT
3331
3432
# Check if this is a challenge branch
35-
if [[ "$BRANCH" =~ ^challenge(-.*)?$ ]]; then
33+
if [[ "$BRANCH" =~ ^challenge(-[0-9]{4}-.*)?$ ]]; then
3634
echo "is_challenge_branch=true" >> $GITHUB_OUTPUT
3735
echo "✅ Valid challenge branch detected: $BRANCH"
3836
3937
# Extract branch suffix for versioning
40-
if [[ "$BRANCH" =~ ^challenge-(.+)$ ]]; then
38+
if [[ "$BRANCH" =~ ^challenge-([0-9]{4}-.+)$ ]]; then
4139
SUFFIX="${BASH_REMATCH[1]}"
4240
echo "branch_suffix=$SUFFIX" >> $GITHUB_OUTPUT
43-
echo "📋 Branch suffix: $SUFFIX"
41+
echo "📋 Branch version: $SUFFIX"
4442
else
4543
echo "branch_suffix=main" >> $GITHUB_OUTPUT
4644
echo "📋 Main challenge branch (no suffix)"
4745
fi
4846
else
4947
echo "is_challenge_branch=false" >> $GITHUB_OUTPUT
5048
echo "ℹ️ Not a challenge branch: $BRANCH"
51-
echo "⏭️ Challenge processing will be skipped"
49+
echo "⏭️ Challenge processing will be skipped (valid patterns: 'challenge' or 'challenge-YYYY-version')"
5250
fi
5351
5452
validate-host-config:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ If you are looking for a simple challenge configuration that you can replicate t
4848

4949
5. Create a branch with name `challenge` in the forked repository from the `master` branch.
5050
<span style="color:purple">Note: Only changes in `challenge` branch will be synchronized with challenge on EvalAI.</span>
51-
You may maintain multiple versions by using additional branches whose names start with `challenge-` (e.g. `challenge-2024`, `challenge-v2`).
52-
<span style="color:purple">Note: The CI pipeline only runs for branches that match the pattern `challenge` or `challenge-*`. Any other branch name will be ignored.</span>
51+
You may maintain multiple versions by using additional branches that follow the pattern `challenge-<year>-<version>` (e.g. `challenge-2024-v1`, `challenge-2024-beta`, `challenge-2025-final`).
52+
<span style="color:purple">Note: The CI pipeline only runs for branches that match the pattern `challenge` or `challenge-YYYY-version`. Any other branch name will be ignored.</span>
5353

5454
If you trigger the processing script manually and do **not** pass a branch argument, it will assume the branch name is `challenge` by default.
5555

github/challenge_processing_script.py

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import config
99
import urllib3
1010
from urllib.parse import urlparse
11+
import yaml
1112

1213
from config import *
1314
from utils import (
@@ -49,8 +50,8 @@
4950
branch_name = args.branch_name if args.branch_name else "challenge"
5051

5152
# Enforce branch naming convention
52-
if not re.match(r"^challenge(-.*)?$", branch_name):
53-
print("Error: Branch name must start with 'challenge' (e.g., 'challenge', 'challenge-2024').")
53+
if not re.match(r"^challenge(-\d{4}-.*)?$", branch_name):
54+
print("Error: Branch name must follow the pattern 'challenge' or 'challenge-<year>-<version>' (e.g., 'challenge', 'challenge-2024-v1', 'challenge-2024-beta').")
5455
sys.exit(1)
5556

5657
def is_localhost_url(url):
@@ -89,6 +90,58 @@ def configure_requests_for_localhost():
8990
print("INFO: SSL verification disabled for localhost development server")
9091

9192

93+
def modify_challenge_config_for_branch(branch_name):
94+
"""
95+
Modify the challenge configuration to make it unique for each branch.
96+
This ensures that different branches create separate challenges rather than updating the same one.
97+
98+
Arguments:
99+
branch_name {str}: The name of the git branch
100+
"""
101+
config_path = "challenge_config.yaml"
102+
103+
# Only modify if this is not the main challenge branch
104+
if branch_name == "challenge":
105+
print(f"📋 Using original challenge configuration (main branch)")
106+
return
107+
108+
print(f"📋 Modifying challenge configuration for branch: {branch_name}")
109+
110+
try:
111+
with open(config_path, 'r') as file:
112+
config_data = yaml.safe_load(file)
113+
114+
# Extract year and version from branch name (challenge-YYYY-version)
115+
branch_match = re.match(r"^challenge-(\d{4})-(.+)$", branch_name)
116+
if branch_match:
117+
year = branch_match.group(1)
118+
version = branch_match.group(2)
119+
suffix = f"{year}-{version}"
120+
else:
121+
# Fallback for any other format
122+
suffix = branch_name.replace("challenge-", "")
123+
124+
# Modify the challenge title to include branch name
125+
original_title = config_data.get('title', 'Challenge')
126+
config_data['title'] = f"{original_title} ({suffix})"
127+
128+
# Modify short description to indicate this is a branch version
129+
original_desc = config_data.get('short_description', '')
130+
config_data['short_description'] = f"{original_desc} [Version: {suffix}]"
131+
132+
# Write the modified config back
133+
with open(config_path, 'w') as file:
134+
yaml.dump(config_data, file, default_flow_style=False)
135+
136+
print(f"✅ Challenge configuration modified:")
137+
print(f" • Title: {config_data['title']}")
138+
print(f" • Description: {config_data['short_description']}")
139+
140+
except Exception as e:
141+
print(f"⚠️ Warning: Could not modify challenge configuration: {e}")
142+
print(f" This may cause issues with branch-specific challenges")
143+
144+
92145
if __name__ == "__main__":
93146

94147
configs = load_host_configs(HOST_CONFIG_FILE_PATH)
@@ -103,6 +156,9 @@ def configure_requests_for_localhost():
103156
# Update the global config path for zip file creation
104157
config.CHALLENGE_CONFIG_FILE_PATH = "challenge_config.yaml"
105158

159+
# Modify challenge configuration for branch-specific challenges
160+
modify_challenge_config_for_branch(branch_name)
161+
106162
# Check if we're using a localhost server and configure accordingly
107163
is_localhost = is_localhost_url(EVALAI_HOST_URL)
108164
runner_info = get_runner_info()
@@ -145,6 +201,12 @@ def configure_requests_for_localhost():
145201
if branch_name:
146202
data["BRANCH_NAME"] = branch_name
147203

204+
# Debug logging to show what data is being sent
205+
print(f"\n📋 Request data being sent to EvalAI:")
206+
print(f" • GITHUB_REPOSITORY: {data.get('GITHUB_REPOSITORY', 'Not set')}")
207+
print(f" • BRANCH_NAME: {data.get('BRANCH_NAME', 'Not set')}")
208+
print(f" • Challenge ZIP file: {CHALLENGE_ZIP_FILE_PATH}")
209+
148210
# Configure SSL verification based on whether we're using localhost
149211
verify_ssl = not is_localhost
150212
print(f"🔒 SSL Verification: {'Disabled (localhost)' if not verify_ssl else 'Enabled'}")

0 commit comments

Comments
 (0)