Skip to content

Commit d1b7091

Browse files
committed
Skip CLI npm ci when tests are skipped
Address review comment on PR #137 (discussion_r3165129538): the install-nodejs-cli-dependencies execution previously ran on every invocation of generate-test-resources because it was only guarded by ${skip.test.harness}. That made non-test builds (e.g. mvn package -DskipTests, mvn deploy -Dmaven.test.skip=true) require npm and network access unnecessarily. Introduce a new ${skip.cli.install} property that defaults to ${skip.test.harness} but is forced to true when -DskipTests=true or -Dmaven.test.skip=true is set, via two auto-activated profiles. Wire the install-nodejs-cli-dependencies execution's <skip> to this new property.
1 parent 1461106 commit d1b7091

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

pom.xml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@
6262
<copilot.cli.path>${copilot.sdk.clone.dir}/nodejs/node_modules/@github/copilot/index.js</copilot.cli.path>
6363
<!-- Set to true (via -Pskip-test-harness) to skip git-clone + npm install of test harness -->
6464
<skip.test.harness>false</skip.test.harness>
65+
<!--
66+
Whether to skip the install-nodejs-cli-dependencies execution
67+
(npm ci of the @github/copilot CLI). Defaults to ${skip.test.harness}
68+
so it tracks the rest of the test-harness setup, but is also
69+
forced to true when Maven tests are skipped (-DskipTests or
70+
-Dmaven.test.skip) via the skip-cli-install-when-tests-skipped
71+
and skip-cli-install-when-maven-test-skip profiles below, so that
72+
non-test builds (e.g. package/deploy with tests skipped) do not
73+
require npm or network access.
74+
-->
75+
<skip.cli.install>${skip.test.harness}</skip.cli.install>
6576
<!-- Extra JVM args for Surefire; overridden by the jdk21+ profile -->
6677
<surefire.jvm.args />
6778
<!--
@@ -292,7 +303,7 @@
292303
<goal>exec</goal>
293304
</goals>
294305
<configuration>
295-
<skip>${skip.test.harness}</skip>
306+
<skip>${skip.cli.install}</skip>
296307
<executable>npm</executable>
297308
<workingDirectory>${copilot.sdk.clone.dir}/nodejs</workingDirectory>
298309
<arguments>
@@ -657,6 +668,39 @@
657668
<skip.test.harness>true</skip.test.harness>
658669
</properties>
659670
</profile>
671+
<!--
672+
Skip the install-nodejs-cli-dependencies (npm ci) execution when
673+
tests are skipped via -DskipTests, so non-test builds do not
674+
require npm or network access. Activates automatically; no manual
675+
-P needed.
676+
-->
677+
<profile>
678+
<id>skip-cli-install-when-tests-skipped</id>
679+
<activation>
680+
<property>
681+
<name>skipTests</name>
682+
<value>true</value>
683+
</property>
684+
</activation>
685+
<properties>
686+
<skip.cli.install>true</skip.cli.install>
687+
</properties>
688+
</profile>
689+
<!--
690+
Same as above, but for -Dmaven.test.skip=true.
691+
-->
692+
<profile>
693+
<id>skip-cli-install-when-maven-test-skip</id>
694+
<activation>
695+
<property>
696+
<name>maven.test.skip</name>
697+
<value>true</value>
698+
</property>
699+
</activation>
700+
<properties>
701+
<skip.cli.install>true</skip.cli.install>
702+
</properties>
703+
</profile>
660704
<!-- Debug profile for FINE logging during tests -->
661705
<profile>
662706
<id>debug</id>

0 commit comments

Comments
 (0)