Get docker container ID with the game code installed.
(self, branch_name: str | None = None)
| 184 | if cleanup: |
| 185 | for artifact in self.artifacts: |
| 186 | if artifact.exists(): |
| 187 | subprocess.run(f"rm -rf {artifact}", shell=True) |
| 188 | self.logger.info(f"🧼 Cleaned up {self.name} game") |
| 189 | |
| 190 | def log_round(self, round_num: int) -> Path: |
| 191 | return self.log_local / "rounds" / str(round_num) |
| 192 | |
| 193 | def get_environment(self, branch_name: str | None = None) -> DockerEnvironment: |
| 194 | """Get docker container ID with the game code installed.""" |
| 195 | self.build_image() |
| 196 | if not self._keep_containers: |
| 197 | run_args = ["--rm"] |
| 198 | else: |
| 199 | run_args = [] |
| 200 | environment = ClashDockerEnvironment( |
| 201 | image=self.image_name, |
| 202 | cwd=str(DIR_WORK), |
| 203 | env={ |
| 204 | "GITHUB_TOKEN": os.getenv("GITHUB_TOKEN", ""), |
| 205 | "PAGER": "cat", |
| 206 | "MANPAGER": "cat", |
| 207 | "LESS": "-R", |
| 208 | "PIP_PROGRESS_BAR": "off", |
| 209 | "TQDM_DISABLE": "1", |
| 210 | }, |
| 211 | container_timeout="10h", |
| 212 | logger=self.logger, |
| 213 | run_args=run_args, |
| 214 | ) |
| 215 | |
| 216 | branch_name = self.game_id if branch_name is None else branch_name |
| 217 | |
| 218 | # Logger setting will likely not take effect for initial container creation logs |
| 219 | environment.logger = get_logger("environment", emoji="🪴") |
| 220 | for cmd in [ |
| 221 | f"git branch {branch_name}", |
| 222 | f"git checkout {branch_name}", |
| 223 | 'git config --global user.email "player@codeclash.com"', |
| 224 | 'git config --global user.name "Player"', |
no test coverage detected