Skip to content

Commit

Permalink
Merge branch 'master' into ide.remote
Browse files Browse the repository at this point in the history
  • Loading branch information
jlahoda committed Dec 28, 2024
2 parents ea0c584 + aec7ccd commit 324336a
Show file tree
Hide file tree
Showing 2,157 changed files with 34,709 additions and 63,374 deletions.
2 changes: 2 additions & 0 deletions .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ github:
wiki: false
issues: true
projects: true
dependabot_alerts: false
dependabot_updates: false
enabled_merge_buttons:
squash: false
merge: true
Expand Down
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@

# Define some file types explicitly as being binary.
*.jar binary

# Define rules for files in specific paths, such as test data,
# for line endings, binary types etc.
java/java.hints/test/unit/data/goldenfiles/** text eol=lf
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/netbeans_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ body:
Latest releases are always available from https://netbeans.apache.org/download/
multiple: false
options:
- "Apache NetBeans 23"
# - "Apache NetBeans 24 release candidate"
- "Apache NetBeans 24"
# - "Apache NetBeans 25 release candidate"
- "Apache NetBeans latest daily build"
validations:
required: true
Expand Down Expand Up @@ -73,6 +73,7 @@ body:
multiple: false
options:
- "No / Don't know"
- "Apache NetBeans 24"
- "Apache NetBeans 23"
- "Apache NetBeans 22"
- "Apache NetBeans 21"
Expand Down
162 changes: 162 additions & 0 deletions .github/scripts/CommitHeaderChecker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpClient.Redirect;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.util.List;

import static java.util.stream.Gatherers.fold;
import static java.util.stream.Gatherers.scan;
import static java.util.stream.Gatherers.windowSliding;

record Commit(int index, String from, String date, String subject, String blank) {}
record Result(int total, boolean green) {}

// checks commit headers for valid author, email and commit msg formatting
// its main purpose is to prevent common merge mistakes

// Java 23+, may require preview flag
// java CommitHeaderChecker.java https://github.com/apache/netbeans/pull/${{ github.event.pull_request.number }}

// green tests:
// java --enable-preview CommitHeaderChecker.java https://github.com/apache/netbeans/pull/66
// java --enable-preview CommitHeaderChecker.java https://github.com/apache/netbeans/pull/7641
// java --enable-preview CommitHeaderChecker.java https://github.com/apache/netbeans/pull/4138
// java --enable-preview CommitHeaderChecker.java https://github.com/apache/netbeans/pull/4692

// red tests:
// java --enable-preview CommitHeaderChecker.java https://github.com/apache/netbeans/pull/7776
// java --enable-preview CommitHeaderChecker.java https://github.com/apache/netbeans/pull/5567

void main(String[] args) throws IOException, InterruptedException {

if (args.length != 1 || !args[0].startsWith("https://github.com/")) {
throw new IllegalArgumentException("PR URL expected");
}

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(args[0]+".patch"))
.timeout(Duration.ofSeconds(10))
.build();

println("checking PR patch file...");
Result result;
try (HttpClient client = HttpClient.newBuilder()
.followRedirects(Redirect.NORMAL).build()) {

result = client.send(request, BodyHandlers.ofLines()).body()
// 5 line window, From/Date/Subject and extra line for blank line / overflow check
// "From" can be two lines if the name is very long
.gather(windowSliding(5))
.filter(w -> isCommitHeader(w))
.gather(scan(
() -> new Commit(-1, "", "", "", ""),
(c, w) -> createCommit(c.index+1, w)))
.peek(System.out::println)
.gather(fold(
() -> new Result(0, true),
(r, c) -> new Result(r.total+1, r.green & checkCommit(c))))
.findFirst()
.orElseThrow();
}

println(result.total + " commit(s) checked");
System.exit(result.green ? 0 : 1);
}

// From: Duke <[email protected]>
// Date: Thu, 1 Oct 2024 22:10:50 -0700
// Subject: [PATCH] Mail Validator
private static boolean isCommitHeader(List<String> lines) {
int i = 0;
return lines.size() == 5
&& lines.get(i++).startsWith("From: ") // "From" can be two lines in some cases
&&(lines.get(i++).startsWith("Date: ") || lines.get(i++).startsWith("Date: "))
&& lines.get(i++).startsWith("Subject: ");
}

private static Commit createCommit(int index, List<String> lines) {
int i = 0;
return lines.get(1).startsWith("Date: ") // "From" can be two lines in some cases
? new Commit(index, lines.get(i++), lines.get(i++), lines.get(i++), lines.get(i++))
: new Commit(index, lines.get(i++) + lines.get(i++), lines.get(i++), lines.get(i++), lines.get(i++));
}

boolean checkCommit(Commit c) {
return checkNameAndEmail(c.index, c.from)
& checkSubject(c.index, c.subject)
& checkBlankLineAfterSubject(c.index, c.blank);
}

boolean checkNameAndEmail(int i, String from) {
// From: Duke <[email protected]>
int start = from.indexOf('<');
int end = from.indexOf('>');

String mail = end > start ? from.substring(start+1, end) : "";
String author = start > 6 ? from.substring(6, start).strip() : "";

// bots may pass
if (author.contains("[bot]")) {
return true;
}

boolean green = true;
if (mail.isBlank() || !mail.contains("@") || mail.contains("noreply") || mail.contains("localhost")) {
println("::error::invalid email in commit " + i + " '" + from + "'");
green = false;
}

// mime encoding indicates it is probably a proper name, since gh account names aren't encoded
boolean encoded = author.startsWith("=?") && author.endsWith("?=");

// single word author -> probably the nickname/account name/root etc
if (author.isBlank() || (!encoded && !author.contains(" ") && !author.contains("-"))) {
println("::error::invalid author in commit " + i + " '" + author + "' (full name?)");
green = false;
}
return green;
}

// https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-commit.html#_discussion
boolean checkSubject(int i, String subject) {
// Subject: [PATCH] msg
subject = subject.substring(subject.indexOf(']')+1).strip();
// single word subjects are likely not intended or should be squashed before merge
if (!subject.contains(" ")) {
println("::error::invalid subject in commit " + i + " '" + subject + "'");
return false;
}
return true;
}

// there should be a blank line after the subject line, some subjects can overflow though.
boolean checkBlankLineAfterSubject(int i, String blank) {
// disabled since this would produce too many warnings due to overflowing subject lines
// if (!blank.isBlank()) {
// println("::warning::blank line after subject recommended in commit " + i + " (is subject over 50 char limit?)");
//// return false;
// }
return true;
}
70 changes: 44 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
timeout-minutes: 40
strategy:
matrix:
java: [ '17', '21', '23' ]
java: [ '17', '21', '24-ea' ]
exclude:
- java: ${{ github.event_name == 'pull_request' && 'nothing' || '21' }}
fail-fast: false
Expand Down Expand Up @@ -229,7 +229,7 @@ jobs:
java: [ 17 ]
include:
- os: ubuntu-latest
java: 22
java: 23
fail-fast: false
steps:

Expand Down Expand Up @@ -296,25 +296,31 @@ jobs:
echo "::error::PRs must be labeled, see: https://cwiki.apache.org/confluence/display/NETBEANS/PRs+and+You+-+A+reviewer+Guide"
exit 1
- name: Set up JDK ${{ matrix.java }}
if: ${{ !cancelled() }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: ${{ env.DEFAULT_JAVA_DISTRIBUTION }}

- name: Checkout ${{ github.ref }} ( ${{ github.sha }} )
if: ${{ !cancelled() }}
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: false
show-progress: false
fetch-depth: 10

- name: Print last 10 Commits
- name: Set up JDK 23 for scripts
if: ${{ github.event_name == 'pull_request' && !cancelled() }}
uses: actions/setup-java@v4
with:
java-version: 23
distribution: ${{ env.DEFAULT_JAVA_DISTRIBUTION }}

- name: Check Commit Headers
if: ${{ github.event_name == 'pull_request' && !cancelled() }}
run: git log --oneline -n10 --pretty=format:'%h %an [%ae] %s'
run: java --enable-preview .github/scripts/CommitHeaderChecker.java ${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.pull_request.number }}

- name: Set up JDK ${{ matrix.java }}
if: ${{ !cancelled() }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: ${{ env.DEFAULT_JAVA_DISTRIBUTION }}

- name: Check line endings and verify RAT report
if: ${{ !cancelled() }}
Expand Down Expand Up @@ -416,16 +422,23 @@ jobs:
- name: Build nbms
run: ant $OPTS build-nbms

# 13-14 min
- name: Build javadoc
if: env.test_javadoc == 'true' && success()
run: ant $OPTS build-javadoc

# runs only in PRs if requested; ~18 min
- name: Build all Tests
if: env.test_tests == 'true' && github.event_name == 'pull_request' && success()
run: ant -quiet -Dcluster.config=$CLUSTER_CONFIG test -Dtest.includes=NoTestsJustBuild

# 13-14 min for javadoc; JDK version must be synced with nb-javac
- name: Set up JDK 23 for javadoc
if: env.test_javadoc == 'true' && success()
uses: actions/setup-java@v4
with:
java-version: 23
distribution: ${{ env.DEFAULT_JAVA_DISTRIBUTION }}

- name: Build javadoc
if: env.test_javadoc == 'true' && success()
run: ant $OPTS build-javadoc

- name: Create Test Summary
uses: test-summary/action@v2
if: failure()
Expand Down Expand Up @@ -744,6 +757,9 @@ jobs:
- name: ide/team.commons
run: ant $OPTS -f ide/team.commons test

- name: ide/textmate.lexer
run: ant $OPTS -f ide/textmate.lexer test

- name: ide/terminal.nb
run: ant $OPTS -f ide/terminal.nb test

Expand Down Expand Up @@ -1294,6 +1310,9 @@ jobs:
- name: java.freeform
run: ant $OPTS -f java/java.freeform test

- name: java.file.launcher
run: ant $OPTS -f java/java.file.launcher test

# - name: java.kit
# run: ant $OPTS -f java/java.kit test

Expand Down Expand Up @@ -1983,6 +2002,9 @@ jobs:
# - name: j2ee.ejbverification
# run: ant $OPTS -f enterprise/j2ee.ejbverification test

- name: j2ee.persistence
run: ant $OPTS -f java/j2ee.persistence test

# Fails
# - name: j2eeserver
# run: ant $OPTS -f enterprise/j2eeserver test
Expand All @@ -1997,10 +2019,6 @@ jobs:
# - name: j2ee.sun.ddui
# run: ant $OPTS -f enterprise/j2ee.sun.ddui test

# Fails + Slow
# - name: jakarta.web.beans
# run: ant $OPTS -f enterprise/jakarta.web.beans test

- name: javaee.wildfly
run: .github/retry.sh ant $OPTS -f enterprise/javaee.wildfly test

Expand Down Expand Up @@ -2042,9 +2060,8 @@ jobs:
- name: tomcat5
run: ant $OPTS -f enterprise/tomcat5 test

# Fails
# - name: web.beans
# run: ant $OPTS -f enterprise/web.beans test
- name: web.beans
run: ant $OPTS -f enterprise/web.beans test

# Fails + Slow
# - name: web.core.syntax
Expand Down Expand Up @@ -2603,13 +2620,14 @@ jobs:
env "netbeans.extra.options=-J-Dnetbeans.logger.console=true" ant $OPTS test-vscode-ext

# last job depends on everything so that it is forced to run last even if a long job fails early
# cleanup job depends on everything so that it is forced to run last even if a long job fails early.
# 'paperwork' is left out intentionally, since it doesn't run unit tests (hopefully doesn't need restarts)
# and shouldn't prevent cleanup on validation failure - which might be common during dev time
cleanup:
name: Cleanup Workflow Artifacts
needs:
- base-build
- commit-validation
- paperwork
- build-system-test
- build-from-src-zip
- ide-modules-test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
source:

name: Build Source Zip
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:

Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
build-linux:

name: Build on Linux
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: source

steps:
Expand Down Expand Up @@ -227,7 +227,7 @@ jobs:
build-zip-with-build-artifacts:

name: Package Native Execution Libraries
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

# Only run when the platform specific builds are finished
needs: [build-linux, build-macos-x64, build-macos-arm]
Expand Down
Loading

0 comments on commit 324336a

Please sign in to comment.