Unverified Commit ebf4d134 authored by daz's avatar daz
Browse files

Convert `dependency-submission` action to Typescript

Instead of being a thin wrapper over `setup-gradle`, the `dependency-submission`
action is now a fully-fledged action sharing implementation with `setup-gradle`.
parent 42146079
Loading
Loading
Loading
Loading
+7
Changes for .github/workflows/ci-full-check.yml: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -43,6 +43,13 @@ jobs:
    with:
      cache-key-prefix: ${{github.run_number}}-

  dependency-submission:
    uses: ./.github/workflows/integ-test-dependency-submission.yml
    permissions:
      contents: write
    with:
      cache-key-prefix: ${{github.run_number}}-

  execution-with-caching:
    uses: ./.github/workflows/integ-test-execution-with-caching.yml
    with:
+9
Changes for .github/workflows/ci-quick-check.yml: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -69,6 +69,15 @@ jobs:
      runner-os: '["ubuntu-latest"]'
      download-dist: true

  dependency-submission:
    needs: build-distribution
    uses: ./.github/workflows/integ-test-dependency-submission.yml
    permissions:
      contents: write
    with:
      runner-os: '["ubuntu-latest"]'
      download-dist: true

  execution-with-caching:
    needs: build-distribution
    uses: ./.github/workflows/integ-test-execution-with-caching.yml
+148
Changes for .github/workflows/integ-test-dependency-submission.yml: 148 added lines, 0 removed lines.
Original line number Diff line number Diff line
name: Test dependency graph

on:
  workflow_call:
    inputs:
      cache-key-prefix:
        type: string
      runner-os:
        type: string
        default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
      download-dist:
        type: boolean
        default: false

permissions:
  contents: write

env:
  DOWNLOAD_DIST: ${{ inputs.download-dist }}
  GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: dependency-graph-${{ inputs.cache-key-prefix }}

jobs:
  groovy-generate-and-upload:
    strategy:
      matrix:
        os: ${{fromJSON(inputs.runner-os)}}
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout sources
      uses: actions/checkout@v4
    - name: Initialize integ-test
      uses: ./.github/actions/init-integ-test

    - name: Generate dependency graph
      uses: ./dependency-submission
      with:
        dependency-graph: generate-and-upload
        build-root-directory: .github/workflow-samples/groovy-dsl

  groovy-download-and-submit:
    needs: [groovy-generate-and-upload]
    runs-on: "ubuntu-latest"
    steps:
    - name: Checkout sources
      uses: actions/checkout@v4
    - name: Initialize integ-test
      uses: ./.github/actions/init-integ-test

    - name: Submit dependency graph
      uses: ./dependency-submission
      with:
        dependency-graph: download-and-submit

  kotlin-generate-and-submit:
    strategy:
      matrix:
        os: ${{fromJSON(inputs.runner-os)}}
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout sources
      uses: actions/checkout@v4
    - name: Initialize integ-test
      uses: ./.github/actions/init-integ-test

    - name: Generate and submit dependency graph
      uses: ./dependency-submission
      with:
        build-root-directory: .github/workflow-samples/kotlin-dsl

  # TODO - Test this scenario (and make it work)
  # multiple-builds:
  #   strategy:
  #     matrix:
  #       os: ${{fromJSON(inputs.runner-os)}}
  #   runs-on: ${{ matrix.os }}
  #   steps:
  #   - name: Checkout sources
  #     uses: actions/checkout@v4
  #   - name: Initialize integ-test
  #     uses: ./.github/actions/init-integ-test

  #   - name: Setup Gradle for dependency-graph generate
  #     uses: ./setup-gradle
  #     with:
  #       dependency-graph: generate-and-submit
  #   - id: gradle-assemble
  #     run: ./gradlew assemble
  #     working-directory: .github/workflow-samples/groovy-dsl
  #   - id: gradle-build
  #     run: ./gradlew build
  #     working-directory: .github/workflow-samples/groovy-dsl
  #   - id: gradle-build-again
  #     run: ./gradlew build
  #     working-directory: .github/workflow-samples/groovy-dsl
  #   - name: Check generated dependency graphs
  #     shell: bash
  #     run: |
  #       echo "gradle-assemble report file: ${{ steps.gradle-assemble.outputs.dependency-graph-file }}"
  #       echo "gradle-build report file: ${{ steps.gradle-build.outputs.dependency-graph-file }}"
  #       echo "gradle-build-again report file: ${{ steps.gradle-build-again.outputs.dependency-graph-file }}"
  #       ls -l dependency-graph-reports
  #       if [ ! -e "${{ steps.gradle-assemble.outputs.dependency-graph-file }}" ]; then
  #           echo "Did not find gradle-assemble dependency graph file"
  #           exit 1
  #       fi
  #       if [ ! -e "${{ steps.gradle-build.outputs.dependency-graph-file }}" ]; then
  #           echo "Did not find gradle-build dependency graph files"
  #           exit 1
  #       fi
  #       if [ ! -e "${{ steps.gradle-build-again.outputs.dependency-graph-file }}" ]; then
  #           echo "Did not find gradle-build-again dependency graph files"
  #           exit 1
  #       fi
        
  config-cache:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout sources
      uses: actions/checkout@v4
    - name: Initialize integ-test
      uses: ./.github/actions/init-integ-test

    - id: config-cache-store
      uses: ./dependency-submission
      with:
        build-root-directory: .github/workflow-samples/groovy-dsl
        additional-arguments: --configuration-cache
    - name: Check and delete generated dependency graph
      shell: bash
      run: |
        if [ ! -e "${{ steps.config-cache-store.outputs.dependency-graph-file }}" ]; then
            echo "Did not find config-cache-store dependency graph files"
            exit 1
        fi
        rm ${{ steps.config-cache-store.outputs.dependency-graph-file }}
    - id: config-cache-reuse
      uses: ./dependency-submission
      with:
        build-root-directory: .github/workflow-samples/groovy-dsl
        additional-arguments: --configuration-cache
    - name: Check no dependency graph is generated
      shell: bash
      run: |
        if [ ! -z "$(ls -A dependency-graph-reports)" ]; then
            echo "Expected no dependency graph files to be generated"
            ls -l dependency-graph-reports
            exit 1
        fi        
