Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .codesignal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ release layout they depend on.

- `setup.sh` installs the release for the channel in `~/.cosmo-agents` (outside the workspace)
and starts the simulation; it returns once the server on :3000 answers. Production runs the
latest release, staging (`APP_ENVIRONMENT=staging`) the newest build.
latest release, staging (`APP_ENVIRONMENT=staging`) the newest build. When the release's
download link fails, it fetches the same file through GitHub's API.
- `run_solution.sh` prints the simulation's report (main README, "Evaluation output").

The workspace holds only the task's own files, so the editor shows the task's code and what the
Expand Down
12 changes: 11 additions & 1 deletion .codesignal/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@ APP="$HOME/.cosmo-agents/app"

# Production runs the latest release; staging the newest build (README, "Releases").
URL="https://github.com/CodeSignal/learn_cosmo-agents/releases/latest/download/release.tar.gz"
API="https://api.github.com/repos/CodeSignal/learn_cosmo-agents/releases/latest"
if [ "${APP_ENVIRONMENT:-}" = "staging" ]; then
URL="https://github.com/CodeSignal/learn_cosmo-agents/releases/download/prerelease/release.tar.gz"
API="https://api.github.com/repos/CodeSignal/learn_cosmo-agents/releases/tags/prerelease"
fi

rm -rf "$APP" && mkdir -p "$APP"
curl -fsSL --retry 3 "$URL" | tar -xz -C "$APP"
# GitHub's release download links can fail for anonymous clients while its API still serves the file.
TARBALL="$HOME/.cosmo-agents/release.tar.gz"
if ! curl -fsSL --retry 3 -o "$TARBALL" "$URL"; then
ASSET="$(curl -fsSL --retry 3 "$API" | grep -o '"url": *"https://api.github.com/[^"]*/releases/assets/[0-9]*"' | head -1 | cut -d'"' -f4)"
[ -n "$ASSET" ] || { echo "setup: no release asset found at $API" >&2; exit 1; }
curl -fsSL --retry 3 -H "Accept: application/octet-stream" -o "$TARBALL" "$ASSET"
fi
tar -xzf "$TARBALL" -C "$APP"
rm -f "$TARBALL"
sh "$APP/scripts/session-setup.sh" /usercode/FILESYSTEM/.codesignal/agent-sim.json
Loading