Skip to content

chore(CENG-598): Migrate pipelines from CircleCi to GHA #51

chore(CENG-598): Migrate pipelines from CircleCi to GHA

chore(CENG-598): Migrate pipelines from CircleCi to GHA #51

Workflow file for this run

name: Test
on:
push:
branches:
- master
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: test-results-${{ matrix.python-version }}
path: ./reports/pytest.xml
retention-days: 30
# Build zipapp once with PEX on Python 3.10
build-zipapp-pex:
name: Build zipapp with PEX (Python 3.10)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up Python 3.10
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.10"
cache: "pip"
- name: Install PEX
run: |
python -m pip install --upgrade pip
pip install pex
- name: Get version
id: get_version
run: echo "VERSION=$(cat cloudsmith_cli/data/VERSION)" >> $GITHUB_ENV
- name: Create multi-platform Zipapp with PEX
run: |
pex . \
--output-file "cloudsmith-${VERSION}.pyz" \
--console-script cloudsmith \
--python-shebang "/usr/bin/env python3" \
--venv \
--complete-platform .github/.platforms/linux-x86_64-py310.json \
--complete-platform .github/.platforms/linux-aarch64-py310.json \
--complete-platform .github/.platforms/linux-x86_64-musl-py310.json \
--complete-platform .github/.platforms/linux-aarch64-musl-py310.json \
--complete-platform .github/.platforms/macos-arm64-py310.json \
--complete-platform .github/.platforms/windows-x86_64-py310.json \
--complete-platform .github/.platforms/linux-x86_64-py311.json \
--complete-platform .github/.platforms/linux-aarch64-py311.json \
--complete-platform .github/.platforms/linux-x86_64-musl-py311.json \
--complete-platform .github/.platforms/linux-aarch64-musl-py311.json \
--complete-platform .github/.platforms/macos-arm64-py311.json \
--complete-platform .github/.platforms/windows-x86_64-py311.json \
--complete-platform .github/.platforms/linux-x86_64-py312.json \
--complete-platform .github/.platforms/linux-aarch64-py312.json \
--complete-platform .github/.platforms/linux-x86_64-musl-py312.json \
--complete-platform .github/.platforms/linux-aarch64-musl-py312.json \
--complete-platform .github/.platforms/macos-arm64-py312.json \
--complete-platform .github/.platforms/windows-x86_64-py312.json \
--complete-platform .github/.platforms/linux-x86_64-py313.json \
--complete-platform .github/.platforms/linux-aarch64-py313.json \
--complete-platform .github/.platforms/linux-x86_64-musl-py313.json \
--complete-platform .github/.platforms/linux-aarch64-musl-py313.json \
--complete-platform .github/.platforms/macos-arm64-py313.json \
--complete-platform .github/.platforms/windows-x86_64-py313.json \
--complete-platform .github/.platforms/linux-x86_64-py314.json \
--complete-platform .github/.platforms/linux-aarch64-py314.json \
--complete-platform .github/.platforms/linux-x86_64-musl-py314.json \
--complete-platform .github/.platforms/linux-aarch64-musl-py314.json \
--complete-platform .github/.platforms/macos-arm64-py314.json \
--complete-platform .github/.platforms/windows-x86_64-py314.json
- name: Upload zipapp artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: cloudsmith-zipapp
path: cloudsmith-${{ env.VERSION }}.pyz
retention-days: 7
# Test PEX-built zipapp on Alpine Linux (musl)
test-zipapp-alpine:
name: Test zipapp on Alpine (musl) - Python ${{ matrix.python-version }}
needs: build-zipapp-pex
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
container:
image: python:${{ matrix.python-version }}-alpine
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Get version
id: get_version
run: echo "VERSION=$(cat cloudsmith_cli/data/VERSION)" >> $GITHUB_ENV
- name: Download zipapp artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: cloudsmith-zipapp
- name: Make zipapp executable
run: chmod +x "cloudsmith-${VERSION}.pyz"
- name: Validate zipapp execution
run: |
OUTPUT=$(./"cloudsmith-${VERSION}.pyz" --version)
echo "Zipapp Version: $OUTPUT"
echo "$OUTPUT" | grep "${VERSION}"
# Test PEX-built zipapp on Linux ARM64 (via QEMU)
test-zipapp-arm64:
name: Test zipapp on Linux ARM64 - Python ${{ matrix.python-version }}
needs: build-zipapp-pex
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: linux/arm64
- name: Get version
id: get_version
run: echo "VERSION=$(cat cloudsmith_cli/data/VERSION)" >> $GITHUB_ENV
- name: Download zipapp artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: cloudsmith-zipapp
- name: Test zipapp on ARM64
run: |
docker run --rm --platform linux/arm64 \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
-e "VERSION=${VERSION}" \
python:${{ matrix.python-version }}-slim \
sh -c 'chmod +x "cloudsmith-${VERSION}.pyz" && ./"cloudsmith-${VERSION}.pyz" --version | grep "${VERSION}"'
# Test PEX-built zipapp across OSes and Python versions
test-zipapp-build:
name: Test zipapp build (OS ${{ matrix.os }}, Python ${{ matrix.python-version }})
needs: build-zipapp-pex
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}
- name: Get version (Unix)
if: runner.os != 'Windows'
run: echo "VERSION=$(cat cloudsmith_cli/data/VERSION)" >> $GITHUB_ENV
- name: Get version (Windows)
if: runner.os == 'Windows'
run: |
$version = Get-Content cloudsmith_cli/data/VERSION -Raw
$version = $version.Trim()
echo "VERSION=$version" >> $env:GITHUB_ENV
- name: Download zipapp artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: cloudsmith-zipapp
- name: Make zipapp executable (non-Windows)
if: runner.os != 'Windows'
run: chmod +x "cloudsmith-${VERSION}.pyz"
- name: Validate zipapp execution (non-Windows)
if: runner.os != 'Windows'
run: |
OUTPUT=$(./"cloudsmith-${VERSION}.pyz" --version)
echo "Zipapp Version: $OUTPUT"
echo "$OUTPUT" | grep "${VERSION}"
- name: Validate zipapp execution (Windows)
if: runner.os == 'Windows'
run: |
$output = python "cloudsmith-$env:VERSION.pyz" --version 2>&1 | Out-String
if (-not ($output -like "*$env:VERSION*")) {
throw "Version validation failed. Expected: $env:VERSION"
}