Skip to content

Commit a75e909

Browse files
committed
Merge branch 'trap_changes' into schema
1 parent 859eb36 commit a75e909

67 files changed

Lines changed: 5634 additions & 435 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release-engine.yml

Lines changed: 73 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -92,82 +92,83 @@ jobs:
9292
9393
- name: Upload specs
9494
run: gsutil -m rsync -a $OBJECT_ACL -r ./specs gs://$GCS_BUCKET/specs/${RELEASE_ARTIFACT_ID}/$RELEASE_VERSION
95-
# release-python:
96-
# name: Release Python
97-
# runs-on: ubuntu-latest
98-
# permissions:
99-
# contents: read
100-
# id-token: write
101-
102-
# steps:
103-
# - uses: conda-incubator/setup-miniconda@v3
104-
# with:
105-
# python-version: 3.12
106-
107-
# - name: Checkout branch
108-
# uses: actions/checkout@v3
109-
110-
# - name: Inject release version
111-
# run: |
112-
# release_version=${GITHUB_REF#refs/*/}
113-
# release_version=${release_version#engine.}
114-
# echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
115-
# echo "The release version is $release_version"
116-
117-
# - name: Authenticate to Google Cloud Platform
118-
# uses: google-github-actions/auth@v1
119-
# with:
120-
# create_credentials_file: true
121-
# workload_identity_provider: projects/830784087321/locations/global/workloadIdentityPools/releases/providers/github-workflow
122-
# service_account: releases-agent@mitbattlecode.iam.gserviceaccount.com
123-
124-
# - name: Set up Google Cloud SDK
125-
# uses: 'google-github-actions/setup-gcloud@v1'
126-
127-
# - name: Clone private maps
128-
# if: ${{ env.IS_PUBLIC != 'YES' }}
129-
# uses: actions/checkout@v3
130-
# with:
131-
# repository: battlecode/private-maps
132-
# token: ${{ secrets.CI_REPOSITORY_CLONE_PAT }}
133-
# path: private-maps
95+
release-python:
96+
name: Release Python
97+
runs-on: ubuntu-latest
98+
permissions:
99+
contents: read
100+
id-token: write
101+
102+
steps:
103+
- uses: conda-incubator/setup-miniconda@v3
104+
with:
105+
python-version: 3.12
106+
107+
- name: Checkout branch
108+
uses: actions/checkout@v3
109+
110+
- name: Inject release version
111+
run: |
112+
release_version=${GITHUB_REF#refs/*/}
113+
release_version=${release_version#engine.}
114+
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
115+
echo "The release version is $release_version"
116+
117+
- name: Authenticate to Google Cloud Platform
118+
uses: google-github-actions/auth@v1
119+
with:
120+
create_credentials_file: true
121+
workload_identity_provider: projects/830784087321/locations/global/workloadIdentityPools/releases/providers/github-workflow
122+
service_account: releases-agent@mitbattlecode.iam.gserviceaccount.com
123+
124+
- name: Set up Google Cloud SDK
125+
uses: 'google-github-actions/setup-gcloud@v1'
126+
127+
- name: Clone private maps
128+
if: ${{ env.IS_PUBLIC != 'YES' }}
129+
uses: actions/checkout@v3
130+
with:
131+
repository: battlecode/private-maps
132+
token: ${{ secrets.CI_REPOSITORY_CLONE_PAT }}
133+
path: private-maps
134134

135-
# - name: Inject private maps
136-
# if: ${{ env.IS_PUBLIC != 'YES' }}
137-
# run: |
138-
# source="private-maps/$RELEASE_ARTIFACT_ID"
139-
# dest="$RELEASE_ARTIFACT_ID/maps"
140-
# if [ -d "$source" ]; then
141-
# cp -r -i "$source/." "$dest/" < /dev/null &> private-maps-copy-log
142-
# if [ -s "private-maps-copy-log" ]; then
143-
# echo "FAILED! Public and private maps should not intersect."
144-
# cat private-maps-copy-log
145-
# exit 1
146-
# fi
147-
# fi
135+
- name: Inject private maps
136+
if: ${{ env.IS_PUBLIC != 'YES' }}
137+
run: |
138+
source="private-maps/$RELEASE_ARTIFACT_ID"
139+
dest="engine/src/main/battlecode/world/resources"
140+
if [ -d "$source" ]; then
141+
cp -r -i "$source/." "$dest/" < /dev/null &> private-maps-copy-log
142+
if [ -s "private-maps-copy-log" ]; then
143+
echo "FAILED! Public and private maps should not intersect."
144+
cat private-maps-copy-log
145+
exit 1
146+
fi
147+
fi
148148
149-
# - name: Build python package
150-
# shell: bash -el {0} # Make sure conda is activated
151-
# run: |
152-
# conda info
153-
# python --version
154-
# pip install --upgrade build
155-
# SETUPTOOLS_SCM_PRETEND_VERSION=${RELEASE_VERSION} python -m build
156-
157-
# - name: Determine access control
158-
# run: |
159-
# [[ "$IS_PUBLIC" = "YES" ]] && acl="public-read" || acl="project-private"
160-
# echo "OBJECT_ACL=$acl" >> $GITHUB_ENV
161-
# echo "Objects will be uploaded with ACL $acl"
162-
163-
# - name: Upload python package to remote repository
164-
# run: |
165-
# mv *.tar.gz battlecode.tar.gz
166-
# gsutil -m cp -a $OBJECT_ACL battlecode.tar.gz gs://$GCS_BUCKET/maven/org/battlecode/${RELEASE_ARTIFACT_ID}-python/${RELEASE_VERSION}/
167-
# working-directory: ./dist
149+
- name: Build python package
150+
shell: bash -el {0} # Make sure conda is activated
151+
run: |
152+
conda info
153+
python --version
154+
pip install --upgrade build
155+
SETUPTOOLS_SCM_PRETEND_VERSION=${RELEASE_VERSION} python -m build
156+
working-directory: engine/src/crossplay_python
157+
158+
- name: Determine access control
159+
run: |
160+
[[ "$IS_PUBLIC" = "YES" ]] && acl="public-read" || acl="project-private"
161+
echo "OBJECT_ACL=$acl" >> $GITHUB_ENV
162+
echo "Objects will be uploaded with ACL $acl"
163+
164+
- name: Upload python package to remote repository
165+
run: |
166+
mv *.tar.gz battlecode.tar.gz
167+
gsutil -m cp -a $OBJECT_ACL battlecode.tar.gz gs://$GCS_BUCKET/maven/org/battlecode/${RELEASE_ARTIFACT_ID}-python/${RELEASE_VERSION}/
168+
working-directory: engine/src/crossplay_python/dist
168169

169170
# TODO: docs?
170-
#- name: Upload javadocs
171+
# - name: Upload javadocs
171172
# run: |
172173
# unzip -d ${{ runner.temp }}/javadoc $HOME/.m2/repository/org/battlecode/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION/*-javadoc.jar
173174
# gsutil -m rsync -a $OBJECT_ACL -r ${{ runner.temp }}/javadoc gs://$GCS_BUCKET/javadoc/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Note, Competitors
66
This is the development repo! You most likely won't need anything in here; do not clone this.
7-
Instead, follow the instructions [here](https://play.battlecode.org/bc26java/quick_start) to get started.
7+
Instead, follow the instructions [here](https://play.battlecode.org/bc26/quick_start) to get started.
88

99
## Repository Structure
1010

build.gradle

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ dependencies {
4040
bots project(":example-bots")
4141
}
4242

43+
task installPythonPackage(type: Exec) {
44+
if (project.findProperty('forceInstallPythonPackage') ?: false) {
45+
commandLine 'python', '-m', 'pip', 'install', '-e', 'engine/src/crossplay_python'
46+
} else {
47+
commandLine 'python', '-c', "import importlib.util,subprocess,sys; pkg='battlecode26'; importlib.util.find_spec(pkg) or subprocess.check_call([sys.executable,'-m','pip','install','-e',pkg])"
48+
}
49+
}
50+
4351
def serverJar = configurations.engine.singleFile
4452

4553
task buildMap(type: JavaExec, dependsOn: [':engine:build']) {
@@ -78,6 +86,8 @@ task headless(type: JavaExec, dependsOn: [':engine:build', ':example-bots:build'
7886
'-Dbc.engine.show-indicators=' + (project.findProperty('showIndicators') ?: 'true'),
7987
'-Dbc.game.team-a=' + project.property('teamA'),
8088
'-Dbc.game.team-b=' + project.property('teamB'),
89+
'-Dbc.game.team-a.language=' + (project.findProperty('languageA') ?: 'java'),
90+
'-Dbc.game.team-b.language=' + (project.findProperty('languageB') ?: 'java'),
8191
'-Dbc.game.team-a.url=' + (project.findProperty('classLocationA') ?: defaultClassLocation),
8292
'-Dbc.game.team-b.url=' + (project.findProperty('classLocationB') ?: defaultClassLocation),
8393
'-Dbc.game.team-a.package=' + (project.findProperty('packageNameA') ?: project.property('teamA')),
@@ -89,10 +99,25 @@ task headless(type: JavaExec, dependsOn: [':engine:build', ':example-bots:build'
8999
]
90100
}
91101

102+
task crossPlayPy(type: Exec, dependsOn: ['installPythonPackage']) {
103+
commandLine 'python', '-m', 'battlecode26',
104+
'--teamA', (project.findProperty('languageA') == 'java' ? '/' : project.property('teamA')),
105+
'--teamB', (project.findProperty('languageB') == 'java' ? '/' : project.property('teamB')),
106+
'--dirA', 'example-bots/src/crossplay_python',
107+
'--dirB', 'example-bots/src/crossplay_python',
108+
'--new-process'
109+
}
110+
92111
// keep the client happy because it references this step
93112
task unpackClient() {}
94113

95-
task run(dependsOn: ['headless', 'unpackClient']) {}
114+
task run(dependsOn: ['unpackClient', 'headless']) {}
115+
116+
if (project.hasProperty('languageA') && project.property('languageA') == 'python' ||
117+
project.hasProperty('languageB') && project.property('languageB') == 'python') {
118+
run.dependsOn crossPlayPy
119+
headless.mustRunAfter crossPlayPy
120+
}
96121

97122
task runClient {
98123
doLast {

engine/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ dependencies {
5858
// There are no valid released versions on Maven Central or Sonatype.
5959
// If you need JSI, download jsi-1.0.jar manually and use:
6060
[group: 'net.sf.trove4j', name: 'trove4j', version: '2.1.0'],
61+
62+
[group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.15.2'],
6163
)
6264
// implementation files('lib/jsi-1.0.jar')
6365

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/_version.py
2+
*.egg-info/
3+
dist/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .classes import *
2+
from .wrappers import *

0 commit comments

Comments
 (0)