diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index bf29b04..70e4f18 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Bug report about: Create a report to help us improve title: '' -labels: '' +labels: 'bug' assignees: '' --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 3f7d5bf..424628c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,7 @@ name: Feature request about: Suggest an idea for this project title: '' -labels: '' +labels: 'feature' assignees: '' --- diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml new file mode 100644 index 0000000..84e6a1b --- /dev/null +++ b/.github/actions/build-docs/action.yml @@ -0,0 +1,9 @@ +name: Build Documentation +description: 'Build Documentation.' + +runs: + using: composite + steps: + - name: Build Documentation + shell: bash + run: make docs diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..5cf127c --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,9 @@ +name: Build distribution files +description: 'Build distribution files' + +runs: + using: composite + steps: + - name: Build distribution files + shell: bash + run: poetry build diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml new file mode 100644 index 0000000..60910ad --- /dev/null +++ b/.github/actions/publish/action.yml @@ -0,0 +1,18 @@ +name: Publish Package +description: 'Publish the package to PyPI' +inputs: + token: + description: 'Token to use for publishing.' + required: true + dry_run: + description: 'Is this a dry run. If so no package will be published.' + required: true + +runs: + using: composite + steps: + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + if: ${{ inputs.dry_run == 'false' }} + with: + password: ${{inputs.token}} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2018bac --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: Quality control checks + +on: + push: + branches: [ main, 'feat/**' ] + paths-ignore: + - '**.md' # Do not need to run CI for markdown changes. + pull_request: + branches: [ main, 'feat/**' ] + paths-ignore: + - '**.md' + +jobs: + linux: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install poetry + run: pipx install poetry + + - uses: ./.github/actions/build + - uses: ./.github/actions/build-docs + + - name: Run tests + run: make test + + - name: Verify typehints + run: make lint + + windows: + runs-on: windows-latest + + defaults: + run: + shell: powershell + + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install requirements + run: | + pipx install poetry + poetry install --all-extras + + - name: Run tests + run: make test diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 0000000..4ba79c1 --- /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.yml b/.github/workflows/manual-publish.yml new file mode 100644 index 0000000..b2a862d --- /dev/null +++ b/.github/workflows/manual-publish.yml @@ -0,0 +1,38 @@ +name: Publish Package +on: + workflow_dispatch: + inputs: + dry_run: + description: 'Is this a dry run? If so no package will be published.' + type: boolean + required: true + +jobs: + build-publish: + runs-on: ubuntu-latest + # Needed to get tokens during publishing. + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Install poetry + run: pipx install poetry + + - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.2 + name: 'Get PyPI token' + with: + aws_assume_role: ${{ vars.AWS_ROLE_ARN }} + ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN' + + - uses: ./.github/actions/build + + - uses: ./.github/actions/publish + with: + token: ${{env.PYPI_AUTH_TOKEN}} + dry_run: ${{ inputs.dry_run }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..74740be --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,53 @@ +name: Run Release Please + +on: + push: + branches: [ main ] + +jobs: + release-package: + runs-on: ubuntu-latest + permissions: + id-token: write # Needed if using OIDC to get release secrets. + contents: write # Contents and pull-requests are for release-please to make releases. + pull-requests: write + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + command: manifest + token: ${{secrets.GITHUB_TOKEN}} + default-branch: main + + - uses: actions/checkout@v4 + if: ${{ steps.release.outputs.releases_created }} + with: + fetch-depth: 0 # If you only need the current version keep this. + + - uses: actions/setup-python@v4 + if: ${{ steps.release.outputs.releases_created }} + with: + python-version: 3.8 + + - name: Install poetry + if: ${{ steps.release.outputs.releases_created }} + run: pipx install poetry + + - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.2 + if: ${{ steps.release.outputs.releases_created }} + name: 'Get PyPI token' + with: + aws_assume_role: ${{ vars.AWS_ROLE_ARN }} + ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN' + + - uses: ./.github/actions/build + if: ${{ steps.release.outputs.releases_created }} + + - uses: ./.github/actions/build-docs + if: ${{ steps.release.outputs.releases_created }} + + - uses: ./.github/actions/publish + if: ${{ steps.release.outputs.releases_created }} + with: + token: ${{env.PYPI_AUTH_TOKEN}} + dry_run: false diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..14118d4 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,10 @@ +name: 'Close stale issues and PRs' +on: + workflow_dispatch: + schedule: + # Happen once per day at 1:30 AM + - cron: '30 1 * * *' + +jobs: + sdk-close-stale: + uses: launchdarkly/gh-actions/.github/workflows/sdk-stale.yml@main diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..466df71 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0" +} diff --git a/ld_openfeature/provider.py b/ld_openfeature/provider.py index d8f29d6..a3d67bf 100644 --- a/ld_openfeature/provider.py +++ b/ld_openfeature/provider.py @@ -19,6 +19,9 @@ def __init__(self, client: LDClient): self.__context_converter = EvaluationContextConverter() self.__details_converter = ResolutionDetailsConverter() + def shutdown(self): + self.__client.close() + def get_metadata(self) -> Metadata: return Metadata("launchdarkly-openfeature-server") diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..e06f67d --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,11 @@ +{ + "packages": { + ".": { + "release-type": "python", + "versioning": "default", + "include-v-in-tag": false, + "extra-files": ["docs/conf.py"], + "include-component-in-tag": false + } + } +}