+26 −35
Changes for dependency-submission/action.yml: 26 added lines, 35 removed lines.
Original line number Diff line number Diff line
@@ -47,6 +47,29 @@ inputs:
    description: Indicate that you agree to the Build Scan® terms of use. This input value must be "yes".
    required: false

  # HARD-CODED DEFAULTS - These should be removed from here and set directly in code
  dependency-graph-continue-on-failure:
    required: false
    default: false
  artifact-retention-days:
    required: false
    default: 1
  add-job-summary:
    required: false
    default: 'always'
  add-job-summary-as-pr-comment:
    required: false
    default: 'never'
  workflow-job-context:
    required: false
    default: ${{ toJSON(matrix) }}
  github-token:
    default: ${{ github.token }}
    required: false
  cache-disabled:
    required: false
    default: true

  # DEPRECATED ACTION INPUTS
  build-scan-terms-of-service-url:
    description: The URL to the Build Scan® terms of use. This input must be set to 'https://gradle.com/terms-of-service'.
@@ -59,38 +82,6 @@ inputs:
    deprecation-message: The input has been renamed to align with the Develocity API. Use 'build-scan-terms-of-use-agree' instead.

runs:
  using: "composite"
  steps:
    - name: Check no setup-gradle
      shell: bash
      run: |
        if [ -n "${GRADLE_BUILD_ACTION_SETUP_COMPLETED}" ]; then
          echo "The dependency-submission action cannot be used in the same Job as the setup-gradle action. Please use a separate Job for dependency submission."
          exit 1
        fi
    - name: Generate dependency graph
      if: ${{ inputs.dependency-graph == 'generate-and-submit' || inputs.dependency-graph == 'generate-and-upload' }}
      uses: gradle/actions/[email protected]
      with:
        dependency-graph: ${{ inputs.dependency-graph }}
        dependency-graph-continue-on-failure: false
        gradle-version: ${{ inputs.gradle-version }}
        build-root-directory: ${{ inputs.build-root-directory }}
        cache-encryption-key: ${{ inputs.cache-encryption-key }}
        build-scan-publish: ${{ inputs.build-scan-publish }}
        build-scan-terms-of-use-url: ${{ inputs.build-scan-terms-of-use-url || inputs.build-scan-terms-of-service-url }}
        build-scan-terms-of-use-agree: ${{ inputs.build-scan-terms-of-use-agree || inputs.build-scan-terms-of-service-agree }}
        artifact-retention-days: 1
        arguments: |
          -Dorg.gradle.configureondemand=false
          -Dorg.gradle.dependency.verification=off
          -Dorg.gradle.unsafe.isolated-projects=false
          :ForceDependencyResolutionPlugin_resolveAllDependencies
          ${{ inputs.additional-arguments }}
    - name: Download and submit dependency graph
      if: ${{ inputs.dependency-graph == 'download-and-submit' }}
      uses: gradle/actions/[email protected]
      with:
        dependency-graph: download-and-submit
        dependency-graph-continue-on-failure: false
        cache-disabled: true
  using: 'node20'
  main: '../dist/dependency-submission/main/index.js'
  post: '../dist/dependency-submission/post/index.js'
+2
Changes for sources/package.json: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@
    "format": "prettier --write 'src/**/*.ts'",
    "format-check": "prettier --check 'src/**/*.ts'",
    "lint": "eslint 'src/**/*.ts'",
    "compile-dependency-submission-main": "ncc build src/dependency-submission/main.ts --out ../dist/dependency-submission/main --source-map --no-source-map-register",
    "compile-dependency-submission-post": "ncc build src/dependency-submission/post.ts --out ../dist/dependency-submission/post --source-map --no-source-map-register",
    "compile-setup-gradle-main": "ncc build src/setup-gradle/main.ts --out ../dist/setup-gradle/main --source-map --no-source-map-register",
    "compile-setup-gradle-post": "ncc build src/setup-gradle/post.ts --out ../dist/setup-gradle/post --source-map --no-source-map-register",
    "compile": "npm-run-all --parallel compile-*",
Loading