Skip to content

Commit 02ee54f

Browse files
committed
Add copilot setup steps
1 parent 1f6a6fe commit 02ee54f

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: "Copilot Setup Steps"
2+
3+
# This workflow pre-installs dependencies for GitHub Copilot coding agent
4+
# to enable faster and more reliable development in Copilot's ephemeral environment.
5+
# See: https://docs.github.com/en/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent
6+
7+
# Automatically run the setup steps when they are changed to allow for easy validation, and
8+
# allow manual testing through the repository's "Actions" tab
9+
on:
10+
workflow_dispatch:
11+
push:
12+
paths:
13+
- .github/workflows/copilot-setup-steps.yml
14+
pull_request:
15+
paths:
16+
- .github/workflows/copilot-setup-steps.yml
17+
18+
jobs:
19+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
20+
copilot-setup-steps:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 59
23+
24+
# Set the permissions to the lowest permissions possible needed for your steps.
25+
# Copilot will be given its own token for its operations.
26+
permissions:
27+
# 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.
28+
contents: read
29+
30+
# You can define any steps you want, and they will run before the agent starts.
31+
# If you do not check out your code, Copilot will do this for you.
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
36+
- name: Set up JDK for running Gradle
37+
uses: actions/setup-java@v4
38+
with:
39+
distribution: temurin
40+
java-version: 17
41+
42+
- name: Setup Gradle
43+
uses: gradle/actions/setup-gradle@v4
44+
45+
# Pre-download and cache Gradle dependencies to speed up builds
46+
- name: Download and cache Gradle dependencies
47+
run: |
48+
./gradlew dependencies --no-daemon
49+
./gradlew compileJava --no-daemon
50+
./gradlew compileTestJava --no-daemon
51+
52+
# Install Docker if needed for smoke tests (Docker-in-Docker for testing containers)
53+
- name: Set up Docker Buildx
54+
uses: docker/setup-buildx-action@v3
55+
56+
# Pre-build classes to warm up the environment
57+
- name: Pre-compile classes
58+
run: ./gradlew classes testClasses --no-daemon
59+
60+
# Cache Gradle wrapper and dependencies for faster subsequent runs
61+
- name: Cache Gradle wrapper
62+
uses: actions/cache@v4
63+
with:
64+
path: |
65+
~/.gradle/wrapper
66+
~/.gradle/caches
67+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
68+
restore-keys: |
69+
${{ runner.os }}-gradle-
70+
71+
# Install common tools that might be needed for development
72+
- name: Install development tools
73+
run: |
74+
# Install tools commonly used in Java development
75+
sudo apt-get update
76+
sudo apt-get install -y curl wget unzip
77+
78+
# Install additional tools that might be useful for the Application Insights agent
79+
sudo apt-get install -y jq # For JSON processing
80+
sudo apt-get install -y git # Git (usually already installed)
81+
82+
# Set environment variables that might be useful for the agent
83+
- name: Set environment variables
84+
run: |
85+
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
86+
echo "GRADLE_HOME=$GRADLE_HOME" >> $GITHUB_ENV
87+
echo "PATH=$PATH" >> $GITHUB_ENV
88+
89+
# Validate the setup by running a basic build check
90+
- name: Validate setup
91+
run: |
92+
echo "Java version:"
93+
java -version
94+
echo "Gradle version:"
95+
./gradlew --version
96+
echo "Available memory:"
97+
free -h
98+
echo "Disk space:"
99+
df -h
100+
echo ""
101+
echo "Setup complete! GitHub Copilot can now:"
102+
echo "- Build the project with './gradlew assemble'"
103+
echo "- Run tests with './gradlew test'"
104+
echo "- Run smoke tests with './gradlew :smoke-tests:apps:HttpClients:smokeTest'"
105+
echo "- Apply code formatting with './gradlew spotlessApply'"

0 commit comments

Comments
 (0)