Skip to content

Add copilot setup steps #1

Add copilot setup steps

Add copilot setup steps #1

name: "Copilot Setup Steps"
# This workflow pre-installs dependencies for GitHub Copilot coding agent
# to enable faster and more reliable development in Copilot's ephemeral environment.
# See: https://docs.github.com/en/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent
# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest
timeout-minutes: 59
# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read
# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK for running Gradle
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# Pre-download and cache Gradle dependencies to speed up builds
- name: Download and cache Gradle dependencies
run: |
./gradlew dependencies --no-daemon
./gradlew compileJava --no-daemon
./gradlew compileTestJava --no-daemon
# Install Docker if needed for smoke tests (Docker-in-Docker for testing containers)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Pre-build classes to warm up the environment
- name: Pre-compile classes
run: ./gradlew classes testClasses --no-daemon
# Cache Gradle wrapper and dependencies for faster subsequent runs
- name: Cache Gradle wrapper
uses: actions/cache@v4
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Install common tools that might be needed for development
- name: Install development tools
run: |
# Install tools commonly used in Java development
sudo apt-get update
sudo apt-get install -y curl wget unzip
# Install additional tools that might be useful for the Application Insights agent
sudo apt-get install -y jq # For JSON processing
sudo apt-get install -y git # Git (usually already installed)
# Set environment variables that might be useful for the agent
- name: Set environment variables
run: |
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "GRADLE_HOME=$GRADLE_HOME" >> $GITHUB_ENV
echo "PATH=$PATH" >> $GITHUB_ENV
# Validate the setup by running a basic build check
- name: Validate setup
run: |
echo "Java version:"
java -version
echo "Gradle version:"
./gradlew --version
echo "Available memory:"
free -h
echo "Disk space:"
df -h
echo ""
echo "Setup complete! GitHub Copilot can now:"
echo "- Build the project with './gradlew assemble'"
echo "- Run tests with './gradlew test'"
echo "- Run smoke tests with './gradlew :smoke-tests:apps:HttpClients:smokeTest'"
echo "- Apply code formatting with './gradlew spotlessApply'"