This is an automated email from the ASF dual-hosted git repository. dlmarion pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo-access.git
The following commit(s) were added to refs/heads/main by this push: new 3f9b439 Add GH build actions, add license headers to files (#19) 3f9b439 is described below commit 3f9b439780f3d4002e32352c9ce27edc9de66cff Author: Dave Marion <dlmar...@apache.org> AuthorDate: Mon Oct 2 11:24:53 2023 -0400 Add GH build actions, add license headers to files (#19) Closes #18 --- .github/CONTRIBUTING.md | 41 +++ .github/workflows/maven.yaml | 132 +++++++++ .github/workflows/scripts.yaml | 61 +++++ contrib/antlr4/pom.xml | 20 ++ contrib/antlr4/src/main/antlr4/AccessExpression.g4 | 2 +- .../accumulo/access/grammar/SpecificationTest.java | 18 ++ .../antlr/AccessExpressionAntlrBenchmark.java | 18 ++ .../antlr/AccessExpressionAntlrEvaluator.java | 18 ++ .../grammar/antlr/AccessExpressionAntlrParser.java | 18 ++ .../accumulo/access/grammar/antlr/Antlr4Tests.java | 18 ++ pom.xml | 297 +++++++++++++++++++++ src/build/ci/find-unapproved-chars.sh | 50 ++++ src/build/ci/find-unapproved-junit.sh | 52 ++++ src/build/ci/install-shfmt.sh | 29 ++ src/build/ci/run-shellcheck.sh | 28 ++ src/build/ci/run-shfmt.sh | 26 ++ src/build/license-header.txt | 16 ++ .../java/org/apache/accumulo/access/AeNode.java | 18 ++ .../java/org/apache/accumulo/access/Parser.java | 18 ++ .../java/org/apache/accumulo/access/Tokenizer.java | 18 ++ 20 files changed, 897 insertions(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..8a07ce4 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,41 @@ +<!-- + + 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 + + https://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. + +--> + +# Contributors Guide + +If you believe that you have found a [bug](https://github.com/apache/accumulo-access/labels/bug), please search for an existing [issue](https://github.com/apache/accumulo-access/issues) to see if it has already been reported. If you would like to add a new feature to Accumulo-Access, please send an email with your idea to the [dev](mailto:d...@accumulo.apache.org) mail list. If it's appropriate, then we will create an issue. For simple changes, it's ok to just submit a pull request witho [...] + +## Development + +- See the [Developer's Guide](https://accumulo.apache.org/how-to-contribute/) for information regarding common build commands, IDE setup and more. +- Ensure that your work targets the correct branch +- Add/update unit and integration tests + +## Patch Submission + +- Ensure that Accumulo-Access builds cleanly before submitting your patch using the command: `mvn clean verify` +- Before submission please squash your commits using a message that starts with the issue number and a description of the changes. +- Patches should be submitted in the form of Pull Requests to the Apache Accumulo-Access GitHub [repository](https://github.com/apache/accumulo-access/). + +## Review + +- We welcome reviews from anyone. Any committer can approve and merge the changes. +- Reviewers will likely have questions and comments. They may use terms such as those in [RFC2119](https://tools.ietf.org/html/rfc2119). diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml new file mode 100644 index 0000000..7c7f8b4 --- /dev/null +++ b/.github/workflows/maven.yaml @@ -0,0 +1,132 @@ +# +# 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 +# +# https://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. +# + +# This workflow will build a Java project with Maven +# See also: +# https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: QA + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] + +permissions: + contents: read + +jobs: + # fast build to populate the local maven repository cache + fastbuild: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: adopt + java-version: 11 + - name: Cache local maven repository + uses: actions/cache@v3 + with: + path: | + ~/.m2/repository/ + !~/.m2/repository/org/apache/accumulo + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Show the first log message + run: git log -n1 + - name: Check for unapproved characters + run: src/build/ci/find-unapproved-chars.sh + - name: Check for unapproved JUnit API usage + run: src/build/ci/find-unapproved-junit.sh + - name: Build with Maven (Fast Build) + timeout-minutes: 20 + run: mvn -B -V -e -ntp "-Dstyle.color=always" clean package dependency:resolve -DskipTests -DskipFormat -DverifyFormat + env: + MAVEN_OPTS: -Djansi.force=true + # more complete builds with tests + mvn: + needs: fastbuild + strategy: + matrix: + profile: + - {name: 'unit-tests', javaver: 11, args: 'verify -PskipQA'} + - {name: 'qa-checks', javaver: 11, args: 'verify javadoc:jar -Psec-bugs,errorprone'} + - {name: 'jdk17', javaver: 17, args: 'verify javadoc:jar -Psec-bugs,errorprone'} + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK ${{ matrix.profile.javaver }} + uses: actions/setup-java@v3 + with: + distribution: adopt + java-version: ${{ matrix.profile.javaver }} + - name: Cache local maven repository + uses: actions/cache@v3 + witi: + path: | + ~/.m2/repository/ + !~/.m2/repository/org/apache/accumulo + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Override DNS to fix IP address for hostname + run: | + ip -br addr + echo "'hostname -i' shows '$(hostname -i)'" + echo "'hostname -I' shows '$(hostname -I)'" + hostname_short=$(hostname -s) + hostname_long=$(hostname -f) + if ! grep -q $hostname_short /etc/hosts; then + actual_ip=$(ip -4 addr show dev eth0 | grep -o 'inet [0-9.]*' | cut -f2 -d ' ') + echo "Setting $hostname_long / $hostname_short to $actual_ip in /etc/hosts" + echo "$actual_ip $hostname_long $hostname_short" | sudo tee -a /etc/hosts + ip -br addr + echo "'hostname -i' shows '$(hostname -i)'" + echo "'hostname -I' shows '$(hostname -I)'" + fi + - name: Build with Maven (${{ matrix.profile.name }}) + timeout-minutes: 60 + run: mvn -B -V -e -ntp "-Dstyle.color=always" -DskipFormat ${{ matrix.profile.args }} + env: + MAVEN_OPTS: -Djansi.force=true + - name: Upload unit test results + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: surefire-reports-${{ matrix.profile.name }} + path: ./**/target/surefire-reports/ + if-no-files-found: ignore + - name: Upload integration test results + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: failsafe-reports-${{ matrix.profile.name }} + path: ./**/target/failsafe-reports/ + if-no-files-found: ignore + - name: Upload mini test logs + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: mini-tests-logs-${{ matrix.profile.name }} + path: ./**/target/**/mini-tests/**/logs/ + if-no-files-found: ignore + diff --git a/.github/workflows/scripts.yaml b/.github/workflows/scripts.yaml new file mode 100644 index 0000000..40bf549 --- /dev/null +++ b/.github/workflows/scripts.yaml @@ -0,0 +1,61 @@ +# +# 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 +# +# https://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. +# + +# This workflow will build a Java project with Maven +# See also: +# https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: ScriptQA + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] + +permissions: + contents: read + +jobs: + shfmt: + name: shfmt + timeout-minutes: 3 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Show the first log message + run: git log -n1 + - name: Install shfmt + run: src/build/ci/install-shfmt.sh + - name: Checking formatting of all scripts + run: src/build/ci/run-shfmt.sh + + shellcheck: + name: ShellCheck + timeout-minutes: 3 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Show the first log message + run: git log -n1 + - name: Install shfmt + run: src/build/ci/install-shfmt.sh + - name: Running shellcheck on all scripts + run: src/build/ci/run-shellcheck.sh + diff --git a/contrib/antlr4/pom.xml b/contrib/antlr4/pom.xml index ca30fbf..3aa1cb6 100644 --- a/contrib/antlr4/pom.xml +++ b/contrib/antlr4/pom.xml @@ -1,4 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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 + + https://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. + +--> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> diff --git a/contrib/antlr4/src/main/antlr4/AccessExpression.g4 b/contrib/antlr4/src/main/antlr4/AccessExpression.g4 index e945c6d..4ab5f6f 100644 --- a/contrib/antlr4/src/main/antlr4/AccessExpression.g4 +++ b/contrib/antlr4/src/main/antlr4/AccessExpression.g4 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ grammar AccessExpression; @header { diff --git a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/SpecificationTest.java b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/SpecificationTest.java index d0362db..500036b 100644 --- a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/SpecificationTest.java +++ b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/SpecificationTest.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * https://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. + */ package org.apache.accumulo.access.grammar; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrBenchmark.java b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrBenchmark.java index 80ad3a3..e9e9725 100644 --- a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrBenchmark.java +++ b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrBenchmark.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * https://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. + */ package org.apache.accumulo.access.grammar.antlr; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrEvaluator.java b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrEvaluator.java index 98fe4a8..a3ddc29 100644 --- a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrEvaluator.java +++ b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrEvaluator.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * https://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. + */ package org.apache.accumulo.access.grammar.antlr; import java.util.ArrayList; diff --git a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrParser.java b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrParser.java index 615e836..95f5898 100644 --- a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrParser.java +++ b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/AccessExpressionAntlrParser.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * https://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. + */ package org.apache.accumulo.access.grammar.antlr; import java.nio.charset.StandardCharsets; diff --git a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/Antlr4Tests.java b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/Antlr4Tests.java index 799d18c..1849de0 100644 --- a/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/Antlr4Tests.java +++ b/contrib/antlr4/src/test/java/org/apache/accumulo/access/grammar/antlr/Antlr4Tests.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * https://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. + */ package org.apache.accumulo.access.grammar.antlr; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/pom.xml b/pom.xml index 626572f..d8ca8c7 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ <maven.compiler.target>11</maven.compiler.target> <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <version.errorprone>2.20.0</version.errorprone> <version.jmh>1.36</version.jmh> </properties> <dependencies> @@ -71,6 +72,37 @@ </dependencies> <build> <plugins> + <plugin> + <groupId>com.mycila</groupId> + <artifactId>license-maven-plugin</artifactId> + <version>4.2</version> + <configuration> + <licenseSets> + <licenseSet> + <header>src/build/license-header.txt</header> + <excludes combine.children="append"> + <exclude>contrib/antlr4/src/test/resources/specification.abnf</exclude> + <exclude>contrib/antlr4/src/main/antlr4/Abnf.g4</exclude> + <exclude>**/DEPENDENCIES</exclude> + <exclude>**/LICENSE</exclude> + <exclude>**/NOTICE</exclude> + <exclude>**/target/**</exclude> + </excludes> + </licenseSet> + </licenseSets> + <mapping combine.children="append"> + <!-- general mappings; module-specific mappings appear in their respective pom --> + <Makefile>SCRIPT_STYLE</Makefile> + <c>SLASHSTAR_STYLE</c> + <cc>SLASHSTAR_STYLE</cc> + <css>SLASHSTAR_STYLE</css> + <g4>SLASHSTAR_STYLE</g4> + <h>SLASHSTAR_STYLE</h> + <java>SLASHSTAR_STYLE</java> + <thrift>SLASHSTAR_STYLE</thrift> + </mapping> + </configuration> + </plugin> <plugin> <groupId>com.github.ekryd.sortpom</groupId> <artifactId>sortpom-maven-plugin</artifactId> @@ -157,6 +189,271 @@ </execution> </executions> </plugin> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>4.7.3.5</version> + <configuration> + <xmlOutput>true</xmlOutput> + <effort>Max</effort> + <failOnError>true</failOnError> + <includeTests>true</includeTests> + <maxRank>17</maxRank> + <jvmArgs>-Dcom.overstock.findbugs.ignore=com.google.common.util.concurrent.RateLimiter,com.google.common.hash.Hasher,com.google.common.hash.HashCode,com.google.common.hash.HashFunction,com.google.common.hash.Hashing,com.google.common.cache.Cache,com.google.common.io.CountingOutputStream,com.google.common.io.ByteStreams,com.google.common.cache.LoadingCache,com.google.common.base.Stopwatch,com.google.common.cache.RemovalNotification,com.google.common.util.concurrent.Uninterruptib [...] + <plugins combine.children="append"> + <plugin> + <groupId>com.overstock.findbugs</groupId> + <artifactId>library-detectors</artifactId> + <version>1.2.0</version> + </plugin> + </plugins> + </configuration> + <executions> + <execution> + <id>run-spotbugs</id> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> + <profiles> + <profile> + <!-- This profile skips all Quality Assurance checks; activate with -PskipQA OR -DskipQA --> + <id>skipQA</id> + <activation> + <property> + <name>skipQA</name> + </property> + </activation> + <properties> + <accumulo.skip>true</accumulo.skip> + <apilyzer.skip>true</apilyzer.skip> + <checkstyle.skip>true</checkstyle.skip> + <formatter.skip>true</formatter.skip> + <impsort.skip>true</impsort.skip> + <mdep.analyze.skip>true</mdep.analyze.skip> + <modernizer.skip>true</modernizer.skip> + <rat.skip>true</rat.skip> + <skipITs>true</skipITs> + <skipTests>true</skipTests> + <sort.skip>true</sort.skip> + <spotbugs.skip>true</spotbugs.skip> + <warbucks.skip>true</warbucks.skip> + </properties> + </profile> + <profile> + <!-- off by default, but enable with '-P verifyformat' or '-DverifyFormat' --> + <id>verifyformat</id> + <activation> + <property> + <name>verifyFormat</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>com.github.ekryd.sortpom</groupId> + <artifactId>sortpom-maven-plugin</artifactId> + <executions> + <execution> + <id>verify-sorted-pom</id> + <goals> + <goal>verify</goal> + </goals> + <phase>process-resources</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.mycila</groupId> + <artifactId>license-maven-plugin</artifactId> + <executions> + <execution> + <id>verify-license-headers</id> + <goals> + <goal>check</goal> + </goals> + <phase>process-test-resources</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> + <executions> + <execution> + <id>verify-formatted-java-source</id> + <goals> + <goal>validate</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>net.revelc.code</groupId> + <artifactId>impsort-maven-plugin</artifactId> + <executions> + <execution> + <id>verify-sorted-imports</id> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <!-- on by default, but disable with '-P !autoformat' or '-DskipFormat' --> + <id>autoformat</id> + <activation> + <property> + <name>!skipFormat</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>com.github.ekryd.sortpom</groupId> + <artifactId>sortpom-maven-plugin</artifactId> + <executions> + <execution> + <id>sort-pom</id> + <goals> + <goal>sort</goal> + </goals> + <phase>process-sources</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.mycila</groupId> + <artifactId>license-maven-plugin</artifactId> + <executions> + <execution> + <id>license-headers</id> + <goals> + <goal>format</goal> + </goals> + <phase>process-test-resources</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> + <executions> + <execution> + <id>format-java-source</id> + <goals> + <goal>format</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>net.revelc.code</groupId> + <artifactId>impsort-maven-plugin</artifactId> + <executions> + <execution> + <id>sort-imports</id> + <goals> + <goal>sort</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>sec-bugs</id> + <build> + <plugins> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>4.7.3.5</version> + <configuration> + <plugins> + <plugin> + <groupId>com.h3xstream.findsecbugs</groupId> + <artifactId>findsecbugs-plugin</artifactId> + <version>1.12.0</version> + </plugin> + </plugins> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <!-- This profile uses the Google ErrorProne tool to perform static code analysis at + compile time. Auto-generated code is not checked. + See: https://errorprone.info/bugpatterns for list of available bug patterns.--> + <id>errorprone</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <compilerArgs> + <arg>-XDcompilePolicy=simple</arg> + <arg> + -Xplugin:ErrorProne \ + -XepExcludedPaths:.*/(src/test)/.* \ + -XepDisableWarningsInGeneratedCode \ + -XepDisableAllWarnings \ + <!-- ERROR patterns to specifically ignore --> + -Xep:MustBeClosedChecker:OFF \ + -Xep:UnicodeInCode:OFF \ + <!-- WARNING patterns to specifically check --> + -Xep:ExpectedExceptionChecker \ + <!-- treat following warning as an error --> + -Xep:FutureReturnValueIgnored:ERROR \ + -Xep:MissingOverride \ + <!--WARN if braces are missing for control statements --> + -Xep:MissingBraces:WARN \ + <!-- Items containing 'OFF' are currently Errors flagged by ErrorProne. The 'OFF' + can be removed and the project recompiled to discover location of errors for + further analysis. @SuppressWarnings can be used to ignore errors if desired. --> + </arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg> + </compilerArgs> + <annotationProcessorPaths> + <path> + <groupId>com.google.errorprone</groupId> + <artifactId>error_prone_core</artifactId> + <version>${version.errorprone}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>jdk17</id> + <activation> + <jdk>[17,)</jdk> + </activation> + <properties> + <extraTestArgs>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.management/java.lang.management=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/jav [...] + </properties> + </profile> + </profiles> </project> diff --git a/src/build/ci/find-unapproved-chars.sh b/src/build/ci/find-unapproved-chars.sh new file mode 100755 index 0000000..d02fb13 --- /dev/null +++ b/src/build/ci/find-unapproved-chars.sh @@ -0,0 +1,50 @@ +#! /usr/bin/env bash +# +# 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 +# +# https://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. +# + +# The purpose of this ci script is to ensure that a pull request doesn't +# unintentionally, or maliciously, add any new non-ASCII characters unless they +# are preapproved on the ALLOWED list or in known binary or resource files +NUM_EXPECTED=0 +ALLOWED='©èö🐈三四五六八九十' + +function findallnonascii() { + # -P for perl matching, -o for only showing the match for counting occurrences not lines + local opts='-Po' + if [[ $1 == 'print' ]]; then + # -P for perl matching, -H for always showing filenames, -n for showing line numbers + opts='-PHn' + fi + find . -type f \ + -not -path '*/\.git/*' \ + -not -regex '.*[.]\(png\|jar\|\|jceks\)$' \ + -exec grep "$opts" "[^[:ascii:]$ALLOWED]" {} + +} + +function comparecounts() { + local count + count=$(findallnonascii | wc -l) + if [[ $NUM_EXPECTED -ne $count ]]; then + echo "Expected $NUM_EXPECTED, but found $count unapproved non-ASCII characters:" + findallnonascii 'print' + return 1 + fi +} + +comparecounts && echo "Found exactly $NUM_EXPECTED unapproved non-ASCII characters, as expected" diff --git a/src/build/ci/find-unapproved-junit.sh b/src/build/ci/find-unapproved-junit.sh new file mode 100755 index 0000000..c3a898a --- /dev/null +++ b/src/build/ci/find-unapproved-junit.sh @@ -0,0 +1,52 @@ +#! /usr/bin/env bash +# +# 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 +# +# https://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. +# + +# The purpose of this ci script is to ensure that a pull request doesn't +# unintentionally add JUnit jupiter APIs to vintage tests, or add vintage +# APIs to new jupiter tests. +NUM_EXPECTED=0 +ALLOWED=() + +ALLOWED_PIPE_SEP=$({ for x in "${ALLOWED[@]}"; do echo "$x"; done; } | paste -sd'|') + +function findalljunitproblems() { + # -P for perl matching, -R for recursive, -l for matching files + local opts='-PRl' + if [[ $1 == 'print' ]]; then + # -P for perl matching, -R for recursive, -l for matching files, -H for always showing filenames + opts='-PRlH' + fi + # find any new classes using something other than the jupiter API, except those allowed + grep "$opts" --include='*.java' 'org[.]junit[.](?!jupiter)' | grep -Pv "^(${ALLOWED_PIPE_SEP//./[.]})\$" + # find any uses of the jupiter API in the allowed vintage classes + grep "$opts" 'org[.]junit[.]jupiter' "${ALLOWED[@]}" +} + +function comparecounts() { + local count + count=$(findalljunitproblems | wc -l) + if [[ $NUM_EXPECTED -ne $count ]]; then + echo "Expected $NUM_EXPECTED, but found $count classes using the wrong JUnit APIs:" + findalljunitproblems 'print' + return 1 + fi +} + +comparecounts && echo "Found exactly $NUM_EXPECTED unapproved JUnit API uses, as expected" diff --git a/src/build/ci/install-shfmt.sh b/src/build/ci/install-shfmt.sh new file mode 100755 index 0000000..fd73efc --- /dev/null +++ b/src/build/ci/install-shfmt.sh @@ -0,0 +1,29 @@ +#! /usr/bin/env bash +# +# 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 +# +# https://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. +# + +# Install shfmt tool to search for and optionally format bash scripts +# This is useful for other CI tools to run ShellCheck and shfmt to format + +set -e +set -x + +shfmt_version=3.4.3 +sudo wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O /usr/local/bin/shfmt && + sudo chmod +x /usr/local/bin/shfmt diff --git a/src/build/ci/run-shellcheck.sh b/src/build/ci/run-shellcheck.sh new file mode 100755 index 0000000..5d6ca75 --- /dev/null +++ b/src/build/ci/run-shellcheck.sh @@ -0,0 +1,28 @@ +#! /usr/bin/env bash +# +# 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 +# +# https://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. +# + +# Run ShellCheck on all bash scripts + +set -e + +mapfile -t filestocheck < <(shfmt -f .) + +set -x +shellcheck -P SCRIPTDIR -x "${filestocheck[@]}" diff --git a/src/build/ci/run-shfmt.sh b/src/build/ci/run-shfmt.sh new file mode 100755 index 0000000..233df9a --- /dev/null +++ b/src/build/ci/run-shfmt.sh @@ -0,0 +1,26 @@ +#! /usr/bin/env bash +# +# 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 +# +# https://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. +# + +# Check formatting of all bash scripts + +set -e +set -x + +shfmt -ln bash -l -d -i 2 -ci -s . diff --git a/src/build/license-header.txt b/src/build/license-header.txt new file mode 100644 index 0000000..f808223 --- /dev/null +++ b/src/build/license-header.txt @@ -0,0 +1,16 @@ +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 + + https://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. diff --git a/src/main/java/org/apache/accumulo/access/AeNode.java b/src/main/java/org/apache/accumulo/access/AeNode.java index 556dd6d..b627367 100644 --- a/src/main/java/org/apache/accumulo/access/AeNode.java +++ b/src/main/java/org/apache/accumulo/access/AeNode.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * https://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. + */ package org.apache.accumulo.access; import java.util.List; diff --git a/src/main/java/org/apache/accumulo/access/Parser.java b/src/main/java/org/apache/accumulo/access/Parser.java index c8373ed..8eb822e 100644 --- a/src/main/java/org/apache/accumulo/access/Parser.java +++ b/src/main/java/org/apache/accumulo/access/Parser.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * https://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. + */ package org.apache.accumulo.access; import java.util.ArrayList; diff --git a/src/main/java/org/apache/accumulo/access/Tokenizer.java b/src/main/java/org/apache/accumulo/access/Tokenizer.java index bd52616..de5e21f 100644 --- a/src/main/java/org/apache/accumulo/access/Tokenizer.java +++ b/src/main/java/org/apache/accumulo/access/Tokenizer.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * https://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. + */ package org.apache.accumulo.access; import static java.nio.charset.StandardCharsets.UTF_8;