Skip to content

Commit

Permalink
add license check action & use proper "UTF-8" charset
Browse files Browse the repository at this point in the history
  • Loading branch information
imbajin committed Feb 8, 2023
1 parent 6ae93ff commit 7805380
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 28 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: hugegraph-computer ci
name: "hugegraph-computer ci"

on:
push:
Expand All @@ -9,7 +9,7 @@ on:

jobs:
computer-ci:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
TRAVIS_DIR: computer-dist/src/assembly/travis
KUBERNETES_VERSION: 1.20.1
Expand All @@ -21,7 +21,7 @@ jobs:
with:
fetch-depth: 2

- name: Install JDK 8
- name: Install JDK 8 for HDFS
uses: actions/setup-java@v3
with:
java-version: '8'
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/license-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "license checker"

on:
push:
branches:
- master
- /^release-.*$/
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-license-header:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# More info could refer to: https://github.com/apache/skywalking-eyes
- name: Check License Header
uses: apache/skywalking-eyes@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
log: info
config: .licenserc.yaml

- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

- name: License check(RAT)
run: |
mvn apache-rat:check -ntp
find ./ -name rat.txt -print0 | xargs -0 -I file cat file > merged-rat.txt
grep "Binaries" merged-rat.txt -C 3 && cat merged-rat.txt
# TODO: enable it later
# check-dependency-license:
# runs-on: ubuntu-latest
# env:
# SCRIPT_DEPENDENCY: computer-dist/scripts/dependency
# steps:
# - name: Checkout source
# uses: actions/checkout@v3
# - name: Set up JDK 11
# uses: actions/setup-java@v3
# with:
# java-version: '11'
# distribution: 'adopt'
# - name: mvn install
# run: |
# mvn install -DskipTests=true -ntp
# - name: generate current dependencies
# run: |
# bash $SCRIPT_DEPENDENCY/regenerate_known_dependencies.sh current-dependencies.txt
# - name: check third dependencies
# run: |
# bash $SCRIPT_DEPENDENCY/check_dependencies.sh
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Mark stale issues and pull requests
name: "Mark stale issues and pull requests"

on:
schedule:
Expand Down
80 changes: 80 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#
# 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.
#

header: # `header` section is configurations for source codes license header.
license:
spdx-id: Apache-2.0 # the spdx id of the license, it's convenient when your license is standard SPDX license.
copyright-owner: Apache Software Foundation # the copyright owner to replace the [owner] in the `spdx-id` template.
content: | # `license` will be used as the content when `fix` command needs to insert a license header.
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.
# `pattern` is optional regexp if all the file headers are the same as `license` or the license of `spdx-id` and `copyright-owner`.
pattern: |
Licensed to the Apache Software Foundation under one or more contributor
license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright
ownership. The Apache Software Foundation 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.
paths: # `paths` are the path list that will be checked (and fixed) by license-eye, default is ['**'].
- '**'

paths-ignore: # `paths-ignore` are the path list that will be ignored by license-eye.
- '.gitignore'
- 'LICENSE'
- 'NOTICE'
- 'DISCLAIMER'
- '**/*.md'
- '**/*.versionsBackup'
- '**/*.log'
- '**/*.conf'
- '**/*.txt'
- '**/*.csv'
- '**/*.json'
- '**/*.svg'
- '**/*.gitattributes'
- '**/.flattened-pom.xml'
- '**/.prettierrc'
- '**/*.MF'
- '**/.stylelintrc'
- 'assembly/**'
- '.github/**/*'
- '**/target/*'
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.

# license-location-threshold specifies the index threshold where the license header can be located,
# after all, a "header" cannot be TOO far from the file start.
license-location-threshold: 80

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package org.apache.hugegraph.computer.core.util;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
Expand All @@ -28,7 +28,6 @@

/**
* @author Matthias Broecheler (me@matthiasb.com)
* @author HugeGraph Authors
*/
public final class StringEncoding {

Expand All @@ -47,7 +46,7 @@ public final class StringEncoding {
private static final Base64.Encoder BASE64_ENCODER = Base64.getEncoder();
private static final Base64.Decoder BASE64_DECODER = Base64.getDecoder();

// Similar to {@link StringSerializer}
/** Similar to {@link StringSerializer} */
public static int writeAsciiString(byte[] array, int offset, String value) {
E.checkArgument(CharMatcher.ascii().matchesAllOf(value),
"'%s' must be ASCII string", value);
Expand All @@ -63,7 +62,8 @@ public static int writeAsciiString(byte[] array, int offset, String value) {
assert c <= 127;
byte b = (byte) c;
if (++i == len) {
b |= 0x80; // End marker
// End marker
b |= 0x80;
}
array[offset++] = b;
} while (i < len);
Expand All @@ -73,7 +73,7 @@ public static int writeAsciiString(byte[] array, int offset, String value) {

public static String readAsciiString(byte[] array, int offset) {
StringBuilder sb = new StringBuilder();
int c = 0;
int c;
do {
c = 0xFF & array[offset++];
if (c != 0x80) {
Expand All @@ -90,27 +90,15 @@ public static int getAsciiByteLength(String value) {
}

public static byte[] encode(String value) {
try {
return value.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ComputerException("Failed to encode string", e);
}
return value.getBytes(StandardCharsets.UTF_8);
}

public static String decode(byte[] bytes) {
try {
return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ComputerException("Failed to decode string", e);
}
return new String(bytes, StandardCharsets.UTF_8);
}

public static String decode(byte[] bytes, int offset, int length) {
try {
return new String(bytes, offset, length, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ComputerException("Failed to decode string", e);
}
return new String(bytes, offset, length, StandardCharsets.UTF_8);
}

public static String encodeBase64(byte[] bytes) {
Expand Down Expand Up @@ -141,8 +129,7 @@ public static UUID uuid(String value) {
return UUID.fromString(value);
}
// UUID represented by hex string
E.checkArgument(value.length() == 32,
"Invalid UUID string: %s", value);
E.checkArgument(value.length() == 32, "Invalid UUID string: %s", value);
String high = value.substring(0, 16);
String low = value.substring(16);
return new UUID(Long.parseUnsignedLong(high, 16),
Expand Down
6 changes: 4 additions & 2 deletions computer-dist/release-docs/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ The following components are provided under the Apache 2.0 License.
(Apache License, Version 2.0,LGPL 2.1) * Xml Compatibility extensions for Jackson(org.codehaus.jackson:jackson-xc:1.9.2-http://jackson.codehaus.org )
(Apache License, Version 2.0,LGPL 2.1,MPL 1.1) * Javassist(org.javassist:javassist:3.21.0-GA-http://www.javassist.org/ )

computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java files from https://github.com/JanusGraph

========================================================================
Third party BSD licenses
========================================================================
Expand Down Expand Up @@ -497,9 +499,9 @@ The following components are provided under the Public Domain License.
(Public Domain, per Creative Commons CC0) * XZ for Java(org.tukaani:xz:1.8-https://tukaani.org/xz/java.html )

========================================================================
Third party Go licens
Third party Go license
========================================================================

The following components are provided under The Go licens.
The following components are provided under The Go license.

(The Go license) * re2j(com.google.re2j:re2j:1.1-http://github.com/google/re2j )

0 comments on commit 7805380

Please sign in to comment.