Fix Java code analysis #203
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: GS1 Encoders CI | |
on: | |
push: | |
pull_request: | |
jobs: | |
# | |
# CI jobs | |
# | |
ci-clang: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: clang CI (with sanitizers) | |
run: | | |
# For llvm-symbolizer | |
sudo apt-get -y --no-install-recommends install llvm | |
# Load AI table from external Syntax Dictionary | |
make -C src/c-lib -j `nproc` test CC=clang SANITIZE=yes SLOW_TESTS=yes | |
# Re-run using the embedded AI table | |
rm src/c-lib/gs1-syntax-dictionary.txt | |
make -C src/c-lib -j `nproc` test CC=clang SANITIZE=yes SLOW_TESTS=yes | |
git checkout src/c-lib/gs1-syntax-dictionary.txt | |
make -C src/c-lib -j `nproc` lib CC=clang SANITIZE=yes | |
make -C src/c-lib -j `nproc` app CC=clang SANITIZE=yes | |
( cd src/c-lib && LD_LIBRARY_PATH=build build/gs1encoders.bin --version ) | |
make -C src/c-lib -j `nproc` app-static CC=clang SANITIZE=yes | |
( cd src/c-lib && build/gs1encoders-linux.bin --version ) | |
ci-gcc: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: gcc CI | |
run: | | |
# Load AI table from external Syntax Dictionary | |
make -C src/c-lib -j `nproc` test CC=gcc SLOW_TESTS=yes | |
# Re-run using the embedded AI table | |
rm src/c-lib/gs1-syntax-dictionary.txt | |
make -C src/c-lib -j `nproc` test CC=gcc SLOW_TESTS=yes | |
git checkout src/c-lib/gs1-syntax-dictionary.txt | |
make -C src/c-lib -j `nproc` lib CC=gcc | |
make -C src/c-lib -j `nproc` app CC=gcc | |
( cd src/c-lib && LD_LIBRARY_PATH=build build/gs1encoders.bin --version ) | |
make -C src/c-lib -j `nproc` app-static CC=gcc | |
( cd src/c-lib && build/gs1encoders-linux.bin --version ) | |
ci-msvc: | |
runs-on: windows-2019 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
- name: MSVC CI | |
run: | | |
msbuild /t:Restore,Build /p:Configuration=release /p:Platform="x86" /warnaserror src\gs1encoders.sln | |
# Load AI table from external Syntax Dictionary | |
copy src\c-lib\gs1-syntax-dictionary.txt . | |
src\c-lib\build\test\Win32\Release\gs1encoders-test.exe | |
# Re-run using the embedded AI table | |
del gs1-syntax-dictionary.txt | |
src\c-lib\build\test\Win32\Release\gs1encoders-test.exe | |
copy src\c-lib\gs1-syntax-dictionary.txt . | |
src\c-lib\build\console-app\Win32\Release\gs1encoders-app.exe --version | |
src\dotnet-app\bin\Release\netcoreapp3.1\gs1encoders-dotnet-app.exe --version | |
ci-macos: | |
runs-on: macos-12 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: clang CI | |
run: | | |
# Load AI table from external Syntax Dictionary | |
make -C src/c-lib -j `sysctl -n hw.logicalcpu` test SANITIZE=yes SLOW_TESTS=yes | |
# Re-run using the embedded AI table | |
rm src/c-lib/gs1-syntax-dictionary.txt | |
make -C src/c-lib -j `sysctl -n hw.logicalcpu` test SANITIZE=yes SLOW_TESTS=yes | |
git checkout src/c-lib/gs1-syntax-dictionary.txt | |
make -C src/c-lib -j `sysctl -n hw.logicalcpu` lib SANITIZE=yes | |
make -C src/c-lib -j `sysctl -n hw.logicalcpu` app SANITIZE=yes | |
( cd src/c-lib && DYLD_LIBRARY_PATH=build build/gs1encoders.bin --version ) | |
make -C src/c-lib -j `sysctl -n hw.logicalcpu` app-static SANITIZE=yes | |
( cd src/c-lib && build/gs1encoders-linux.bin --version ) | |
ci-scan-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: clang static analyser CI | |
run: | | |
sudo apt-get update | |
sudo apt-get -y --no-install-recommends install clang-tools | |
scan-build -o plist make -C src/c-lib -j `nproc` all CC=clang | |
scan-build -o plist make -C src/c-lib -j `nproc` test CC=clang SLOW_TESTS=yes | |
[ "$(find plist/ -name *.html)" = '' ]; | |
- name: "clang static analyzer: Store assets on failure" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: clang-scan.tgz | |
path: plist/**/*.html | |
retention-days: 30 | |
if: ${{ failure() }} | |
- name: check includes with IWYU | |
working-directory: src/c-lib | |
run: | | |
sudo apt-get -y --no-install-recommends install iwyu | |
find -name '*.c' -print0 | xargs -0 -n1 -i bash -c 'iwyu -DPRNT -DSYMBOLOGY=gs1_encoder_sNONE -DUNIT_TESTS -DGS1_LINTER_ERR_STR_EN {}; [[ $? = 2 ]] || false' | |
- name: cppcheck | |
working-directory: src/c-lib | |
run: | | |
sudo apt-get -y --no-install-recommends install cppcheck | |
cppcheck --enable=all --force \ | |
-U GS1_LINTER_CUSTOM_GCP_LOOKUP \ | |
-U GS1_LINTER_CUSTOM_GCP_LOOKUP_H \ | |
-U GS1_LINTER_CUSTOM_ISO4217_LOOKUP \ | |
-U GS1_LINTER_CUSTOM_ISO4217_LOOKUP_H \ | |
-U GS1_LINTER_CUSTOM_ISO3166ALPHA2_LOOKUP \ | |
-U GS1_LINTER_CUSTOM_ISO3166ALPHA2_LOOKUP_H \ | |
-U GS1_LINTER_CUSTOM_ISO3166_LOOKUP \ | |
-U GS1_LINTER_CUSTOM_ISO3166_LOOKUP_H \ | |
-U GS1_LINTER_CUSTOM_MEDIA_TYPE_LOOKUP \ | |
-U GS1_LINTER_CUSTOM_MEDIA_TYPE_LOOKUP_H \ | |
-U CLOCK_MONOTONIC -U RUNNING_ON_VALGRIND -U TEST_FINI -U TEST_INIT \ | |
-i gs1encoders-fuzzer-ais.c \ | |
-i gs1encoders-fuzzer-dl.c \ | |
-i gs1encoders-fuzzer-scandata.c \ | |
-i gs1encoders-fuzzer-syn.c \ | |
-i gs1syntaxdictionary-fuzzer-linters.c \ | |
--suppress=missingIncludeSystem . | |
ci-java: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Java CI | |
run: | | |
make -C src/c-lib -j `nproc` libstatic | |
ant -f src/java/build.xml test | |
ci-wasm: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: mymindstorm/setup-emsdk@v14 | |
- uses: actions/checkout@v4 | |
- name: WASM build | |
run: | | |
make -C src/c-lib -j `nproc` wasm | |
ls -l src/c-lib/build-wasm | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Node.js tests | |
working-directory: src/js-wasm | |
run: | | |
npm install | |
node --experimental-vm-modules node_modules/jest-cli/bin/jest.js | |
- name: Node.js run | |
working-directory: src/js-wasm | |
run: | | |
node example.node.mjs --version | |
ci-jsonly: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: mymindstorm/setup-emsdk@v14 | |
- uses: actions/checkout@v4 | |
- name: WASM build | |
run: | | |
make -C src/c-lib -j `nproc` wasm JSONLY=yes | |
ls -l src/c-lib/build-wasm | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Node.js test | |
working-directory: src/js-wasm | |
run: | | |
npm install | |
node --experimental-vm-modules node_modules/jest-cli/bin/jest.js | |
- name: Node.js run | |
working-directory: src/js-wasm | |
run: | | |
node example.node.mjs --version | |
ci-ios-app: | |
runs-on: macos-12 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: src/ios/Pods | |
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pods- | |
- name: iOS app CI | |
working-directory: src/ios | |
run: | | |
pod install | |
xcodebuild -workspace GS1\ Encoders\ App.xcworkspace -scheme 'GS1 Encoders App' build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | |
ci-android-app: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'gradle' | |
- name: Android app CI | |
working-directory: src/android | |
run: | | |
./gradlew build --no-daemon | |
# | |
# Production builds | |
# | |
build-release-windows: | |
needs: | |
- ci-msvc | |
runs-on: windows-2019 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
- name: Windows release build | |
run: | | |
msbuild /t:Restore,Build /p:Configuration=release /p:Platform="x86" /p:RuntimeIdentifier=win-x86 /warnaserror src\gs1encoders.sln | |
msbuild /p:Configuration=release /p:Platform="x86" /p:PublishSingleFile=True /p:SelfContained=True /p:RuntimeIdentifier=win-x86 /p:PublishDir=bin\Release\netcoreapp3.1\win-x86\publish\ /warnaserror src\gs1encoders.sln -target:gs1encoders-dotnet-app:Publish | |
- name: ZIP development libs | |
working-directory: src/c-lib/build/library/Win32/Release | |
run: | | |
7z a gs1encoders-windows-libs.zip gs1encoders.h gs1encoders.lib gs1encoders.dll ../../../../gs1-syntax-dictionary.txt | |
- name: Store Windows development libs | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-libs | |
path: src/c-lib/build/library/Win32/Release/gs1encoders-windows-libs.zip | |
- name: ZIP console application | |
working-directory: src/c-lib/build/console-app/Win32/Release | |
run: | | |
7z a gs1encoders-windows-console-app.zip gs1encoders-app.exe gs1encoders.dll ../../../../gs1-syntax-dictionary.txt | |
- name: Store Windows console app | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-console-app | |
path: src/c-lib/build/console-app/Win32/Release/gs1encoders-windows-console-app.zip | |
- name: ZIP GUI application | |
working-directory: src/dotnet-app/bin/Release\netcoreapp3.1\win-x86\publish | |
run: | | |
7z a gs1encoders-windows-gui-app.zip gs1encoders-dotnet-app.exe ../../gs1encoders.dll ../../../../../../c-lib/gs1-syntax-dictionary.txt | |
- name: Store Windows GUI app | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-gui-app | |
path: src/dotnet-app/bin/Release/netcoreapp3.1/win-x86/publish/gs1encoders-windows-gui-app.zip | |
build-release-linux: | |
needs: | |
- ci-gcc | |
- ci-clang | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Linux release build | |
run: | | |
make -C src/c-lib -j `nproc` CC=clang | |
src/c-lib/build/gs1encoders-linux.bin --version | |
cp src/c-lib/gs1-syntax-dictionary.txt src/c-lib/build/ | |
cd src/c-lib/build | |
tar cvzf gs1encoders-linux-app.tgz gs1encoders-linux.bin gs1-syntax-dictionary.txt | |
- name: Store Linux build | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-app | |
path: src/c-lib/build/gs1encoders-linux-app.tgz | |
build-release-wasm: | |
needs: | |
- ci-wasm | |
runs-on: ubuntu-latest | |
steps: | |
- uses: mymindstorm/setup-emsdk@v14 | |
- uses: actions/checkout@v4 | |
- name: WASM release build | |
run: | | |
make -C src/c-lib -j `nproc` wasm | |
cd src/js-wasm | |
tar cvzf gs1encoders-wasm-app.tgz gs1encoder-wasm.wasm gs1encoder-wasm.mjs gs1encoder.mjs example.html example.mjs example.node.mjs | |
- name: Store WASM build | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wasm-app | |
path: src/js-wasm/gs1encoders-wasm-app.tgz | |
build-release-jsonly: | |
needs: | |
- ci-jsonly | |
runs-on: ubuntu-latest | |
steps: | |
- uses: mymindstorm/setup-emsdk@v14 | |
- uses: actions/checkout@v4 | |
- name: JSONLY release build | |
run: | | |
make -C src/c-lib -j `nproc` wasm JSONLY=yes | |
cd src/js-wasm | |
tar cvzf gs1encoders-jsonly-app.tgz gs1encoder-wasm.mjs gs1encoder.mjs example.html example.mjs example.node.mjs | |
- name: Store JSONLY build | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jsonly-app | |
path: src/js-wasm/gs1encoders-jsonly-app.tgz | |
# | |
# Create release and upload artifacts | |
# | |
create-release: | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
needs: | |
- ci-gcc | |
- ci-clang | |
- ci-msvc | |
- ci-macos | |
- ci-scan-build | |
- ci-java | |
- ci-wasm | |
- ci-jsonly | |
- ci-ios-app | |
- ci-android-app | |
- build-release-linux | |
- build-release-windows | |
- build-release-wasm | |
- build-release-jsonly | |
steps: | |
- name: Load Windows libs | |
uses: actions/download-artifact@v4 | |
with: | |
name: windows-libs | |
- name: Load Windows console app | |
uses: actions/download-artifact@v4 | |
with: | |
name: windows-console-app | |
- name: Load Windows GUI app | |
uses: actions/download-artifact@v4 | |
with: | |
name: windows-gui-app | |
- name: Load Linux app | |
uses: actions/download-artifact@v4 | |
with: | |
name: linux-app | |
- name: Load WASM app | |
uses: actions/download-artifact@v4 | |
with: | |
name: wasm-app | |
- name: Load JSONLY app | |
uses: actions/download-artifact@v4 | |
with: | |
name: jsonly-app | |
- name: Get version | |
id: get_version | |
run: | | |
VERSION=${GITHUB_REF/refs\/tags\//} | |
echo ::set-output name=VERSION::$VERSION | |
- name: Create GitHub release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.VERSION }} | |
release_name: ${{ steps.get_version.outputs.VERSION }} | |
draft: false | |
prerelease: false | |
- name: "Upload asset: Windows development libs" | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: gs1encoders-windows-libs.zip | |
asset_name: gs1encoders-windows-libs.zip | |
asset_content_type: application/zip | |
- name: "Upload asset: Windows console application" | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: gs1encoders-windows-console-app.zip | |
asset_name: gs1encoders-windows-console-app.zip | |
asset_content_type: application/zip | |
- name: "Upload asset: Windows GUI application" | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: gs1encoders-windows-gui-app.zip | |
asset_name: gs1encoders-windows-gui-app.zip | |
asset_content_type: application/zip | |
- name: "Upload asset: Linux application" | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: gs1encoders-linux-app.tgz | |
asset_name: gs1encoders-linux-app.tgz | |
asset_content_type: application/octet-stream | |
- name: "Upload asset: WASM applications (browser and Node.js)" | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: gs1encoders-wasm-app.tgz | |
asset_name: gs1encoders-wasm-app.tgz | |
asset_content_type: application/octet-stream | |
- name: "Upload asset: JSONLY applications (browser and Node.js)" | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: gs1encoders-jsonly-app.tgz | |
asset_name: gs1encoders-jsonly-app.tgz | |
asset_content_type: application/octet-stream |