Github Action 備忘録

Windows でエラー

jobs:
  drools-build:
    ...
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
      ...
    steps:
      ...
      - name: Backward Compatibility Test
        run: |
          CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
          echo "Current version: $CURRENT_VERSION"

Windows だけエラー

The term 'CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)' is not recognized
as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.

shell: bash をつければよい。(Windows のデフォルトは PowerShell)

Java Performance tips

  • Use benchmark!

  • String.replace("A", "B") -> String.replace('A', 'B') : char is faster

  • String.format("%s.%s", strA, strB) -> StringBuilder.append(strA).append(".").append(strB) : format is better for maintenance, but StringBuilder would be faster for critical path
  • Avoid sort O(n log(n)) as possible
  • Be careful about Regex
  • Avoid long method
  • logger.debug("value = " + value) -> logger("value = {}", value)