diff --git a/.github/actions/await-http-resource/action.yml b/.github/actions/await-http-resource/action.yml new file mode 100644 index 00000000..ba177fb7 --- /dev/null +++ b/.github/actions/await-http-resource/action.yml @@ -0,0 +1,20 @@ +name: Await HTTP Resource +description: 'Waits for an HTTP resource to be available (a HEAD request succeeds)' +inputs: + url: + description: 'URL of the resource to await' + required: true +runs: + using: composite + steps: + - name: Await HTTP resource + shell: bash + run: | + url=${{ inputs.url }} + echo "Waiting for $url" + until curl --fail --head --silent ${{ inputs.url }} > /dev/null + do + echo "." + sleep 60 + done + echo "$url is available" diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 6328d227..70b05131 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,31 +1,39 @@ -name: 'Build' +name: Build description: 'Builds the project, optionally publishing it to a local deployment repository' inputs: - java-version: + develocity-access-key: + description: 'Access key for authentication with ge.spring.io' required: false - default: '17' - description: 'The Java version to compile and test with' + gradle-cache-read-only: + description: 'Whether Gradle''s cache should be read only' + required: false + default: 'true' java-distribution: + description: 'Java distribution to use' required: false default: 'liberica' - description: 'The Java distribution to use for the build' - java-toolchain: + java-early-access: + description: 'Whether the Java version is in early access' required: false default: 'false' + java-toolchain: description: 'Whether a Java toolchain should be used' - publish: required: false default: 'false' + java-version: + description: 'Java version to compile and test with' + required: false + default: '17' + publish: description: 'Whether to publish artifacts ready for deployment to Artifactory' - develocity-access-key: required: false - description: 'The access key for authentication with ge.spring.io' + default: 'false' outputs: build-scan-url: - description: 'The URL, if any, of the build scan produced by the build' + description: 'URL, if any, of the build scan produced by the build' value: ${{ (inputs.publish == 'true' && steps.publish.outputs.build-scan-url) || steps.build.outputs.build-scan-url }} version: - description: 'The version that was built' + description: 'Version that was built' value: ${{ steps.read-version.outputs.version }} runs: using: composite @@ -33,10 +41,12 @@ runs: - name: Prepare Gradle Build uses: ./.github/actions/prepare-gradle-build with: + cache-read-only: ${{ inputs.gradle-cache-read-only }} develocity-access-key: ${{ inputs.develocity-access-key }} - java-version: ${{ inputs.java-version }} java-distribution: ${{ inputs.java-distribution }} + java-early-access: ${{ inputs.java-early-access }} java-toolchain: ${{ inputs.java-toolchain }} + java-version: ${{ inputs.java-version }} - name: Build id: build if: ${{ inputs.publish == 'false' }} diff --git a/.github/actions/create-github-release/action.yml b/.github/actions/create-github-release/action.yml index d5cc67fb..03452537 100644 --- a/.github/actions/create-github-release/action.yml +++ b/.github/actions/create-github-release/action.yml @@ -1,27 +1,27 @@ name: Create GitHub Release -description: Create the release on GitHub with a changelog +description: 'Create the release on GitHub with a changelog' inputs: milestone: - description: Name of the GitHub milestone for which a release will be created - required: true - token: - description: Token to use for authentication with GitHub + description: 'Name of the GitHub milestone for which a release will be created' required: true pre-release: - description: Whether the release is a pre-release (a milestone or release candidate) + description: 'Whether the release is a pre-release (a milestone or release candidate)' required: false default: 'false' + token: + description: 'Token to use for authentication with GitHub' + required: true runs: using: composite steps: - name: Generate Changelog uses: spring-io/github-changelog-generator@185319ad7eaa75b0e8e72e4b6db19c8b2cb8c4c1 #v0.0.11 with: + config-file: .github/actions/create-github-release/changelog-generator.yml milestone: ${{ inputs.milestone }} token: ${{ inputs.token }} - config-file: .github/actions/create-github-release/changelog-generator.yml - name: Create GitHub Release + shell: bash env: GITHUB_TOKEN: ${{ inputs.token }} - shell: bash run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md ${{ inputs.pre-release == 'true' && '--prerelease' || '' }} diff --git a/.github/actions/create-github-release/changelog-generator.yml b/.github/actions/create-github-release/changelog-generator.yml index 9c7fa358..0c1077fd 100644 --- a/.github/actions/create-github-release/changelog-generator.yml +++ b/.github/actions/create-github-release/changelog-generator.yml @@ -1,5 +1,4 @@ changelog: - repository: spring-projects/spring-restdocs sections: - title: ":star: New Features" labels: diff --git a/.github/actions/prepare-gradle-build/action.yml b/.github/actions/prepare-gradle-build/action.yml index 3715cc19..819c13d0 100644 --- a/.github/actions/prepare-gradle-build/action.yml +++ b/.github/actions/prepare-gradle-build/action.yml @@ -1,36 +1,55 @@ -name: 'Prepare Gradle Build' +name: Prepare Gradle Build description: 'Prepares a Gradle build. Sets up Java and Gradle and configures Gradle properties' inputs: - java-version: + cache-read-only: + description: 'Whether Gradle''s cache should be read only' + required: false + default: 'true' + develocity-access-key: + description: 'Access key for authentication with ge.spring.io' required: false - default: '17' - description: 'The Java version to use for the build' java-distribution: + description: 'Java distribution to use' required: false default: 'liberica' - description: 'The Java distribution to use for the build' - java-toolchain: + java-early-access: + description: 'Whether the Java version is in early access. When true, forces java-distribution to temurin' required: false default: 'false' + java-toolchain: description: 'Whether a Java toolchain should be used' - develocity-access-key: required: false - description: 'The access key for authentication with ge.spring.io' + default: 'false' + java-version: + description: 'Java version to use for the build' + required: false + default: '17' runs: using: composite steps: + - name: Free Disk Space + if: ${{ runner.os == 'Linux' }} + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + with: + tool-cache: true + docker-images: false - name: Set Up Java - uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0 + uses: actions/setup-java@v4 with: - distribution: ${{ inputs.java-distribution }} + distribution: ${{ inputs.java-early-access == 'true' && 'temurin' || (inputs.java-distribution || 'liberica') }} java-version: | - ${{ inputs.java-version }} + ${{ inputs.java-early-access == 'true' && format('{0}-ea', inputs.java-version) || inputs.java-version }} ${{ inputs.java-toolchain == 'true' && '17' || '' }} - - name: Set Up Gradle + - name: Set Up Gradle With Read/Write Cache + if: ${{ inputs.cache-read-only == 'false' }} uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0 with: cache-read-only: false develocity-access-key: ${{ inputs.develocity-access-key }} + - name: Set Up Gradle + uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0 + with: + develocity-access-key: ${{ inputs.develocity-access-key }} - name: Configure Gradle Properties shell: bash run: | diff --git a/.github/actions/print-jvm-thread-dumps/action.yml b/.github/actions/print-jvm-thread-dumps/action.yml index 9b0905b7..bcaebf36 100644 --- a/.github/actions/print-jvm-thread-dumps/action.yml +++ b/.github/actions/print-jvm-thread-dumps/action.yml @@ -1,5 +1,5 @@ name: Print JVM thread dumps -description: Prints a thread dump for all running JVMs +description: 'Prints a thread dump for all running JVMs' runs: using: composite steps: diff --git a/.github/actions/send-notification/action.yml b/.github/actions/send-notification/action.yml index d1389776..b379e678 100644 --- a/.github/actions/send-notification/action.yml +++ b/.github/actions/send-notification/action.yml @@ -1,33 +1,39 @@ name: Send Notification -description: Sends a Google Chat message as a notification of the job's outcome +description: 'Sends a Google Chat message as a notification of the job''s outcome' inputs: - webhook-url: - description: 'Google Chat Webhook URL' - required: true - status: - description: 'Status of the job' - required: true build-scan-url: description: 'URL of the build scan to include in the notification' + required: false run-name: description: 'Name of the run to include in the notification' + required: false default: ${{ format('{0} {1}', github.ref_name, github.job) }} + status: + description: 'Status of the job' + required: true + webhook-url: + description: 'Google Chat Webhook URL' + required: true runs: using: composite steps: - - shell: bash + - name: Prepare Variables + shell: bash run: | echo "BUILD_SCAN=${{ inputs.build-scan-url == '' && ' [build scan unavailable]' || format(' [<{0}|Build Scan>]', inputs.build-scan-url) }}" >> "$GITHUB_ENV" echo "RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_ENV" - - shell: bash + - name: Success Notification if: ${{ inputs.status == 'success' }} + shell: bash run: | curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was successful ${{ env.BUILD_SCAN }}"}' || true - - shell: bash + - name: Failure Notification if: ${{ inputs.status == 'failure' }} + shell: bash run: | curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: " *<${{ env.RUN_URL }}|${{ inputs.run-name }}> failed* ${{ env.BUILD_SCAN }}"}' || true - - shell: bash + - name: Cancel Notification if: ${{ inputs.status == 'cancelled' }} + shell: bash run: | curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was cancelled"}' || true diff --git a/.github/actions/sync-to-maven-central/action.yml b/.github/actions/sync-to-maven-central/action.yml index 838da9bd..ec3b20d3 100644 --- a/.github/actions/sync-to-maven-central/action.yml +++ b/.github/actions/sync-to-maven-central/action.yml @@ -1,20 +1,20 @@ name: Sync to Maven Central -description: Syncs a release to Maven Central and waits for it to be available for use +description: 'Syncs a release to Maven Central and waits for it to be available for use' inputs: jfrog-cli-config-token: description: 'Config token for the JFrog CLI' required: true - spring-restdocs-version: - description: 'The version of Spring REST Docs that is being synced to Central' - required: true - ossrh-s01-token-username: - description: 'Username for authentication with s01.oss.sonatype.org' + ossrh-s01-staging-profile: + description: 'Staging profile to use when syncing to Central' required: true ossrh-s01-token-password: description: 'Password for authentication with s01.oss.sonatype.org' required: true - ossrh-s01-staging-profile: - description: 'Staging profile to use when syncing to Central' + ossrh-s01-token-username: + description: 'Username for authentication with s01.oss.sonatype.org' + required: true + spring-restdocs-version: + description: 'Version of Spring REST Docs that is being synced to Central' required: true runs: using: composite @@ -29,22 +29,15 @@ runs: - name: Sync uses: spring-io/nexus-sync-action@42477a2230a2f694f9eaa4643fa9e76b99b7ab84 # v0.0.1 with: - username: ${{ inputs.ossrh-s01-token-username }} + close: true + create: true + generate-checksums: true password: ${{ inputs.ossrh-s01-token-password }} + release: true staging-profile-name: ${{ inputs.ossrh-s01-staging-profile }} - create: true upload: true - close: true - release: true - generate-checksums: true + username: ${{ inputs.ossrh-s01-token-username }} - name: Await - shell: bash - run: | - url=${{ format('https://repo.maven.apache.org/maven2/org/springframework/restdocs/spring-restdocs-core/{0}/spring-restdocs-core-{0}.jar', inputs.spring-restdocs-version) }} - echo "Waiting for $url" - until curl --fail --head --silent $url > /dev/null - do - echo "." - sleep 60 - done - echo "$url is available" + uses: ./.github/actions/await-http-resource + with: + url: ${{ format('https://repo.maven.apache.org/maven2/org/springframework/restdocs/spring-restdocs-core/{0}/spring-restdocs-core-{0}.jar', inputs.spring-restdocs-version) }} diff --git a/.github/workflows/build-and-deploy-snapshot.yml b/.github/workflows/build-and-deploy-snapshot.yml index 63166434..a77698bd 100644 --- a/.github/workflows/build-and-deploy-snapshot.yml +++ b/.github/workflows/build-and-deploy-snapshot.yml @@ -8,37 +8,38 @@ concurrency: jobs: build-and-deploy-snapshot: name: Build and Deploy Snapshot - runs-on: ubuntu-latest if: ${{ github.repository == 'spring-projects/spring-restdocs' }} + runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} steps: - name: Check Out Code - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@v4 - name: Build and Publish id: build-and-publish uses: ./.github/actions/build with: - develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} + develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + gradle-cache-read-only: false publish: true - name: Deploy uses: spring-io/artifactory-deploy-action@26bbe925a75f4f863e1e529e85be2d0093cac116 # v0.0.1 with: - uri: 'https://repo.spring.io' - username: ${{ secrets.ARTIFACTORY_USERNAME }} - password: ${{ secrets.ARTIFACTORY_PASSWORD }} - build-name: 'spring-restdocs-3.0.x' - repository: 'libs-snapshot-local' + artifact-properties: | + /**/spring-restdocs-*.zip::zip.type=docs,zip.deployed=false + build-name: ${{ format('spring-restdocs-{0}', github.ref_name) }} folder: 'deployment-repository' + password: ${{ secrets.ARTIFACTORY_PASSWORD }} + repository: ${{ 'libs-snapshot-local' }} signing-key: ${{ secrets.GPG_PRIVATE_KEY }} signing-passphrase: ${{ secrets.GPG_PASSPHRASE }} - artifact-properties: | - /**/spring-restdocs-*.zip::zip.type=docs,zip.deployed=false + uri: 'https://repo.spring.io' + username: ${{ secrets.ARTIFACTORY_USERNAME }} - name: Send Notification - uses: ./.github/actions/send-notification if: always() + uses: ./.github/actions/send-notification with: - webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} - status: ${{ job.status }} build-scan-url: ${{ steps.build-and-publish.outputs.build-scan-url }} run-name: ${{ format('{0} | Linux | Java 17', github.ref_name) }} + status: ${{ job.status }} + webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} outputs: version: ${{ steps.build-and-publish.outputs.version }} diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml index cf50659f..164c04dc 100644 --- a/.github/workflows/build-pull-request.yml +++ b/.github/workflows/build-pull-request.yml @@ -1,30 +1,24 @@ name: Build Pull Request on: pull_request - permissions: contents: read - jobs: build: name: Build Pull Request - runs-on: ubuntu-latest if: ${{ github.repository == 'spring-projects/spring-restdocs' }} + runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} steps: - - name: Set Up JDK 17 - uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0 - with: - java-version: '17' - distribution: 'liberica' - - name: Check Out - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - - name: Set Up Gradle - uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0 + - name: Check Out Code + uses: actions/checkout@v4 - name: Build - env: - run: ./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --no-parallel --continue build + id: build + uses: ./.github/actions/build + - name: Print JVM Thread Dumps When Cancelled + if: cancelled() + uses: ./.github/actions/print-jvm-thread-dumps - name: Upload Build Reports - uses: actions/upload-artifact@v4 if: failure() + uses: actions/upload-artifact@v4 with: name: build-reports path: '**/build/reports/' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69eb0a04..c6b216c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,12 +8,13 @@ concurrency: jobs: ci: name: '${{ matrix.os.name}} | Java ${{ matrix.java.version}}' - runs-on: ${{ matrix.os.id }} if: ${{ github.repository == 'spring-projects/spring-restdocs' }} + runs-on: ${{ matrix.os.id }} strategy: + fail-fast: false matrix: os: - - id: ubuntu-latest + - id: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name: Linux - id: windows-latest name: Windows @@ -24,6 +25,8 @@ jobs: toolchain: true - version: 22 toolchain: true + - version: 23 + toolchain: true exclude: - os: name: Linux @@ -37,20 +40,22 @@ jobs: git config --global core.longPaths true Stop-Service -name Docker - name: Check Out Code - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@v4 - name: Build id: build uses: ./.github/actions/build with: - java-version: ${{ matrix.java.version }} - java-distribution: ${{ matrix.java.distribution || 'liberica' }} + develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + gradle-cache-read-only: false + java-early-access: ${{ matrix.java.early-access || 'false' }} + java-distribution: ${{ matrix.java.distribution }} java-toolchain: ${{ matrix.java.toolchain }} - develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} + java-version: ${{ matrix.java.version }} - name: Send Notification - uses: ./.github/actions/send-notification if: always() + uses: ./.github/actions/send-notification with: - webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} - status: ${{ job.status }} build-scan-url: ${{ steps.build.outputs.build-scan-url }} run-name: ${{ format('{0} | {1} | Java {2}', github.ref_name, matrix.os.name, matrix.java.version) }} + status: ${{ job.status }} + webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 46e33b78..b1aa842f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,28 +8,29 @@ concurrency: jobs: build-and-stage-release: name: Build and Stage Release - runs-on: ubuntu-latest if: ${{ github.repository == 'spring-projects/spring-restdocs' }} + runs-on: ${{ vars.UBUNTU_MEDIUIM || 'ubuntu-latest' }} steps: - name: Check Out Code - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@v4 - name: Build and Publish id: build-and-publish uses: ./.github/actions/build with: - develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} + develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + gradle-cache-read-only: false publish: true - name: Stage Release uses: spring-io/artifactory-deploy-action@26bbe925a75f4f863e1e529e85be2d0093cac116 # v0.0.1 with: - uri: 'https://repo.spring.io' - username: ${{ secrets.ARTIFACTORY_USERNAME }} + build-name: ${{ format('spring-restdocs-{0}', github.ref_name) }} + folder: 'deployment-repository' password: ${{ secrets.ARTIFACTORY_PASSWORD }} - build-name: ${{ format('spring-restdocs-{0}', steps.build-and-publish.outputs.version)}} repository: 'libs-staging-local' - folder: 'deployment-repository' signing-key: ${{ secrets.GPG_PRIVATE_KEY }} signing-passphrase: ${{ secrets.GPG_PASSPHRASE }} + uri: 'https://repo.spring.io' + username: ${{ secrets.ARTIFACTORY_USERNAME }} outputs: version: ${{ steps.build-and-publish.outputs.version }} sync-to-maven-central: @@ -37,10 +38,10 @@ jobs: needs: - build-and-stage-release - verify - runs-on: ubuntu-latest + runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - name: Check Out Code - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Sync to Maven Central uses: ./.github/actions/sync-to-maven-central with: @@ -54,23 +55,23 @@ jobs: needs: - build-and-stage-release - sync-to-maven-central - runs-on: ubuntu-latest + runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - name: Set up JFrog CLI uses: jfrog/setup-jfrog-cli@9fe0f98bd45b19e6e931d457f4e98f8f84461fb5 # v4.4.1 env: JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} - - name: Promote build + - name: Promote Open Source Build run: jfrog rt build-promote ${{ format('spring-restdocs-{0}', needs.build-and-stage-release.outputs.version)}} ${{ github.run_number }} libs-release-local create-github-release: name: Create GitHub Release needs: - build-and-stage-release - promote-release - runs-on: ubuntu-latest + runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - name: Check Out Code - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Create GitHub Release uses: ./.github/actions/create-github-release with: