-
Notifications
You must be signed in to change notification settings - Fork 1.2k
161 lines (128 loc) · 8.35 KB
/
java-smoke-test.yml
File metadata and controls
161 lines (128 loc) · 8.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: "Java smoke test"
on:
workflow_dispatch:
workflow_call:
secrets:
COPILOT_GITHUB_TOKEN:
required: true
permissions:
contents: read
jobs:
smoke-test-jdk17:
name: Build SDK and run smoke test (JDK 17)
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
defaults:
run:
shell: bash
working-directory: ./java
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "17"
distribution: "microsoft"
cache: "maven"
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v6
with:
node-version: 22
- name: Read pinned @github/copilot version from pom.xml
id: cli-version
run: |
PROP="readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync"
VERSION=$(sed -n "s|.*<${PROP}>\(.*\)</${PROP}>.*|\1|p" pom.xml | head -n 1 | tr -d '[:space:]')
if [[ -z "$VERSION" || "$VERSION" == "PRIMER_TO_REPLACE" ]]; then
echo "::error::Could not read pinned @github/copilot version from pom.xml property <${PROP}>" >&2
exit 1
fi
echo "Pinned @github/copilot version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Install Copilot CLI globally (pinned to pom.xml version)
run: npm install -g "@github/copilot@${{ steps.cli-version.outputs.version }}"
- name: Verify CLI works
run: copilot --version
- name: Build SDK and install to local repo
run: mvn -DskipTests -Pskip-test-harness clean install
- name: Create and run smoke test via Copilot CLI
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
run: |
cat > /tmp/smoke-test-prompt.txt << 'PROMPT_EOF'
You are running inside the copilot-sdk monorepo, in the java/ subdirectory.
The SDK has already been built and installed into the local Maven repository.
JDK 17 and Maven are already installed and on PATH.
Execute the prompt at `src/test/prompts/PROMPT-smoke-test.md` with the following critical overrides:
**Critical override — disable SNAPSHOT updates (but allow downloads):** The goal of this workflow is to validate the SDK SNAPSHOT that was just built and installed locally, not any newer SNAPSHOT that might exist in a remote repository. To ensure Maven does not download a newer timestamped SNAPSHOT of the SDK while still allowing it to download any missing plugins or dependencies, you must run the smoke-test Maven build without `-U` and with `--no-snapshot-updates`, so that it uses the locally installed SDK artifact. Use `mvn --no-snapshot-updates clean package` instead of `mvn -U clean package` or `mvn -o clean package`.
**Critical override — do NOT run the jar:** Stop after the `mvn --no-snapshot-updates clean package` build succeeds. Do NOT execute Step 4 (java -jar) or Step 5 (verify exit code) from the prompt. The workflow will run the jar in a separate deterministic step to guarantee the exit code propagates correctly.
Follow steps 1-3 only: create the `smoke-test/` directory, create `pom.xml` and the Java source file exactly as specified, and build with `mvn --no-snapshot-updates clean package` (no SNAPSHOT updates and without `-U`).
If any step fails, exit with a non-zero exit code. Do not silently fix errors.
PROMPT_EOF
copilot --yolo --prompt "$(cat /tmp/smoke-test-prompt.txt)"
- name: Run smoke test jar
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
run: |
cd smoke-test
java -jar ./target/copilot-sdk-smoketest-1.0-SNAPSHOT.jar
echo "Smoke test passed (exit code 0)"
smoke-test-java25:
name: Build SDK and run smoke test (JDK 25)
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
defaults:
run:
shell: bash
working-directory: ./java
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up JDK 25
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "25"
distribution: "microsoft"
cache: "maven"
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v6
with:
node-version: 22
- name: Read pinned @github/copilot version from pom.xml
id: cli-version
run: |
PROP="readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync"
VERSION=$(sed -n "s|.*<${PROP}>\(.*\)</${PROP}>.*|\1|p" pom.xml | head -n 1 | tr -d '[:space:]')
if [[ -z "$VERSION" || "$VERSION" == "PRIMER_TO_REPLACE" ]]; then
echo "::error::Could not read pinned @github/copilot version from pom.xml property <${PROP}>" >&2
exit 1
fi
echo "Pinned @github/copilot version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Install Copilot CLI globally (pinned to pom.xml version)
run: npm install -g "@github/copilot@${{ steps.cli-version.outputs.version }}"
- name: Verify CLI works
run: copilot --version
- name: Build SDK and install to local repo
run: mvn -DskipTests -Pskip-test-harness clean install
- name: Create and run smoke test via Copilot CLI
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
run: |
cat > /tmp/smoke-test-prompt.txt << 'PROMPT_EOF'
You are running inside the copilot-sdk monorepo, in the java/ subdirectory.
The SDK has already been built and installed into the local Maven repository.
JDK 25 and Maven are already installed and on PATH.
Execute the prompt at `src/test/prompts/PROMPT-smoke-test.md` with the following critical overrides:
**Critical override — disable SNAPSHOT updates (but allow downloads):** The goal of this workflow is to validate the SDK SNAPSHOT that was just built and installed locally, not any newer SNAPSHOT that might exist in a remote repository. To ensure Maven does not download a newer timestamped SNAPSHOT of the SDK while still allowing it to download any missing plugins or dependencies, you must run the smoke-test Maven build without `-U` and with `--no-snapshot-updates`, so that it uses the locally installed SDK artifact. Use `mvn --no-snapshot-updates clean package` instead of `mvn -U clean package` or `mvn -o clean package`.
**Critical override — do NOT run the jar:** Stop after the `mvn --no-snapshot-updates clean package` build succeeds. Do NOT execute Step 4 (java -jar) or Step 5 (verify exit code) from the prompt. The workflow will run the jar in a separate deterministic step to guarantee the exit code propagates correctly.
**Critical override — enable Virtual Threads for JDK 25:** After creating the Java source file from the README "Quick Start" section but BEFORE building, you must modify the source file to enable virtual thread support. The Quick Start code contains inline comments that start with `// JDK 25+:` — these are instructions. Find every such comment and follow what it says (comment out lines it says to comment out, uncomment lines it says to uncomment). Add any imports required by the newly uncommented code (e.g. `java.util.concurrent.Executors`).
Also set `maven.compiler.source` and `maven.compiler.target` to `25` in the `pom.xml`.
Follow steps 1-3 only: create the `smoke-test/` directory, create `pom.xml` and the Java source file exactly as specified, apply the JDK 25 virtual thread modifications described above, and build with `mvn --no-snapshot-updates clean package` (no SNAPSHOT updates and without `-U`).
If any step fails, exit with a non-zero exit code. Do not silently fix errors.
PROMPT_EOF
copilot --yolo --prompt "$(cat /tmp/smoke-test-prompt.txt)"
- name: Run smoke test jar
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
run: |
cd smoke-test
java -jar ./target/copilot-sdk-smoketest-1.0-SNAPSHOT.jar
echo "Smoke test passed (exit code 0)"