From 844958e38d3c8c028945a50291714e301f8727db Mon Sep 17 00:00:00 2001 From: "Matthew M. Keeler" Date: Thu, 30 Nov 2023 15:10:53 -0500 Subject: [PATCH] ci: Replace releaser with release please (#187) --- .circleci/config.yml | 107 ---------------------- .github/actions/build-docs/action.yml | 21 +++++ .github/actions/ci/action.yml | 48 ++++++++++ .github/actions/publish-docs/action.yml | 15 +++ .github/workflows/ci.yml | 83 +++++++++++++++++ .github/workflows/lint-pr-title.yml | 12 +++ .github/workflows/manual-publish-docs.yml | 35 +++++++ .github/workflows/release-please.yml | 51 +++++++++++ .ldrelease/config.yml | 28 ------ .ldrelease/update-version.sh | 9 -- .release-please-manifest.json | 3 + README.md | 2 +- release-please-config.json | 12 +++ src/LaunchDarkly/LDClient.php | 2 +- 14 files changed, 282 insertions(+), 146 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/actions/build-docs/action.yml create mode 100644 .github/actions/ci/action.yml create mode 100644 .github/actions/publish-docs/action.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/lint-pr-title.yml create mode 100644 .github/workflows/manual-publish-docs.yml create mode 100644 .github/workflows/release-please.yml delete mode 100644 .ldrelease/config.yml delete mode 100755 .ldrelease/update-version.sh create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b376278b..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,107 +0,0 @@ -version: 2.1 - -orbs: - win: circleci/windows@2.2.0 - -workflows: - workflow: - jobs: - - test-on-linux: - matrix: - parameters: - php-version: ["8.0", "8.1"] - composer-dependencies: ["lowest", "highest"] - - test-on-windows - -jobs: - test-on-windows: - executor: - name: win/default - shell: powershell.exe - - environment: - LD_INCLUDE_INTEGRATION_TESTS: 1 - - steps: - - checkout - - run: - name: install php and java support - command: choco install -y php composer javaruntime - - run: - name: download wiremock - command: Invoke-WebRequest -Uri https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-jre8-standalone/2.31.0/wiremock-jre8-standalone-2.31.0.jar -UseBasicParsing -OutFile wiremock.jar - - run: - name: start wiremock - background: true - command: java -jar ./wiremock.jar - - run: - name: wait for wiremock to be available - command: PowerShell -Command Start-Sleep -Seconds 5 - - run: - name: install dependencies - command: composer install --no-progress - - run: - name: run tests - command: .\vendor\bin\phpunit - - test-on-linux: - parameters: - php-version: - type: string - composer-dependencies: - type: string - - environment: - LD_INCLUDE_INTEGRATION_TESTS: 1 - TEST_HARNESS_PARAMS: -junit build/contract-tests-output/junit-results.xml - - docker: - - image: cimg/php:<> - - image: wiremock/wiremock - - steps: - - setup_remote_docker - - checkout - - - run: - name: Install xdebug - command: sudo pecl install xdebug - - run: - name: validate composer.json - command: composer validate - - run: - name: install dependencies - command: composer install --no-progress - - when: - condition: - equal: [ <>, "lowest" ] - steps: - - run: - name: downgrade to lowest versions - command: composer update --prefer-lowest --prefer-stable - - - run: - name: run tests - command: make test - - run: - name: lint - command: make lint - - - run: - name: build contract test service - command: make build-contract-tests - - run: - name: start contract test service - command: make start-contract-test-service - background: true - - run: - name: run contract tests - command: mkdir -p build/contract-tests-output && make run-contract-tests - - - store_test_results: - path: build/phpunit/junit.xml - - store_test_results: - path: build/contract-tests-output - - store_artifacts: - path: build/phpunit/html-coverage/ - destination: coverage/ diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml new file mode 100644 index 00000000..0054d266 --- /dev/null +++ b/.github/actions/build-docs/action.yml @@ -0,0 +1,21 @@ +# Use a step like this to build documentation. +name: Build Documentation +description: 'Build Documentation.' + +runs: + using: composite + steps: + - name: Build Documentation + shell: bash + run: | + phpdoc \ + -d src \ + -t "docs" \ + --ignore Impl/ \ + --ignore '*/Impl/' \ + --ignore-tags psalm-param \ + --ignore-tags psalm-var \ + --ignore-tags psalm-return \ + --visibility public \ + --defaultpackagename "LaunchDarkly" \ + --title "LaunchDarkly PHP SDK" diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml new file mode 100644 index 00000000..e60b745c --- /dev/null +++ b/.github/actions/ci/action.yml @@ -0,0 +1,48 @@ +name: CI Workflow +description: 'Shared CI workflow.' +inputs: + php-version: + description: 'Which version of PHP should we setup?' + required: false + default: 8.0 + use-lowest-dependencies: + description: 'Should we prefer the lowest dependency version?' + type: boolean + required: false + default: false + token: + description: 'Token used to prevent composer rate limiting' + required: true + +runs: + using: composite + steps: + - name: Setup PHP + uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 + with: + php-version: ${{ inputs.php-version }} + extensions: xdebug + tools: phpdoc:3.1.2 + env: + GITHUB_TOKEN: ${{ inputs.token }} + + - name: Install dependencies + shell: bash + run: composer install --no-progress + + - name: Downgrade to lowest versions + if: ${{ inputs.use-lowest-dependencies }} + shell: bash + run: composer update --prefer-lowest --prefer-stable + + - name: Run unit tests + shell: bash + run: make test + + - name: Run lint checks + shell: bash + run: make lint + + - name: Run contract tests + shell: bash + run: make contract-tests diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml new file mode 100644 index 00000000..fb5a1c4e --- /dev/null +++ b/.github/actions/publish-docs/action.yml @@ -0,0 +1,15 @@ +name: Publish Documentation +description: 'Publish the documentation to GitHub pages' +inputs: + token: + description: 'Token to use for publishing.' + required: true + +runs: + using: composite + steps: + - uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.1 + name: 'Publish to Github pages' + with: + docs_path: docs + github_token: ${{ inputs.token }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3f18c9ac --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,83 @@ +name: Run CI +on: + push: + branches: [ 5.x ] + paths-ignore: + - '**.md' # Do not need to run CI for markdown changes. + pull_request: + branches: [ 5.x ] + paths-ignore: + - '**.md' + +jobs: + linux-build: + runs-on: ubuntu-latest + + services: + wiremock: + image: wiremock/wiremock + ports: + - 8080:8080 + + strategy: + matrix: + php-version: [8.0, 8.1] + use-lowest-dependencies: [true, false] + + env: + LD_INCLUDE_INTEGRATION_TESTS: 1 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # If you only need the current version keep this. + + - uses: ./.github/actions/ci + with: + php-version: ${{ matrix.php-version }} + use-lowest-dependencies: ${{ matrix.use-lowest-dependencies }} + token: ${{ secrets.GITHUB_TOKEN }} + + windows-build: + runs-on: windows-latest + + strategy: + matrix: + php-version: [8.0.30, 8.1.26] + + env: + LD_INCLUDE_INTEGRATION_TESTS: 1 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # If you only need the current version keep this. + + - name: Install java support + run: choco install -y javaruntime + + - name: Install php support + run: choco install -y php --version=${{ matrix.php-version }} --force + + - name: Install composer + run: choco install -y composer + + - name: Download wiremock + run: Invoke-WebRequest -Uri https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-jre8-standalone/2.31.0/wiremock-jre8-standalone-2.31.0.jar -UseBasicParsing -OutFile wiremock.jar + + - name: Verify checksum + shell: bash + run: | + [ "$(sha256sum wiremock.jar | awk '{ print $1 }')" == "c5cd526e04c57293ec847d845733b017c4052d2132653332e05a54272934a305" ] + + - name: Start wiremock + run: cmd /c "START /b java -jar ./wiremock.jar" + + - name: Wait for wiremock to be available + run: PowerShell -Command Start-Sleep -Seconds 5 + + - name: Install dependencies + run: composer install --no-progress + + - name: Run tests + run: .\vendor\bin\phpunit diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 00000000..4ba79c13 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -0,0 +1,12 @@ +name: Lint PR title + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + lint-pr-title: + uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main diff --git a/.github/workflows/manual-publish-docs.yml b/.github/workflows/manual-publish-docs.yml new file mode 100644 index 00000000..8943f5c9 --- /dev/null +++ b/.github/workflows/manual-publish-docs.yml @@ -0,0 +1,35 @@ +on: + workflow_dispatch: + +name: Publish Documentation +jobs: + build-publish: + runs-on: ubuntu-latest + + services: + wiremock: + image: wiremock/wiremock + ports: + - 8080:8080 + + env: + LD_INCLUDE_INTEGRATION_TESTS: 1 + + permissions: + contents: write # Needed in this case to write github pages. + + steps: + - uses: actions/checkout@v4 + + - name: Build and Test + uses: ./.github/actions/ci + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build documentation + uses: ./.github/actions/build-docs + + - name: Publish Documentation + uses: ./.github/actions/publish-docs + with: + token: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..b2dbc5a8 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,51 @@ +name: Run Release Please + +on: + push: + branches: + - 5.x + +jobs: + release-package: + runs-on: ubuntu-latest + + permissions: + contents: write # Contents and pull-requests are for release-please to make releases. + pull-requests: write + + services: + wiremock: + image: wiremock/wiremock + ports: + - 8080:8080 + + env: + LD_INCLUDE_INTEGRATION_TESTS: 1 + + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + command: manifest + token: ${{ secrets.GITHUB_TOKEN }} + default-branch: 5.x + + - uses: actions/checkout@v4 + if: ${{ steps.release.outputs.releases_created }} + with: + fetch-depth: 0 # If you only need the current version keep this. + + - name: Build and Test + if: ${{ steps.release.outputs.releases_created }} + uses: ./.github/actions/ci + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build documentation + if: ${{ steps.release.outputs.releases_created }} + uses: ./.github/actions/build-docs + + - uses: ./.github/actions/publish-docs + if: ${{ steps.release.outputs.releases_created }} + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.ldrelease/config.yml b/.ldrelease/config.yml deleted file mode 100644 index 2049326b..00000000 --- a/.ldrelease/config.yml +++ /dev/null @@ -1,28 +0,0 @@ -version: 2 - -repo: - public: php-server-sdk - private: php-server-sdk-private - -publications: - - url: https://packagist.org/packages/launchdarkly/server-sdk - description: Packagist - -branches: - - name: main - description: 6.x - - name: 5.x - - name: 4.x - -jobs: - - docker: - image: ldcircleci/php-sdk-release:4 # Releaser's default for PHP is still php-sdk-release:3, which is PHP 7.x - template: - name: php - -documentation: - gitHubPages: true - title: "LaunchDarkly PHP SDK" - -sdk: - displayName: "PHP" diff --git a/.ldrelease/update-version.sh b/.ldrelease/update-version.sh deleted file mode 100755 index b017b80d..00000000 --- a/.ldrelease/update-version.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -e - -# Update version in LDClient class -LDCLIENT_PHP=src/LaunchDarkly/LDClient.php -LDCLIENT_PHP_TEMP=${LDCLIENT_PHP}.tmp -sed "s/const VERSION = '.*'/const VERSION = '${LD_RELEASE_VERSION}'/g" ${LDCLIENT_PHP} > ${LDCLIENT_PHP_TEMP} -mv ${LDCLIENT_PHP_TEMP} ${LDCLIENT_PHP} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..b5e91573 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "5.2.0" +} diff --git a/README.md b/README.md index 4376af0d..05090546 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LaunchDarkly Server-side SDK for PHP -[![Circle CI](https://img.shields.io/circleci/project/launchdarkly/php-server-sdk.png)](https://circleci.com/gh/launchdarkly/php-server-sdk) +[![Run CI](https://github.com/launchdarkly/php-server-sdk/actions/workflows/ci.yml/badge.svg?branch=5.x)](https://github.com/launchdarkly/php-server-sdk/actions/workflows/ci.yml) [![Packagist](https://img.shields.io/packagist/v/launchdarkly/server-sdk.svg?style=flat-square)](https://packagist.org/packages/launchdarkly/server-sdk) [![Documentation](https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8)](https://launchdarkly.github.io/php-server-sdk) diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..07189e24 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,12 @@ +{ + "packages": { + ".": { + "release-type": "php", + "bump-minor-pre-major": true, + "versioning": "default", + "include-v-in-tag": false, + "include-component-in-tag": false, + "extra-files": ["src/LaunchDarkly/LDClient.php"] + } + } +} diff --git a/src/LaunchDarkly/LDClient.php b/src/LaunchDarkly/LDClient.php index b5b03740..aaecceba 100644 --- a/src/LaunchDarkly/LDClient.php +++ b/src/LaunchDarkly/LDClient.php @@ -34,7 +34,7 @@ class LDClient * The current SDK version. * @var string */ - const VERSION = '5.2.0'; + const VERSION = '5.2.0'; // x-release-please-version protected string $_sdkKey; protected string $_baseUri;