From d59d0a9530190eec61c1fa5e031c54ca63733b6b Mon Sep 17 00:00:00 2001 From: Joel Rudsberg Date: Mon, 2 Dec 2024 17:18:59 +0100 Subject: [PATCH] try to remove build step --- .github/workflows/test.yml | 822 ++++++++++++++++++------------------- dist/cleanup/index.js | 184 +++++---- dist/main/index.js | 184 +++++---- 3 files changed, 605 insertions(+), 585 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5537254..361389b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,411 +12,411 @@ permissions: contents: read jobs: - build: # make sure build/ci work properly - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: | - npm install - - run: | - npm run all - test: - name: GraalVM - runs-on: ${{ matrix.os }} - strategy: - matrix: - java-version: ['23', '21', '17', '20', 'dev'] - distribution: ['graalvm', 'graalvm-community'] - os: [ - ubuntu-latest, - macos-latest, # macOS on Apple silicon - macos-13, # macOS on Intel - windows-latest - ] - set-gds-token: [false] - components: [''] - include: - - java-version: 'latest-ea' - distribution: 'graalvm' - os: ubuntu-latest - - java-version: '24-ea' - distribution: 'graalvm' - os: ubuntu-latest - - java-version: '21' - distribution: '' - os: ubuntu-latest - - java-version: 'dev' - distribution: '' - os: windows-latest - - java-version: '21' - distribution: 'graalvm-community' - os: ubuntu-latest - components: 'native-image' # should print a warning but not fail - - java-version: '21.0.0' # test for GA version (see #63) - distribution: 'graalvm' - os: ubuntu-latest - - java-version: '17' - distribution: 'graalvm' - os: ubuntu-latest - set-gds-token: true - - java-version: '17.0.13' - distribution: 'graalvm' - os: ubuntu-latest - set-gds-token: true - steps: - - uses: actions/checkout@v4 - - name: Run setup-graalvm action - uses: ./ - with: - java-version: ${{ matrix.java-version }} - distribution: ${{ matrix.distribution }} - github-token: ${{ secrets.GITHUB_TOKEN }} - components: ${{ matrix.components }} - gds-token: ${{ matrix.set-gds-token && secrets.GDS_TOKEN || '' }} - - name: Check environment - run: | - echo "GRAALVM_HOME: $GRAALVM_HOME" - if [[ "${{ matrix.java-version }}" == "dev" ]]; then - [[ "$GRAALVM_HOME" == *"$RUNNER_TEMP"* ]] || exit 12 - else - [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23 - fi - echo "JAVA_HOME: $JAVA_HOME" - java --version - java --version | grep "GraalVM" || exit 34 - native-image --version - if: runner.os != 'Windows' - - name: Check Windows environment - run: | - echo "GRAALVM_HOME: $env:GRAALVM_HOME" - echo "JAVA_HOME: $env:JAVA_HOME" - java --version - native-image --version - test-ce: # make sure the action works on a clean machine without building - needs: test - name: CE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - version: ['latest', 'dev'] - java-version: ['17', '20'] - components: ['native-image'] - os: [macos-latest, windows-latest, ubuntu-latest] - exclude: - - version: 'latest' - java-version: '20' - - version: 'dev' - java-version: '19' - include: - - version: '22.2.0' # for update notifications - java-version: '17' - components: 'native-image' - os: ubuntu-20.04 - - version: '21.2.0' - java-version: '8' # for JDK 8 notification - components: 'native-image' - os: ubuntu-latest - - version: '22.3.1' - java-version: '11' # for JDK 11 notification - components: 'native-image' - os: macos-13 - - version: '22.3.1' - java-version: '17' - components: 'native-image' - os: windows-2022 - - version: 'dev' - java-version: 'dev' - components: 'native-image' - os: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Run setup-graalvm action - uses: ./ - with: - version: ${{ matrix.version }} - java-version: ${{ matrix.java-version }} - components: ${{ matrix.components }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check environment - run: | - echo "GRAALVM_HOME: $GRAALVM_HOME" - if [[ "${{ matrix.version }}" == "dev" ]] && [[ "${{ matrix.java-version }}" == "dev" ]]; then - [[ "$GRAALVM_HOME" == *"$RUNNER_TEMP"* ]] || exit 12 - else - [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23 - fi - echo "JAVA_HOME: $JAVA_HOME" - java -version - java -version 2>&1 | grep "GraalVM" || exit 34 - native-image --version - if [[ "${{ matrix.java-version }}" != "dev" ]]; then - gu list - fi - if: runner.os != 'Windows' - - name: Check Windows environment - run: | - echo "GRAALVM_HOME: $env:GRAALVM_HOME" - echo "JAVA_HOME: $env:JAVA_HOME" - java -version - native-image --version - gu.cmd remove native-image - if: runner.os == 'Windows' - test-ee: - needs: test - name: EE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }} - if: github.event_name != 'pull_request' - runs-on: ${{ matrix.os }} - strategy: - matrix: - version: ['latest'] - java-version: ['17'] - components: ['native-image'] - os: [macos-latest, windows-latest, ubuntu-latest] - include: - - version: '22.3.3' - java-version: '11' - components: 'native-image' - os: ubuntu-latest - - version: '22.3.3' - java-version: '17' - components: 'native-image' - os: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Run setup-graalvm action - uses: ./ - with: - version: ${{ matrix.version }} - gds-token: ${{ secrets.GDS_TOKEN }} - java-version: ${{ matrix.java-version }} - components: ${{ matrix.components }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check environment - run: | - echo "GRAALVM_HOME: $GRAALVM_HOME" - [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12 - echo "JAVA_HOME: $JAVA_HOME" - java --version - java --version | grep -e "GraalVM EE" -e "Oracle GraalVM" || exit 23 - native-image --version - gu list - if: runner.os != 'Windows' - - name: Check Windows environment - run: | - echo "GRAALVM_HOME: $env:GRAALVM_HOME" - echo "JAVA_HOME: $env:JAVA_HOME" - java --version - native-image --version - gu.cmd remove native-image - if: runner.os == 'Windows' - test-mandrel: - needs: test - name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - version: ['mandrel-22.2.0.0-Final', '23.0.1.2-Final', 'mandrel-latest'] - java-version: ['17'] - distribution: ['mandrel'] - os: [windows-latest, ubuntu-latest] - include: - - version: 'mandrel-latest' - java-version: '17' - distribution: '' # test empty distribution for backward compatibility - os: ubuntu-latest - - version: '' # test with no version - java-version: '21' - distribution: 'mandrel' - os: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Run setup-graalvm action - uses: ./ - with: - version: ${{ matrix.version }} - distribution: ${{ matrix.distribution }} - java-version: ${{ matrix.java-version }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check environment - run: | - echo "GRAALVM_HOME: $GRAALVM_HOME" - [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12 - echo "JAVA_HOME: $JAVA_HOME" - java --version - java --version | grep "Temurin" || exit 23 - native-image --version - if: runner.os != 'Windows' - - name: Check Windows environment - run: | - echo "GRAALVM_HOME: $env:GRAALVM_HOME" - echo "JAVA_HOME: $env:JAVA_HOME" - java --version - native-image --version - if: runner.os == 'Windows' - test-liberica: - needs: test - name: Liberica (${{ matrix.java-version }}, '${{ matrix.java-package }}', ${{ matrix.os }}) - runs-on: ${{ matrix.os }} - strategy: - matrix: - java-version: ['17', '21.0.2'] - java-package: ['', 'jdk', 'jdk+fx'] - os: [ubuntu-latest, macos-latest, windows-latest] - steps: - - uses: actions/checkout@v4 - - name: Run setup-graalvm action - uses: ./ - with: - distribution: liberica - java-version: ${{ matrix.java-version }} - java-package: ${{ matrix.java-package }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check environment - run: | - echo "GRAALVM_HOME: $GRAALVM_HOME" - [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12 - echo "JAVA_HOME: $JAVA_HOME" - java --version - java --version | fgrep -qw ${{ matrix.java-version }} || exit 23 - native-image --version - native-image --version | fgrep -qw ${{ matrix.java-version }} || exit 24 - if: runner.os != 'Windows' - - name: Check Windows environment - shell: pwsh - run: | - echo "GRAALVM_HOME: $env:GRAALVM_HOME" - echo "JAVA_HOME: $env:JAVA_HOME" - java --version - if (!(java --version | findstr \<${{ matrix.java-version }}\>)) { - exit 23 - } - native-image --version - if (!(native-image --version | findstr \<${{ matrix.java-version }}\>)) { - exit 24 - } - if: runner.os == 'Windows' - test-native-image-windows: - name: native-image on windows-latest - runs-on: windows-latest - permissions: - contents: read - pull-requests: write # for `native-image-pr-reports` option - steps: - - uses: actions/checkout@v4 - - name: Run setup-graalvm action - uses: ./ - with: - java-version: 'dev' - distribution: 'graalvm-community' - native-image-job-reports: 'true' - native-image-pr-reports: 'true' - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Build HelloWorld executable with GraalVM Native Image on Windows - run: | - echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java - javac HelloWorld.java - native-image HelloWorld - ./helloworld - test-native-image-windows-msvc: - name: native-image on windows-2022 - runs-on: windows-2022 - permissions: - contents: read - pull-requests: write # for `native-image-pr-reports` option - steps: - - uses: actions/checkout@v4 - - name: Run setup-graalvm action - uses: ./ - with: - java-version: '17' - distribution: 'graalvm' - native-image-job-reports: 'true' - native-image-pr-reports: 'true' - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Build HelloWorld executable with GraalVM Native Image on Windows - run: | - echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java - javac HelloWorld.java - native-image HelloWorld - ./helloworld - test-native-image-musl: - name: native-image-musl on ubuntu-latest - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write # for `native-image-pr-reports` option - steps: - - uses: actions/checkout@v4 - - name: Run setup-graalvm action - uses: ./ - with: - java-version: 'dev' - distribution: 'graalvm-community' - native-image-musl: 'true' - native-image-job-reports: 'true' - native-image-pr-reports: 'true' - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Build static HelloWorld executable with GraalVM Native Image and musl - run: | - echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java - javac HelloWorld.java - native-image --static --libc=musl HelloWorld - ./helloworld - test-extensive: - name: extensive tests on ubuntu-latest - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write # for `native-image-pr-reports` option - steps: - - uses: actions/checkout@v4 - - name: Run setup-graalvm action - uses: ./ - with: - java-version: '17.0.8' - distribution: 'graalvm' - components: 'espresso,llvm-toolchain,native-image,nodejs,python,ruby,wasm' - set-java-home: 'false' - native-image-job-reports: 'true' - native-image-pr-reports: 'true' - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check environment - run: | - echo "GRAALVM_HOME: $GRAALVM_HOME" - echo "JAVA_HOME: $JAVA_HOME" - [[ "$GRAALVM_HOME" != "$JAVA_HOME" ]] || exit 12 - [[ $(which java) == *"graalvm"* ]] || exit 23 - java --version - java -truffle --version - gu --version - gu list - [[ $(which lli) == *"graalvm"* ]] || exit 34 - lli --version - native-image --version - [[ $(which node) == *"graalvm"* ]] || exit 45 - node --version - graalpy --version - truffleruby --version - wasm --version - - name: Build HelloWorld.java with GraalVM Native Image - run: | - echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java - javac HelloWorld.java - native-image -g HelloWorld - ./helloworld - # - name: Build Ruby-FFI with TruffleRuby - # run: | - # [[ $(which bundle) == *"graalvm"* ]] || exit 57 - # git clone --depth 1 https://github.com/ffi/ffi.git - # pushd ffi > /dev/null - # # https://github.com/ffi/ffi/blob/447845cb3030194c79700c86fb388a12e6f81386/.github/workflows/ci.yml#L58-L62 - # bundle install - # bundle exec rake libffi - # bundle exec rake compile - # bundle exec rake test - # popd > /dev/null - - name: Remove components - run: gu remove espresso llvm-toolchain nodejs python ruby wasm + # build: # make sure build/ci work properly + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - run: | + # npm install + # - run: | + # npm run all + # test: + # name: GraalVM + # runs-on: ${{ matrix.os }} + # strategy: + # matrix: + # java-version: ['23', '21', '17', '20', 'dev'] + # distribution: ['graalvm', 'graalvm-community'] + # os: [ + # ubuntu-latest, + # macos-latest, # macOS on Apple silicon + # macos-13, # macOS on Intel + # windows-latest + # ] + # set-gds-token: [false] + # components: [''] + # include: + # - java-version: 'latest-ea' + # distribution: 'graalvm' + # os: ubuntu-latest + # - java-version: '24-ea' + # distribution: 'graalvm' + # os: ubuntu-latest + # - java-version: '21' + # distribution: '' + # os: ubuntu-latest + # - java-version: 'dev' + # distribution: '' + # os: windows-latest + # - java-version: '21' + # distribution: 'graalvm-community' + # os: ubuntu-latest + # components: 'native-image' # should print a warning but not fail + # - java-version: '21.0.0' # test for GA version (see #63) + # distribution: 'graalvm' + # os: ubuntu-latest + # - java-version: '17' + # distribution: 'graalvm' + # os: ubuntu-latest + # set-gds-token: true + # - java-version: '17.0.13' + # distribution: 'graalvm' + # os: ubuntu-latest + # set-gds-token: true + # steps: + # - uses: actions/checkout@v4 + # - name: Run setup-graalvm action + # uses: ./ + # with: + # java-version: ${{ matrix.java-version }} + # distribution: ${{ matrix.distribution }} + # github-token: ${{ secrets.GITHUB_TOKEN }} + # components: ${{ matrix.components }} + # gds-token: ${{ matrix.set-gds-token && secrets.GDS_TOKEN || '' }} + # - name: Check environment + # run: | + # echo "GRAALVM_HOME: $GRAALVM_HOME" + # if [[ "${{ matrix.java-version }}" == "dev" ]]; then + # [[ "$GRAALVM_HOME" == *"$RUNNER_TEMP"* ]] || exit 12 + # else + # [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23 + # fi + # echo "JAVA_HOME: $JAVA_HOME" + # java --version + # java --version | grep "GraalVM" || exit 34 + # native-image --version + # if: runner.os != 'Windows' + # - name: Check Windows environment + # run: | + # echo "GRAALVM_HOME: $env:GRAALVM_HOME" + # echo "JAVA_HOME: $env:JAVA_HOME" + # java --version + # native-image --version + # test-ce: # make sure the action works on a clean machine without building + # needs: test + # name: CE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }} + # runs-on: ${{ matrix.os }} + # strategy: + # matrix: + # version: ['latest', 'dev'] + # java-version: ['17', '20'] + # components: ['native-image'] + # os: [macos-latest, windows-latest, ubuntu-latest] + # exclude: + # - version: 'latest' + # java-version: '20' + # - version: 'dev' + # java-version: '19' + # include: + # - version: '22.2.0' # for update notifications + # java-version: '17' + # components: 'native-image' + # os: ubuntu-20.04 + # - version: '21.2.0' + # java-version: '8' # for JDK 8 notification + # components: 'native-image' + # os: ubuntu-latest + # - version: '22.3.1' + # java-version: '11' # for JDK 11 notification + # components: 'native-image' + # os: macos-13 + # - version: '22.3.1' + # java-version: '17' + # components: 'native-image' + # os: windows-2022 + # - version: 'dev' + # java-version: 'dev' + # components: 'native-image' + # os: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - name: Run setup-graalvm action + # uses: ./ + # with: + # version: ${{ matrix.version }} + # java-version: ${{ matrix.java-version }} + # components: ${{ matrix.components }} + # github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Check environment + # run: | + # echo "GRAALVM_HOME: $GRAALVM_HOME" + # if [[ "${{ matrix.version }}" == "dev" ]] && [[ "${{ matrix.java-version }}" == "dev" ]]; then + # [[ "$GRAALVM_HOME" == *"$RUNNER_TEMP"* ]] || exit 12 + # else + # [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23 + # fi + # echo "JAVA_HOME: $JAVA_HOME" + # java -version + # java -version 2>&1 | grep "GraalVM" || exit 34 + # native-image --version + # if [[ "${{ matrix.java-version }}" != "dev" ]]; then + # gu list + # fi + # if: runner.os != 'Windows' + # - name: Check Windows environment + # run: | + # echo "GRAALVM_HOME: $env:GRAALVM_HOME" + # echo "JAVA_HOME: $env:JAVA_HOME" + # java -version + # native-image --version + # gu.cmd remove native-image + # if: runner.os == 'Windows' + # test-ee: + # needs: test + # name: EE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }} + # if: github.event_name != 'pull_request' + # runs-on: ${{ matrix.os }} + # strategy: + # matrix: + # version: ['latest'] + # java-version: ['17'] + # components: ['native-image'] + # os: [macos-latest, windows-latest, ubuntu-latest] + # include: + # - version: '22.3.3' + # java-version: '11' + # components: 'native-image' + # os: ubuntu-latest + # - version: '22.3.3' + # java-version: '17' + # components: 'native-image' + # os: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - name: Run setup-graalvm action + # uses: ./ + # with: + # version: ${{ matrix.version }} + # gds-token: ${{ secrets.GDS_TOKEN }} + # java-version: ${{ matrix.java-version }} + # components: ${{ matrix.components }} + # github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Check environment + # run: | + # echo "GRAALVM_HOME: $GRAALVM_HOME" + # [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12 + # echo "JAVA_HOME: $JAVA_HOME" + # java --version + # java --version | grep -e "GraalVM EE" -e "Oracle GraalVM" || exit 23 + # native-image --version + # gu list + # if: runner.os != 'Windows' + # - name: Check Windows environment + # run: | + # echo "GRAALVM_HOME: $env:GRAALVM_HOME" + # echo "JAVA_HOME: $env:JAVA_HOME" + # java --version + # native-image --version + # gu.cmd remove native-image + # if: runner.os == 'Windows' + # test-mandrel: + # needs: test + # name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }} + # runs-on: ${{ matrix.os }} + # strategy: + # matrix: + # version: ['mandrel-22.2.0.0-Final', '23.0.1.2-Final', 'mandrel-latest'] + # java-version: ['17'] + # distribution: ['mandrel'] + # os: [windows-latest, ubuntu-latest] + # include: + # - version: 'mandrel-latest' + # java-version: '17' + # distribution: '' # test empty distribution for backward compatibility + # os: ubuntu-latest + # - version: '' # test with no version + # java-version: '21' + # distribution: 'mandrel' + # os: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - name: Run setup-graalvm action + # uses: ./ + # with: + # version: ${{ matrix.version }} + # distribution: ${{ matrix.distribution }} + # java-version: ${{ matrix.java-version }} + # github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Check environment + # run: | + # echo "GRAALVM_HOME: $GRAALVM_HOME" + # [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12 + # echo "JAVA_HOME: $JAVA_HOME" + # java --version + # java --version | grep "Temurin" || exit 23 + # native-image --version + # if: runner.os != 'Windows' + # - name: Check Windows environment + # run: | + # echo "GRAALVM_HOME: $env:GRAALVM_HOME" + # echo "JAVA_HOME: $env:JAVA_HOME" + # java --version + # native-image --version + # if: runner.os == 'Windows' + # test-liberica: + # needs: test + # name: Liberica (${{ matrix.java-version }}, '${{ matrix.java-package }}', ${{ matrix.os }}) + # runs-on: ${{ matrix.os }} + # strategy: + # matrix: + # java-version: ['17', '21.0.2'] + # java-package: ['', 'jdk', 'jdk+fx'] + # os: [ubuntu-latest, macos-latest, windows-latest] + # steps: + # - uses: actions/checkout@v4 + # - name: Run setup-graalvm action + # uses: ./ + # with: + # distribution: liberica + # java-version: ${{ matrix.java-version }} + # java-package: ${{ matrix.java-package }} + # github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Check environment + # run: | + # echo "GRAALVM_HOME: $GRAALVM_HOME" + # [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12 + # echo "JAVA_HOME: $JAVA_HOME" + # java --version + # java --version | fgrep -qw ${{ matrix.java-version }} || exit 23 + # native-image --version + # native-image --version | fgrep -qw ${{ matrix.java-version }} || exit 24 + # if: runner.os != 'Windows' + # - name: Check Windows environment + # shell: pwsh + # run: | + # echo "GRAALVM_HOME: $env:GRAALVM_HOME" + # echo "JAVA_HOME: $env:JAVA_HOME" + # java --version + # if (!(java --version | findstr \<${{ matrix.java-version }}\>)) { + # exit 23 + # } + # native-image --version + # if (!(native-image --version | findstr \<${{ matrix.java-version }}\>)) { + # exit 24 + # } + # if: runner.os == 'Windows' + # test-native-image-windows: + # name: native-image on windows-latest + # runs-on: windows-latest + # permissions: + # contents: read + # pull-requests: write # for `native-image-pr-reports` option + # steps: + # - uses: actions/checkout@v4 + # - name: Run setup-graalvm action + # uses: ./ + # with: + # java-version: 'dev' + # distribution: 'graalvm-community' + # native-image-job-reports: 'true' + # native-image-pr-reports: 'true' + # github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Build HelloWorld executable with GraalVM Native Image on Windows + # run: | + # echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java + # javac HelloWorld.java + # native-image HelloWorld + # ./helloworld + # test-native-image-windows-msvc: + # name: native-image on windows-2022 + # runs-on: windows-2022 + # permissions: + # contents: read + # pull-requests: write # for `native-image-pr-reports` option + # steps: + # - uses: actions/checkout@v4 + # - name: Run setup-graalvm action + # uses: ./ + # with: + # java-version: '17' + # distribution: 'graalvm' + # native-image-job-reports: 'true' + # native-image-pr-reports: 'true' + # github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Build HelloWorld executable with GraalVM Native Image on Windows + # run: | + # echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java + # javac HelloWorld.java + # native-image HelloWorld + # ./helloworld + # test-native-image-musl: + # name: native-image-musl on ubuntu-latest + # runs-on: ubuntu-latest + # permissions: + # contents: read + # pull-requests: write # for `native-image-pr-reports` option + # steps: + # - uses: actions/checkout@v4 + # - name: Run setup-graalvm action + # uses: ./ + # with: + # java-version: 'dev' + # distribution: 'graalvm-community' + # native-image-musl: 'true' + # native-image-job-reports: 'true' + # native-image-pr-reports: 'true' + # github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Build static HelloWorld executable with GraalVM Native Image and musl + # run: | + # echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java + # javac HelloWorld.java + # native-image --static --libc=musl HelloWorld + # ./helloworld + # test-extensive: + # name: extensive tests on ubuntu-latest + # runs-on: ubuntu-latest + # permissions: + # contents: read + # pull-requests: write # for `native-image-pr-reports` option + # steps: + # - uses: actions/checkout@v4 + # - name: Run setup-graalvm action + # uses: ./ + # with: + # java-version: '17.0.8' + # distribution: 'graalvm' + # components: 'espresso,llvm-toolchain,native-image,nodejs,python,ruby,wasm' + # set-java-home: 'false' + # native-image-job-reports: 'true' + # native-image-pr-reports: 'true' + # github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Check environment + # run: | + # echo "GRAALVM_HOME: $GRAALVM_HOME" + # echo "JAVA_HOME: $JAVA_HOME" + # [[ "$GRAALVM_HOME" != "$JAVA_HOME" ]] || exit 12 + # [[ $(which java) == *"graalvm"* ]] || exit 23 + # java --version + # java -truffle --version + # gu --version + # gu list + # [[ $(which lli) == *"graalvm"* ]] || exit 34 + # lli --version + # native-image --version + # [[ $(which node) == *"graalvm"* ]] || exit 45 + # node --version + # graalpy --version + # truffleruby --version + # wasm --version + # - name: Build HelloWorld.java with GraalVM Native Image + # run: | + # echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java + # javac HelloWorld.java + # native-image -g HelloWorld + # ./helloworld + # # - name: Build Ruby-FFI with TruffleRuby + # # run: | + # # [[ $(which bundle) == *"graalvm"* ]] || exit 57 + # # git clone --depth 1 https://github.com/ffi/ffi.git + # # pushd ffi > /dev/null + # # # https://github.com/ffi/ffi/blob/447845cb3030194c79700c86fb388a12e6f81386/.github/workflows/ci.yml#L58-L62 + # # bundle install + # # bundle exec rake libffi + # # bundle exec rake compile + # # bundle exec rake test + # # popd > /dev/null + # - name: Remove components + # run: gu remove espresso llvm-toolchain nodejs python ruby wasm test-sbom: name: test 'native-image-enable-sbom' option runs-on: ${{ matrix.os }} @@ -424,14 +424,14 @@ jobs: contents: write strategy: matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + os: [macos-latest] # ubuntu-latest, windows-latest steps: - uses: actions/checkout@v4 - - name: Build action - run: | - npm install - npm run build - npm run package + - name: Run setup-graalvm action + # run: | + # npm install + # npm run build + # npm run package - uses: ./ with: java-version: 'latest-ea' diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 25585f6..928cbba 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -90425,7 +90425,7 @@ else { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.ERROR_HINT = exports.ERROR_REQUEST = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_LIBERICA = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = exports.ACTION_VERSION = void 0; +exports.ERROR_HINT = exports.ERROR_REQUEST = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_LIBERICA = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.NATIVE_IMAGE_OPTIONS_ENV = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = exports.ACTION_VERSION = void 0; exports.ACTION_VERSION = '1.2.6'; exports.INPUT_VERSION = 'version'; exports.INPUT_GDS_TOKEN = 'gds-token'; @@ -90438,6 +90438,7 @@ exports.INPUT_SET_JAVA_HOME = 'set-java-home'; exports.INPUT_CACHE = 'cache'; exports.INPUT_CHECK_FOR_UPDATES = 'check-for-updates'; exports.INPUT_NI_MUSL = 'native-image-musl'; +exports.NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS'; exports.IS_LINUX = process.platform === 'linux'; exports.IS_MACOS = process.platform === 'darwin'; exports.IS_WINDOWS = process.platform === 'win32'; @@ -90813,7 +90814,6 @@ const INPUT_NI_JOB_REPORTS = 'native-image-job-reports'; const INPUT_NI_PR_REPORTS = 'native-image-pr-reports'; const INPUT_NI_PR_REPORTS_UPDATE = 'native-image-pr-reports-update-existing'; const NATIVE_IMAGE_CONFIG_FILE = (0, path_1.join)((0, os_1.tmpdir)(), 'native-image-options.properties'); -const NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS'; const NATIVE_IMAGE_CONFIG_FILE_ENV = 'NATIVE_IMAGE_CONFIG_FILE'; const PR_COMMENT_TITLE = '## GraalVM Native Image Build Report'; function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, javaVersionOrDev, graalVMVersion) { @@ -90879,11 +90879,11 @@ function setNativeImageOption(javaVersionOrDev, optionValue) { javaVersionOrDev.endsWith('-ea')) { /* NATIVE_IMAGE_OPTIONS was introduced in GraalVM for JDK 22 (so were EA builds). */ let newOptionValue = optionValue; - const existingOptions = process.env[NATIVE_IMAGE_OPTIONS_ENV]; + const existingOptions = process.env[c.NATIVE_IMAGE_OPTIONS_ENV]; if (existingOptions) { newOptionValue = `${existingOptions} ${newOptionValue}`; } - core.exportVariable(NATIVE_IMAGE_OPTIONS_ENV, newOptionValue); + core.exportVariable(c.NATIVE_IMAGE_OPTIONS_ENV, newOptionValue); } else { const optionsFile = getNativeImageOptionsFile(); @@ -91180,79 +91180,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.SBOM_FILE_SUFFIX = exports.NATIVE_IMAGE_OPTIONS_ENV = exports.INPUT_NI_SBOM = void 0; +exports.SBOM_FILE_SUFFIX = exports.INPUT_NI_SBOM = void 0; exports.setUpSBOMSupport = setUpSBOMSupport; exports.processSBOM = processSBOM; -exports.convertSBOMDependencies = convertSBOMDependencies; +exports.mapToComponentsWithDependencies = mapToComponentsWithDependencies; +const c = __importStar(__nccwpck_require__(9042)); const core = __importStar(__nccwpck_require__(2186)); const fs = __importStar(__nccwpck_require__(7147)); const github = __importStar(__nccwpck_require__(5438)); const glob = __importStar(__nccwpck_require__(8090)); -const constants_1 = __nccwpck_require__(9042); const path_1 = __nccwpck_require__(1017); exports.INPUT_NI_SBOM = 'native-image-enable-sbom'; -exports.NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS'; exports.SBOM_FILE_SUFFIX = '.sbom.json'; function setUpSBOMSupport() { const isSbomEnabled = core.getInput(exports.INPUT_NI_SBOM) === 'true'; if (!isSbomEnabled) { return; } - let options = process.env[exports.NATIVE_IMAGE_OPTIONS_ENV] || ''; + let options = process.env[c.NATIVE_IMAGE_OPTIONS_ENV] || ''; if (options.length > 0) { options += ' '; } options += '--enable-sbom=export'; - core.exportVariable(exports.NATIVE_IMAGE_OPTIONS_ENV, options); + core.exportVariable(c.NATIVE_IMAGE_OPTIONS_ENV, options); core.info('Enabled SBOM generation for Native Image builds'); } -/** - * Finds a single SBOM file in the build directory - * @returns Path to the SBOM file or null if not found or multiple files exist - */ -function findSBOMFilePath() { - return __awaiter(this, void 0, void 0, function* () { - const globber = yield glob.create(`**/*${exports.SBOM_FILE_SUFFIX}`); - const sbomFiles = yield globber.glob(); - if (sbomFiles.length === 0) { - core.warning('No SBOM file found. Make sure native-image build completed successfully.'); - return null; - } - if (sbomFiles.length > 1) { - core.warning(`Found multiple SBOM files: ${sbomFiles.join(', ')}. ` + - 'Expected exactly one SBOM file. Skipping SBOM processing.'); - return null; - } - core.info(`Found SBOM file: ${sbomFiles[0]}`); - return sbomFiles[0]; - }); -} -function processSBOMComponents(sbomData, handler) { - if (!sbomData.components || !Array.isArray(sbomData.components)) { - core.info('No components found in SBOM'); - return []; - } - return sbomData.components - .filter((component) => component.name) - .map(handler); -} -function printSBOMContent(sbomData) { - core.info('=== SBOM Content ==='); - processSBOMComponents(sbomData, (component) => { - var _a; - const version = component.version || 'unknown'; - const purlMessage = component.purl - ? component.purl - : '(purl not specified, component will not be submitted to GitHub dependency API)'; - core.info(`- ${component.name}@${version} ${purlMessage}`); - if (((_a = component.dependencies) === null || _a === void 0 ? void 0 : _a.length) > 0) { - core.info(` Dependencies: ${component.dependencies.join(', ')}`); - } - // Just for type safety, not used - return undefined; - }); - core.info('=================='); -} function processSBOM() { return __awaiter(this, void 0, void 0, function* () { const isSbomEnabled = core.getInput(exports.INPUT_NI_SBOM) === 'true'; @@ -91265,9 +91217,16 @@ function processSBOM() { } try { const sbomContent = fs.readFileSync(sbomPath, 'utf8'); - const sbomData = JSON.parse(sbomContent); - printSBOMContent(sbomData); - const snapshot = convertSBOMToSnapshot(sbomPath, sbomData); + const sbomData = parseSBOM(sbomContent); + if (!sbomData) { + return; + } + const components = mapToComponentsWithDependencies(sbomData); + if (components.length === 0) { + return; + } + printSBOMContent(components); + const snapshot = convertSBOMToSnapshot(sbomPath, components); if (snapshot) { yield submitDependencySnapshot(snapshot); } @@ -91277,34 +91236,81 @@ function processSBOM() { } }); } -function convertSBOMDependencies(sbomData) { - const resolved = {}; - processSBOMComponents(sbomData, (component) => { - var _a; +function findSBOMFilePath() { + return __awaiter(this, void 0, void 0, function* () { + const globber = yield glob.create(`**/*${exports.SBOM_FILE_SUFFIX}`); + const sbomFiles = yield globber.glob(); + if (sbomFiles.length === 0) { + logSkippingSubmission('No SBOM file found. Make sure native-image build completed successfully.'); + return null; + } + if (sbomFiles.length > 1) { + logSkippingSubmission(`Found multiple SBOM files: ${sbomFiles.join(', ')}.`); + return null; + } + core.info(`Found SBOM file: ${sbomFiles[0]}`); + return sbomFiles[0]; + }); +} +function parseSBOM(jsonString) { + try { + const sbomData = JSON.parse(jsonString); + return sbomData; + } + catch (error) { + core.warning(`Failed to parse SBOM JSON: ${error instanceof Error ? error.message : String(error)}`); + return null; + } +} +// Maps the SBOM data to a list of components with their dependencies +function mapToComponentsWithDependencies(sbom) { + if (!sbom || sbom.components.length === 0) { + logSkippingSubmission('Invalid SBOM data or no components found.'); + return []; + } + return sbom.components.map((component) => { + var _a, _b; + const dependencies = ((_b = (_a = sbom.dependencies) === null || _a === void 0 ? void 0 : _a.find((dep) => dep.ref === component['bom-ref'])) === null || _b === void 0 ? void 0 : _b.dependsOn) || []; + return { + name: component.name, + version: component.version, + purl: component.purl, + dependencies, + 'bom-ref': component['bom-ref'] + }; + }); +} +function printSBOMContent(components) { + core.info('=== SBOM Content ==='); + for (const component of components) { + core.info(`- ${component['bom-ref']}`); + if (component.dependencies && component.dependencies.length > 0) { + core.info(` depends on: ${component.dependencies.join(', ')}`); + } + } + core.info('=================='); +} +function mapToSnapshotResolved(components) { + return Object.fromEntries(components + .filter(component => { if (!component.purl) { core.info(`Component ${component.name} does not have a valid package URL (purl). Skipping.`); - return; } - resolved[component.name] = { - package_url: component.purl - }; - if (((_a = component.dependencies) === null || _a === void 0 ? void 0 : _a.length) > 0) { - resolved[component.name].dependencies = component.dependencies; + return component.purl; + }) + .map(component => [ + component.name, + { + package_url: component.purl, + dependencies: component.dependencies || [] } - return resolved[component.name]; - }); - return resolved; + ])); } -function convertSBOMToSnapshot(sbomPath, sbomData) { +function convertSBOMToSnapshot(sbomPath, components) { const context = github.context; const sbomFileName = (0, path_1.basename)(sbomPath); if (!sbomFileName.endsWith(exports.SBOM_FILE_SUFFIX)) { - core.warning(`Invalid SBOM file name: ${sbomFileName}. Expected a file ending with ${exports.SBOM_FILE_SUFFIX}. Skipping submission.`); - return null; - } - const resolvedDependencies = convertSBOMDependencies(sbomData); - if (Object.keys(resolvedDependencies).length === 0) { - core.warning('No valid components found in SBOM. Skipping submission.'); + logSkippingSubmission(`Invalid SBOM file name: ${sbomFileName}. Expected a file ending with ${exports.SBOM_FILE_SUFFIX}.`); return null; } return { @@ -91318,24 +91324,25 @@ function convertSBOMToSnapshot(sbomPath, sbomData) { }, detector: { name: 'graalvm-native-image', - version: constants_1.ACTION_VERSION, + version: c.ACTION_VERSION, url: 'https://github.com/graalvm/setup-graalvm' }, scanned: new Date().toISOString(), manifests: { [sbomFileName]: { name: sbomFileName, - file: { - source_location: sbomPath - }, - resolved: resolvedDependencies + resolved: mapToSnapshotResolved(components), + metadata: { + generated_by: 'SBOM generated by GraalVM Native Image', + action_version: c.ACTION_VERSION + } } } }; } function submitDependencySnapshot(snapshotData) { return __awaiter(this, void 0, void 0, function* () { - const token = core.getInput(constants_1.INPUT_GITHUB_TOKEN, { required: true }); + const token = core.getInput(c.INPUT_GITHUB_TOKEN, { required: true }); const octokit = github.getOctokit(token); const context = github.context; try { @@ -91357,10 +91364,13 @@ function submitDependencySnapshot(snapshotData) { core.info('Dependency snapshot submitted successfully.'); } catch (error) { - core.warning(`Failed to submit dependency snapshot: ${error instanceof Error ? error.message : String(error)}`); + core.warning(`Failed to submit dependency snapshot for SBOM: ${error instanceof Error ? error.message : String(error)}`); } }); } +function logSkippingSubmission(prefix) { + core.warning(`${prefix} Skipping submission to GitHub Dependency API.`); +} /***/ }), diff --git a/dist/main/index.js b/dist/main/index.js index 71743b4..df8dcbb 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -90980,7 +90980,7 @@ function wrappy (fn, cb) { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.ERROR_HINT = exports.ERROR_REQUEST = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_LIBERICA = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = exports.ACTION_VERSION = void 0; +exports.ERROR_HINT = exports.ERROR_REQUEST = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_LIBERICA = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.NATIVE_IMAGE_OPTIONS_ENV = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = exports.ACTION_VERSION = void 0; exports.ACTION_VERSION = '1.2.6'; exports.INPUT_VERSION = 'version'; exports.INPUT_GDS_TOKEN = 'gds-token'; @@ -90993,6 +90993,7 @@ exports.INPUT_SET_JAVA_HOME = 'set-java-home'; exports.INPUT_CACHE = 'cache'; exports.INPUT_CHECK_FOR_UPDATES = 'check-for-updates'; exports.INPUT_NI_MUSL = 'native-image-musl'; +exports.NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS'; exports.IS_LINUX = process.platform === 'linux'; exports.IS_MACOS = process.platform === 'darwin'; exports.IS_WINDOWS = process.platform === 'win32'; @@ -91609,7 +91610,6 @@ const INPUT_NI_JOB_REPORTS = 'native-image-job-reports'; const INPUT_NI_PR_REPORTS = 'native-image-pr-reports'; const INPUT_NI_PR_REPORTS_UPDATE = 'native-image-pr-reports-update-existing'; const NATIVE_IMAGE_CONFIG_FILE = (0, path_1.join)((0, os_1.tmpdir)(), 'native-image-options.properties'); -const NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS'; const NATIVE_IMAGE_CONFIG_FILE_ENV = 'NATIVE_IMAGE_CONFIG_FILE'; const PR_COMMENT_TITLE = '## GraalVM Native Image Build Report'; function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, javaVersionOrDev, graalVMVersion) { @@ -91675,11 +91675,11 @@ function setNativeImageOption(javaVersionOrDev, optionValue) { javaVersionOrDev.endsWith('-ea')) { /* NATIVE_IMAGE_OPTIONS was introduced in GraalVM for JDK 22 (so were EA builds). */ let newOptionValue = optionValue; - const existingOptions = process.env[NATIVE_IMAGE_OPTIONS_ENV]; + const existingOptions = process.env[c.NATIVE_IMAGE_OPTIONS_ENV]; if (existingOptions) { newOptionValue = `${existingOptions} ${newOptionValue}`; } - core.exportVariable(NATIVE_IMAGE_OPTIONS_ENV, newOptionValue); + core.exportVariable(c.NATIVE_IMAGE_OPTIONS_ENV, newOptionValue); } else { const optionsFile = getNativeImageOptionsFile(); @@ -91976,79 +91976,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.SBOM_FILE_SUFFIX = exports.NATIVE_IMAGE_OPTIONS_ENV = exports.INPUT_NI_SBOM = void 0; +exports.SBOM_FILE_SUFFIX = exports.INPUT_NI_SBOM = void 0; exports.setUpSBOMSupport = setUpSBOMSupport; exports.processSBOM = processSBOM; -exports.convertSBOMDependencies = convertSBOMDependencies; +exports.mapToComponentsWithDependencies = mapToComponentsWithDependencies; +const c = __importStar(__nccwpck_require__(9042)); const core = __importStar(__nccwpck_require__(2186)); const fs = __importStar(__nccwpck_require__(7147)); const github = __importStar(__nccwpck_require__(5438)); const glob = __importStar(__nccwpck_require__(8090)); -const constants_1 = __nccwpck_require__(9042); const path_1 = __nccwpck_require__(1017); exports.INPUT_NI_SBOM = 'native-image-enable-sbom'; -exports.NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS'; exports.SBOM_FILE_SUFFIX = '.sbom.json'; function setUpSBOMSupport() { const isSbomEnabled = core.getInput(exports.INPUT_NI_SBOM) === 'true'; if (!isSbomEnabled) { return; } - let options = process.env[exports.NATIVE_IMAGE_OPTIONS_ENV] || ''; + let options = process.env[c.NATIVE_IMAGE_OPTIONS_ENV] || ''; if (options.length > 0) { options += ' '; } options += '--enable-sbom=export'; - core.exportVariable(exports.NATIVE_IMAGE_OPTIONS_ENV, options); + core.exportVariable(c.NATIVE_IMAGE_OPTIONS_ENV, options); core.info('Enabled SBOM generation for Native Image builds'); } -/** - * Finds a single SBOM file in the build directory - * @returns Path to the SBOM file or null if not found or multiple files exist - */ -function findSBOMFilePath() { - return __awaiter(this, void 0, void 0, function* () { - const globber = yield glob.create(`**/*${exports.SBOM_FILE_SUFFIX}`); - const sbomFiles = yield globber.glob(); - if (sbomFiles.length === 0) { - core.warning('No SBOM file found. Make sure native-image build completed successfully.'); - return null; - } - if (sbomFiles.length > 1) { - core.warning(`Found multiple SBOM files: ${sbomFiles.join(', ')}. ` + - 'Expected exactly one SBOM file. Skipping SBOM processing.'); - return null; - } - core.info(`Found SBOM file: ${sbomFiles[0]}`); - return sbomFiles[0]; - }); -} -function processSBOMComponents(sbomData, handler) { - if (!sbomData.components || !Array.isArray(sbomData.components)) { - core.info('No components found in SBOM'); - return []; - } - return sbomData.components - .filter((component) => component.name) - .map(handler); -} -function printSBOMContent(sbomData) { - core.info('=== SBOM Content ==='); - processSBOMComponents(sbomData, (component) => { - var _a; - const version = component.version || 'unknown'; - const purlMessage = component.purl - ? component.purl - : '(purl not specified, component will not be submitted to GitHub dependency API)'; - core.info(`- ${component.name}@${version} ${purlMessage}`); - if (((_a = component.dependencies) === null || _a === void 0 ? void 0 : _a.length) > 0) { - core.info(` Dependencies: ${component.dependencies.join(', ')}`); - } - // Just for type safety, not used - return undefined; - }); - core.info('=================='); -} function processSBOM() { return __awaiter(this, void 0, void 0, function* () { const isSbomEnabled = core.getInput(exports.INPUT_NI_SBOM) === 'true'; @@ -92061,9 +92013,16 @@ function processSBOM() { } try { const sbomContent = fs.readFileSync(sbomPath, 'utf8'); - const sbomData = JSON.parse(sbomContent); - printSBOMContent(sbomData); - const snapshot = convertSBOMToSnapshot(sbomPath, sbomData); + const sbomData = parseSBOM(sbomContent); + if (!sbomData) { + return; + } + const components = mapToComponentsWithDependencies(sbomData); + if (components.length === 0) { + return; + } + printSBOMContent(components); + const snapshot = convertSBOMToSnapshot(sbomPath, components); if (snapshot) { yield submitDependencySnapshot(snapshot); } @@ -92073,34 +92032,81 @@ function processSBOM() { } }); } -function convertSBOMDependencies(sbomData) { - const resolved = {}; - processSBOMComponents(sbomData, (component) => { - var _a; +function findSBOMFilePath() { + return __awaiter(this, void 0, void 0, function* () { + const globber = yield glob.create(`**/*${exports.SBOM_FILE_SUFFIX}`); + const sbomFiles = yield globber.glob(); + if (sbomFiles.length === 0) { + logSkippingSubmission('No SBOM file found. Make sure native-image build completed successfully.'); + return null; + } + if (sbomFiles.length > 1) { + logSkippingSubmission(`Found multiple SBOM files: ${sbomFiles.join(', ')}.`); + return null; + } + core.info(`Found SBOM file: ${sbomFiles[0]}`); + return sbomFiles[0]; + }); +} +function parseSBOM(jsonString) { + try { + const sbomData = JSON.parse(jsonString); + return sbomData; + } + catch (error) { + core.warning(`Failed to parse SBOM JSON: ${error instanceof Error ? error.message : String(error)}`); + return null; + } +} +// Maps the SBOM data to a list of components with their dependencies +function mapToComponentsWithDependencies(sbom) { + if (!sbom || sbom.components.length === 0) { + logSkippingSubmission('Invalid SBOM data or no components found.'); + return []; + } + return sbom.components.map((component) => { + var _a, _b; + const dependencies = ((_b = (_a = sbom.dependencies) === null || _a === void 0 ? void 0 : _a.find((dep) => dep.ref === component['bom-ref'])) === null || _b === void 0 ? void 0 : _b.dependsOn) || []; + return { + name: component.name, + version: component.version, + purl: component.purl, + dependencies, + 'bom-ref': component['bom-ref'] + }; + }); +} +function printSBOMContent(components) { + core.info('=== SBOM Content ==='); + for (const component of components) { + core.info(`- ${component['bom-ref']}`); + if (component.dependencies && component.dependencies.length > 0) { + core.info(` depends on: ${component.dependencies.join(', ')}`); + } + } + core.info('=================='); +} +function mapToSnapshotResolved(components) { + return Object.fromEntries(components + .filter(component => { if (!component.purl) { core.info(`Component ${component.name} does not have a valid package URL (purl). Skipping.`); - return; } - resolved[component.name] = { - package_url: component.purl - }; - if (((_a = component.dependencies) === null || _a === void 0 ? void 0 : _a.length) > 0) { - resolved[component.name].dependencies = component.dependencies; + return component.purl; + }) + .map(component => [ + component.name, + { + package_url: component.purl, + dependencies: component.dependencies || [] } - return resolved[component.name]; - }); - return resolved; + ])); } -function convertSBOMToSnapshot(sbomPath, sbomData) { +function convertSBOMToSnapshot(sbomPath, components) { const context = github.context; const sbomFileName = (0, path_1.basename)(sbomPath); if (!sbomFileName.endsWith(exports.SBOM_FILE_SUFFIX)) { - core.warning(`Invalid SBOM file name: ${sbomFileName}. Expected a file ending with ${exports.SBOM_FILE_SUFFIX}. Skipping submission.`); - return null; - } - const resolvedDependencies = convertSBOMDependencies(sbomData); - if (Object.keys(resolvedDependencies).length === 0) { - core.warning('No valid components found in SBOM. Skipping submission.'); + logSkippingSubmission(`Invalid SBOM file name: ${sbomFileName}. Expected a file ending with ${exports.SBOM_FILE_SUFFIX}.`); return null; } return { @@ -92114,24 +92120,25 @@ function convertSBOMToSnapshot(sbomPath, sbomData) { }, detector: { name: 'graalvm-native-image', - version: constants_1.ACTION_VERSION, + version: c.ACTION_VERSION, url: 'https://github.com/graalvm/setup-graalvm' }, scanned: new Date().toISOString(), manifests: { [sbomFileName]: { name: sbomFileName, - file: { - source_location: sbomPath - }, - resolved: resolvedDependencies + resolved: mapToSnapshotResolved(components), + metadata: { + generated_by: 'SBOM generated by GraalVM Native Image', + action_version: c.ACTION_VERSION + } } } }; } function submitDependencySnapshot(snapshotData) { return __awaiter(this, void 0, void 0, function* () { - const token = core.getInput(constants_1.INPUT_GITHUB_TOKEN, { required: true }); + const token = core.getInput(c.INPUT_GITHUB_TOKEN, { required: true }); const octokit = github.getOctokit(token); const context = github.context; try { @@ -92153,10 +92160,13 @@ function submitDependencySnapshot(snapshotData) { core.info('Dependency snapshot submitted successfully.'); } catch (error) { - core.warning(`Failed to submit dependency snapshot: ${error instanceof Error ? error.message : String(error)}`); + core.warning(`Failed to submit dependency snapshot for SBOM: ${error instanceof Error ? error.message : String(error)}`); } }); } +function logSkippingSubmission(prefix) { + core.warning(`${prefix} Skipping submission to GitHub Dependency API.`); +} /***/ }),