Merge pull request #1270 from cloudbees-oss/disable-discord #4457
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
| # This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
| # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
| name: Python package | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ v1 ] | |
| paths-ignore: | |
| - 'WORKSPACE' | |
| - 'src/**' | |
| pull_request: | |
| branches: [ v1 ] | |
| paths-ignore: | |
| - 'WORKSPACE' | |
| - 'src/**' | |
| schedule: | |
| # This job runs at 00:00 JST every day. | |
| - cron: '0 9 * * *' | |
| env: | |
| LAUNCHABLE_ORGANIZATION: "launchableinc" | |
| LAUNCHABLE_WORKSPACE: "cli" | |
| GITHUB_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }} | |
| GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| # Python 3.6 is not supported on Ubuntu 22.04. | |
| os: [ubuntu-22.04, windows-latest] | |
| python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] | |
| include: | |
| - os: windows-latest | |
| python-version: 3.6 | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up JDK 1.8 | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | |
| with: | |
| java-version: 8 | |
| distribution: 'temurin' | |
| - name: Install specific dependencies in 3.6 | |
| if: matrix.python-version == '3.6' | |
| uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 | |
| with: | |
| max_attempts: 3 | |
| timeout_minutes: 5 | |
| retry_on: error | |
| command: | | |
| python -m pip install --upgrade pip | |
| # (Kohsuke in 2026 looking at this 2021 change) at some point, pipenv dropped the Python 3.6 support. | |
| # This version must have been one that was known to work. | |
| pip install pipenv==2021.11.5 | |
| pipenv install --dev --python ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| if: matrix.python-version != '3.6' | |
| uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 | |
| with: | |
| max_attempts: 3 | |
| timeout_minutes: 5 | |
| retry_on: error | |
| command: | | |
| python -m pip install --upgrade pip | |
| # In responding to a CI failure unrelated to my change, I noticed that a newer version of pipenv | |
| # (2026.5.2) was resolving a set of packages very differently. Normally, we'd put Pipenv.lock in Git | |
| # to prevent this type of problems, but that file is intentionally kept out of Git, and I was afraid | |
| # of changing that. So here I'm just pinning this to a version known to work. v1 is in the maintenance | |
| # mode, so this bandaid should last long enough. | |
| pip install 'pipenv<=2026.0.3' | |
| pipenv install --dev --python ${{ matrix.python-version }} | |
| - name: Build | |
| run: | | |
| pipenv run pip list | |
| pipenv run build | |
| pipenv run install | |
| - name: Type check | |
| run: pipenv run type | |
| - name: Lint with flake8 | |
| run: | | |
| # stop the build if there are Python syntax errors or undefined names | |
| pipenv run lint | |
| - name: Pull request validation | |
| run: | | |
| # Install Launchable CLI from this repos's code | |
| pip3 install . > /dev/null | |
| set -x | |
| launchable verify | |
| # Tell Launchable about the build you are producing and testing | |
| launchable record build --name ${GITHUB_RUN_ID} | |
| launchable record session --build ${GITHUB_RUN_ID} --flavor os=${{ matrix.os }} --flavor python=${{ matrix.python-version }} > session.txt | |
| # Find 25% of the relevant tests to run for this change | |
| find tests -name test_*.py | grep -v tests/data | launchable subset --target 25% --session $(cat session.txt) --rest launchable-remainder.txt file > subset.txt | |
| function record() { | |
| # Record test results | |
| LAUNCHABLE_SLACK_NOTIFICATION=true launchable record tests --session $(cat session.txt) file test-results/*.xml | |
| } | |
| trap record EXIT | |
| # Test subset of tests | |
| pipenv run test-xml $(tr '\r\n' '\n' < subset.txt) | |
| # Test rest of tests | |
| pipenv run test-xml $(tr '\r\n' '\n' < launchable-remainder.txt) | |
| shell: bash |