build once #32
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: Test | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| pull_request: | |
| branches: | |
| - '**' | |
| permissions: | |
| contents: read | |
| jobs: | |
| # Linting jobs run in parallel | |
| isort: | |
| name: Check import sorting (isort) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| cache-dependency-path: requirements.txt | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run isort | |
| run: pre-commit run -a isort | |
| black: | |
| name: Check code formatting (black) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| cache-dependency-path: requirements.txt | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run black | |
| run: pre-commit run -a black | |
| flake8: | |
| name: Check code style (flake8) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| cache-dependency-path: requirements.txt | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run flake8 | |
| run: pre-commit run -a flake8 | |
| pyupgrade: | |
| name: Check for Python upgrades (pyupgrade) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| cache-dependency-path: requirements.txt | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run pyupgrade | |
| run: pre-commit run -a pyupgrade | |
| pylint: | |
| name: Run comprehensive linting (pylint) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| cache-dependency-path: requirements.txt | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run pylint | |
| run: pylint --rcfile=.pylintrc cloudsmith_cli | |
| # Test jobs run across Python versions | |
| pytest: | |
| name: Run tests (Python ${{ matrix.python-version }}) | |
| 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@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| cache-dependency-path: requirements.txt | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Install package | |
| run: pip install -e . | |
| - name: Run pytest | |
| env: | |
| PYTEST_CLOUDSMITH_API_KEY: ${{ secrets.PYTEST_CLOUDSMITH_API_KEY }} | |
| PYTEST_CLOUDSMITH_API_HOST: ${{ vars.PYTEST_CLOUDSMITH_API_HOST }} | |
| PYTEST_CLOUDSMITH_ORGANIZATION: ${{ vars.PYTEST_CLOUDSMITH_ORGANIZATION }} | |
| run: pytest --junitxml=./reports/pytest.xml | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-${{ matrix.python-version }} | |
| path: ./reports/pytest.xml | |
| retention-days: 30 | |
| # Build zipapp once | |
| build-zipapp: | |
| name: Build zipapp | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| - name: Cache PEX dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.pex | |
| key: pex-${{ runner.os }}-${{ hashFiles('setup.py', 'requirements.txt') }} | |
| restore-keys: | | |
| pex-${{ runner.os }}- | |
| - name: Install pex | |
| run: pip install pex | |
| - name: Get version | |
| id: get_version | |
| run: echo "VERSION=$(cat cloudsmith_cli/data/VERSION)" >> $GITHUB_ENV | |
| - name: Create Zipapp | |
| run: | | |
| pex . \ | |
| -o cloudsmith-${{ env.VERSION }}.pyz \ | |
| --console-script cloudsmith \ | |
| --python-shebang "/usr/bin/env python3" \ | |
| --venv | |
| - name: Upload zipapp artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cloudsmith-zipapp | |
| path: cloudsmith-${{ env.VERSION }}.pyz | |
| retention-days: 1 | |
| # Test zipapp across Python versions and platforms | |
| test-zipapp: | |
| name: Test zipapp (Python ${{ matrix.python-version }} on ${{ matrix.os }}) | |
| needs: build-zipapp | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Get version | |
| id: get_version | |
| run: echo "VERSION=$(cat cloudsmith_cli/data/VERSION)" >> $GITHUB_ENV | |
| - name: Download zipapp artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cloudsmith-zipapp | |
| - name: Make executable (Unix) | |
| if: runner.os != 'Windows' | |
| run: chmod +x cloudsmith-${{ env.VERSION }}.pyz | |
| - name: Validate zipapp execution (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| OUTPUT=$(./cloudsmith-${{ env.VERSION }}.pyz --version) | |
| echo "Zipapp Version: $OUTPUT" | |
| echo "$OUTPUT" | grep "${{ env.VERSION }}" | |
| - name: Validate zipapp execution (Windows) | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: | | |
| OUTPUT=$(python cloudsmith-${{ env.VERSION }}.pyz --version) | |
| echo "Zipapp Version: $OUTPUT" | |
| echo "$OUTPUT" | grep "${{ env.VERSION }}" | |
| - name: Test help command | |
| shell: bash | |
| run: | | |
| if [ "${{ runner.os }}" = "Windows" ]; then | |
| python cloudsmith-${{ env.VERSION }}.pyz --help | |
| else | |
| ./cloudsmith-${{ env.VERSION }}.pyz --help | |
| fi | |
| - name: Test check command | |
| shell: bash | |
| run: | | |
| if [ "${{ runner.os }}" = "Windows" ]; then | |
| python cloudsmith-${{ env.VERSION }}.pyz check service | |
| else | |
| ./cloudsmith-${{ env.VERSION }}.pyz check service | |
| fi |