Codex (Cloud) environment for build and run unit tests?

What environment does Codex Cloud (May 2025) support for building and running unit tests?

I see that it does not have dotnet installed so it can’t build and verify that the code compiles.

I see a similar issue too with my tests. But in my case, the container can’t even connect to the registry and install the necessary dependencies for the tooling needed to run my tests in a Python based repo.

If you go into Environments, choose your repo, click Edit, then expand the Advanced panel you can see more details about this. The code is run in a Docker container using an image based on Ubuntu 24.04, the details of which can be found on Github here.

The dropdown notes that support for custom Docker images is coming. For now, you may be able to install additional tools using the “Setup script” field as it is run while the container still has internet access. apt is installed and available, but I have not personally tried to install anything with it yet so I’m not sure what the limits are.

2 Likes

For me the following script works (created by ChatGPT) :

#!/bin/bash
set -e

# Project name (adjust if needed)
PROJECT_NAME=someprojectname

# .NET version (here 8.0, adjust if needed)
DOTNET_VERSION=8.0

# Add Microsoft package source
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

# Update package sources and transport layer
sudo apt-get update
sudo apt-get install -y apt-transport-https

# Install .NET SDK
sudo apt-get update
sudo apt-get install -y dotnet-sdk-$DOTNET_VERSION

# Test: display version
dotnet --version

# --- IMPORTANT: Restore ALL packages while Internet is available! ---
dotnet restore $PROJECT_NAME.sln

# (Optional: Build and test immediately while Internet is available)
dotnet build $PROJECT_NAME.sln --no-restore
dotnet test $PROJECT_NAME.sln --no-build --no-restore

echo "Setup and pre-restore completed. Container is ready for offline use."

You the man! I commented out the PROJECT_NAME and restore/build/test portions, since I don’t necessarily need that in every CODEX environment.