chore: Restrict the sdist to an allowlist and verify it in CI #935
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - uses: launchdarkly/gh-actions/actions/persistent-stores@persistent-stores-v0 | |
| with: | |
| redis: true | |
| consul: true | |
| dynamodb: true | |
| - uses: ./.github/actions/build | |
| - uses: ./.github/actions/build-docs | |
| - name: Run tests | |
| run: make test-all | |
| env: | |
| LD_SKIP_FLAKY_TESTS: true | |
| - name: Verify typehints | |
| run: make lint | |
| # | |
| # SDK contract tests | |
| # | |
| - name: install contract test dependencies | |
| run: make install-contract-tests-deps | |
| - name: start contract test service | |
| run: make start-contract-test-service-bg | |
| - name: Run contract tests v2 | |
| uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1 | |
| with: | |
| test_service_port: 9000 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| stop_service: "false" | |
| enable_persistence_tests: "true" | |
| - name: Run contract tests v3 | |
| uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1 | |
| with: | |
| test_service_port: 9000 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| version: v3 | |
| enable_persistence_tests: "true" | |
| # | |
| # Async SDK contract tests | |
| # | |
| - name: start async contract test service | |
| run: make start-async-contract-test-service-bg | |
| - name: Run async contract tests v2 | |
| uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1 | |
| with: | |
| test_service_port: 9001 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| stop_service: "false" | |
| enable_persistence_tests: "true" | |
| - name: Run async contract tests v3 | |
| uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1 | |
| with: | |
| test_service_port: 9001 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| version: v3 | |
| enable_persistence_tests: "true" | |
| # Proves the sdist is complete and functional, since the sdist file list is an | |
| # allowlist and an omission there is otherwise invisible. The test-count check | |
| # is what makes this meaningful: without it, an sdist missing half its tests | |
| # would still pass the tests it did ship. The contract-test steps cover the | |
| # other half, since a missing contract-tests directory changes no test count. | |
| sdist: | |
| name: sdist (functional) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| with: | |
| python-version: "3.13" | |
| - name: Count the tests in the checkout | |
| run: | | |
| uv sync --all-extras | |
| count=$(uv run pytest --collect-only -q | grep -oE '[0-9]+ tests? collected' | grep -oE '^[0-9]+') | |
| echo "The checkout collects $count tests." | |
| echo "checkout_tests=$count" >> "$GITHUB_ENV" | |
| - name: Build and unpack the sdist | |
| run: | | |
| uv build --sdist --out-dir dist | |
| mkdir -p "$RUNNER_TEMP/sdist" | |
| tar -xzf dist/*.tar.gz -C "$RUNNER_TEMP/sdist" --strip-components=1 | |
| - name: Check that the sdist ships every test | |
| working-directory: ${{ runner.temp }}/sdist | |
| run: | | |
| uv sync --all-extras | |
| count=$(uv run pytest --collect-only -q | grep -oE '[0-9]+ tests? collected' | grep -oE '^[0-9]+') | |
| echo "The sdist collects $count tests; the checkout collected $checkout_tests." | |
| if [ "$count" -lt "$checkout_tests" ]; then | |
| echo "::error::The sdist is missing tests. Add the missing paths to the include list in [tool.hatch.build.targets.sdist]." | |
| exit 1 | |
| fi | |
| - name: Run the tests from the sdist | |
| working-directory: ${{ runner.temp }}/sdist | |
| run: make test | |
| - name: Verify typehints from the sdist | |
| working-directory: ${{ runner.temp }}/sdist | |
| run: make lint | |
| - name: Start the contract test service from the sdist | |
| working-directory: ${{ runner.temp }}/sdist | |
| run: make start-contract-test-service-bg | |
| - name: Run contract tests against the sdist | |
| uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1 | |
| with: | |
| test_service_port: 9000 | |
| enable_persistence_tests: "false" | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Start the async contract test service from the sdist | |
| working-directory: ${{ runner.temp }}/sdist | |
| run: make start-async-contract-test-service-bg | |
| - name: Run async contract tests against the sdist | |
| uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1 | |
| with: | |
| test_service_port: 9001 | |
| enable_persistence_tests: "false" | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| windows: | |
| runs-on: windows-latest | |
| defaults: | |
| run: | |
| shell: powershell | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - uses: launchdarkly/gh-actions/actions/persistent-stores@persistent-stores-v0 | |
| with: | |
| redis: true | |
| consul: true | |
| dynamodb: true | |
| - name: Install requirements | |
| run: uv sync --all-extras | |
| - name: Run tests | |
| run: make test-all | |
| env: | |
| LD_SKIP_FLAKY_TESTS: true |