Unverified Commit e40a8e06 authored by Bruno Borges's avatar Bruno Borges Committed by GitHub
Browse files

Add an option to disable Java problem matchers (#1133)

* Add problem matcher opt-out

Co-authored-by: default avatarCopilot App <[email protected]>

Copilot-Session: 38eb7886-7ea3-4e4d-8d5f-e3f975135053

* Potential fix for pull request finding

Co-authored-by: default avatarCopilot Autofix powered by AI <[email protected]>

* Potential fix for pull request finding

Co-authored-by: default avatarCopilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: default avatarCopilot Autofix powered by AI <[email protected]>
parent 6e2e32e7
Loading
Loading
Loading
Loading
+3 −1
Changes for README.md: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ For more details, see the full release notes on the [releases page](https://git

  - `set-default`: Set to `false` to install a JDK without making it the default. When `false`, `JAVA_HOME` and `PATH` are not updated, but `JAVA_HOME_<major>_<arch>` is still set so the JDK remains discoverable. Default value: `true`. See [Installing JDK without setting as default](docs/advanced-usage.md#Installing-JDK-without-setting-as-default) for more details.

  - `problem-matcher`: Set to `false` to disable Java problem matcher annotations (compiler diagnostics and uncaught exceptions). Default value: `true`. See [Java problem matcher](docs/advanced-usage.md#java-problem-matcher-compiler-annotations) for details and annotation limits.

  - `verify-signature`: Verifies downloaded Java package signatures when supported by the selected distribution. Currently supported for `temurin` and `microsoft`. If set to `true` for unsupported distributions, the action fails.

  - `verify-signature-public-key`: ASCII-armored GPG public key used to verify the downloaded package signature. Overrides the default bundled key for the selected distribution.
@@ -208,7 +210,7 @@ steps:
    cache: 'maven'
    cache-dependency-path: 'sub-project/pom.xml' # optional
- name: Build with Maven
  run: mvn -B package --file pom.xml
  run: mvn package --file pom.xml
```

> [!NOTE]
+44
Changes for __tests__/problem-matcher.test.ts: 44 added lines, 0 removed lines.
Original line number Diff line number Diff line
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals';

const mockGetInput = jest.fn<(...args: any[]) => any>();
const mockInfo = jest.fn<(...args: any[]) => any>();
const mockDebug = jest.fn<(...args: any[]) => any>();

jest.unstable_mockModule('@actions/core', () => ({
  getInput: mockGetInput,
  info: mockInfo,
  debug: mockDebug,
  warning: jest.fn(),
  setSecret: jest.fn()
}));

const {configureProblemMatcher} = await import('../src/problem-matcher.js');
const {INPUT_PROBLEM_MATCHER} = await import('../src/constants.js');

describe('configureProblemMatcher', () => {
  let inputs: Record<string, string>;

  beforeEach(() => {
    inputs = {};
    mockGetInput.mockImplementation((name: string) => inputs[name] ?? '');
  });

  afterEach(() => {
    jest.resetAllMocks();
  });

  it('registers the Java problem matcher by default', () => {
    configureProblemMatcher('/matchers/java.json');

    expect(mockInfo).toHaveBeenCalledWith('##[add-matcher]/matchers/java.json');
  });

  it('does not register the Java problem matcher when disabled', () => {
    inputs[INPUT_PROBLEM_MATCHER] = 'false';

    configureProblemMatcher('/matchers/java.json');

    expect(mockInfo).not.toHaveBeenCalled();
    expect(mockDebug).toHaveBeenCalledWith('Java problem matcher is disabled');
  });
});
+4
Changes for action.yml: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ inputs:
    description: 'Whether Maven should print artifact download/transfer progress to the build log. When "false" (default) the action sets "-ntp" (--no-transfer-progress) in MAVEN_ARGS to produce cleaner logs. Set to "true" to keep the progress output. Has no effect on non-Maven builds.'
    required: false
    default: false
  problem-matcher:
    description: 'Whether to register the Java problem matcher (compiler errors/warnings and uncaught exceptions). Set to "false" to disable annotations.'
    required: false
    default: true
outputs:
  distribution:
    description: 'Distribution of Java that has been installed'
+1
Changes for dist/cleanup/index.js: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -95924,6 +95924,7 @@ const INPUT_JDK_FILE = 'jdk-file';
const INPUT_JDK_FILE_DEPRECATED = 'jdkFile';
const INPUT_CHECK_LATEST = 'check-latest';
const INPUT_SET_DEFAULT = 'set-default';
const INPUT_PROBLEM_MATCHER = 'problem-matcher';
const INPUT_VERIFY_SIGNATURE = 'verify-signature';
const INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
const INPUT_SERVER_ID = 'server-id';
+16 −1
Changes for dist/setup/index.js: 16 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -73283,6 +73283,7 @@ const INPUT_JDK_FILE = 'jdk-file';
const INPUT_JDK_FILE_DEPRECATED = 'jdkFile';
const INPUT_CHECK_LATEST = 'check-latest';
const INPUT_SET_DEFAULT = 'set-default';
const INPUT_PROBLEM_MATCHER = 'problem-matcher';
const INPUT_VERIFY_SIGNATURE = 'verify-signature';
const INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
const INPUT_SERVER_ID = 'server-id';
@@ -133988,6 +133989,19 @@ function configureMavenArgs() {
        `Set '${INPUT_SHOW_DOWNLOAD_PROGRESS}: true' to keep the download progress output.`);
}
;// CONCATENATED MODULE: ./src/problem-matcher.ts
function configureProblemMatcher(matcherPath) {
    const problemMatcherEnabled = util_getBooleanInput(INPUT_PROBLEM_MATCHER, true);
    if (!problemMatcherEnabled) {
        core_debug('Java problem matcher is disabled');
        return;
    }
    info(`##[add-matcher]${matcherPath}`);
}
;// CONCATENATED MODULE: ./src/setup-java.ts
@@ -134000,6 +134014,7 @@ function configureMavenArgs() {
async function run() {
    try {
        const versions = getMultilineInput(INPUT_JAVA_VERSION);
@@ -134073,7 +134088,7 @@ async function run() {
        }
        endGroup();
        const matchersPath = external_path_.join(external_path_.dirname((0,external_url_.fileURLToPath)(import.meta.url)), '..', '..', '.github');
        info(`##[add-matcher]${external_path_.join(matchersPath, 'java.json')}`);
        configureProblemMatcher(external_path_.join(matchersPath, 'java.json'));
        await configureAuthentication();
        configureMavenArgs();
        if (cache && isCacheFeatureAvailable()) {
Loading