diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 00000000..5b9bf57a --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,61 @@ +name: Continuous Deployment + +on: + workflow_run: + workflows: ["Continuous Integration"] + types: + - completed + +env: + UV_CACHE_DIR: /tmp/.uv-cache + +jobs: + cd: + name: Deploy Release + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + steps: + - name: Checkout Repository + uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + ref: main + + - name: Set up UV Environment + uses: astral-sh/setup-uv@v3.2.0 + with: + enable-cache: true + cache-dependency-glob: uv.lock + + - name: Run Python Semantic Release + id: release + uses: python-semantic-release/python-semantic-release@v9.12.0 + with: + github_token: '${{ secrets.GITHUB_TOKEN }}' + git_committer_name: 'MountainGod2' + git_committer_email: 'admin@reid.ca' + ssh_private_signing_key: '${{ secrets.GIT_COMMIT_SSH_PRIV_KEY }}' + ssh_public_signing_key: '${{ secrets.GIT_COMMIT_SSH_PUB_KEY }}' + + - name: Publish to TestPyPI + if: steps.release.outputs.released == 'true' + uses: pypa/gh-action-pypi-publish@v1.10.3 + with: + repository-url: 'https://test.pypi.org/legacy/' + + - name: Test Install from TestPyPI + if: steps.release.outputs.released == 'true' + run: | + pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple chaturbate-poller + + - name: Publish to PyPI + if: steps.release.outputs.released == 'true' + uses: pypa/gh-action-pypi-publish@v1.10.3 + + - name: Publish to GitHub Releases + if: steps.release.outputs.released == 'true' + uses: python-semantic-release/publish-action@v9.12.0 + with: + github_token: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/ci-cd-build.yml b/.github/workflows/ci-cd-build.yml deleted file mode 100644 index 88f418f9..00000000 --- a/.github/workflows/ci-cd-build.yml +++ /dev/null @@ -1,184 +0,0 @@ -name: CI/CD Pipeline - -on: - push: - branches: - - main - pull_request: - branches: - - main - -env: - UV_CACHE_DIR: /tmp/.uv-cache - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - ci: - name: Continuous Integration (Tests, Linting, Docs) - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.11, 3.12, 3.13] - fail-fast: true - timeout-minutes: 20 - steps: - - name: Checkout Repository - uses: actions/checkout@v4.2.2 - with: - fetch-depth: 0 - - - name: Set up UV Environment - uses: astral-sh/setup-uv@v3.2.0 - with: - enable-cache: true - cache-dependency-glob: uv.lock - - - name: Restore UV Cache - uses: actions/cache@v4.1.2 - with: - path: ${{ env.UV_CACHE_DIR }} - key: "uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}" - restore-keys: | - uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} - uv-${{ runner.os }} - - - name: Install Dependencies and Sync Project - run: uv sync - - - name: Run Formatting, Linting, Type Checks, and Tests - run: | - uv run ruff format ./ - uv run ruff check --fix ./ - uv run mypy ./ - uv run pytest ./ - - - name: Upload Test Coverage to Codecov - uses: codecov/codecov-action@v4.6.0 - with: - token: '${{ secrets.CODECOV_TOKEN }}' - file: ./coverage.xml - fail_ci_if_error: true - - - name: Scan with SonarCloud - uses: SonarSource/sonarcloud-github-action@v3.1.0 - env: - SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}' - - - name: Build Documentation - run: uv run --group=docs make clean html --directory docs/ - - - name: Upload Documentation to GitHub Pages - uses: peaceiris/actions-gh-pages@v4.0.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/_build/html - - - name: Minimize UV Cache - run: uv cache prune --ci - - cd: - name: Continuous Deployment (Release and Publish) - needs: ci - permissions: - id-token: write - contents: write - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4.2.2 - with: - fetch-depth: 0 - ref: main - - - name: Set up UV Environment - uses: astral-sh/setup-uv@v3.2.0 - with: - enable-cache: true - cache-dependency-glob: uv.lock - - - name: Run Python Semantic Release - id: release - uses: python-semantic-release/python-semantic-release@v9.12.0 - with: - github_token: '${{ secrets.GITHUB_TOKEN }}' - git_committer_name: 'MountainGod2' - git_committer_email: 'admin@reid.ca' - ssh_private_signing_key: '${{ secrets.GIT_COMMIT_SSH_PRIV_KEY }}' - ssh_public_signing_key: '${{ secrets.GIT_COMMIT_SSH_PUB_KEY }}' - - - name: Publish to TestPyPI - if: steps.release.outputs.released == 'true' - uses: pypa/gh-action-pypi-publish@v1.10.3 - with: - repository-url: 'https://test.pypi.org/legacy/' - - - name: Test Install from TestPyPI - if: steps.release.outputs.released == 'true' - run: | - pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple chaturbate-poller - - - name: Publish to PyPI - if: steps.release.outputs.released == 'true' - uses: pypa/gh-action-pypi-publish@v1.10.3 - - - name: Publish to GitHub Releases - if: steps.release.outputs.released == 'true' - uses: python-semantic-release/publish-action@v9.12.0 - with: - github_token: '${{ secrets.GITHUB_TOKEN }}' - - build: - name: Build and Push Docker Image - needs: [ci, cd] - runs-on: ubuntu-latest - strategy: - matrix: - platform: [linux/amd64, linux/arm64] - steps: - - name: Checkout Repository - uses: actions/checkout@v4.2.2 - with: - fetch-depth: 0 - - - name: Set up QEMU for Multi-Architecture Builds - uses: docker/setup-qemu-action@v3.2.0 - - - name: Set up Docker Buildx for Multi-Platform Builds - uses: docker/setup-buildx-action@v3.7.1 - - - name: Generate Docker Image Metadata - id: meta - uses: docker/metadata-action@v5.5.1 - with: - images: ghcr.io/mountaingod2/chaturbate_poller - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=raw,value={{ sha }},prefix=commit- - type=raw,value=latest,enable={{is_default_branch}} - - - name: Log in to GitHub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: '${{ github.repository_owner }}' - password: '${{ secrets.GITHUB_TOKEN }}' - - - name: Build and Push Docker Image - uses: docker/build-push-action@v6.9.0 - with: - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64 - - - name: Run Docker Image Tests - run: docker run --rm ghcr.io/mountaingod2/chaturbate_poller:latest --version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..05c077ff --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +name: Continuous Integration + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + UV_CACHE_DIR: /tmp/.uv-cache + +jobs: + ci: + name: Run Tests, Linting, and Build Documentation + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.11, 3.12, 3.13] + fail-fast: true + timeout-minutes: 20 + steps: + - name: Checkout Repository + uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + + - name: Set up UV Environment + uses: astral-sh/setup-uv@v3.2.0 + with: + enable-cache: true + cache-dependency-glob: uv.lock + + - name: Restore UV Cache + uses: actions/cache@v4.1.2 + with: + path: ${{ env.UV_CACHE_DIR }} + key: "uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}" + restore-keys: | + uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} + uv-${{ runner.os }} + + - name: Install Dependencies and Sync Project + run: uv sync + + - name: Run Formatting, Linting, Type Checks, and Tests + run: | + uv run ruff format ./ + uv run ruff check --fix ./ + uv run mypy ./ + uv run pytest ./ + + - name: Upload Test Coverage to Codecov + uses: codecov/codecov-action@v4.6.0 + with: + token: '${{ secrets.CODECOV_TOKEN }}' + file: ./coverage.xml + fail_ci_if_error: true + + - name: Scan with SonarCloud + uses: SonarSource/sonarcloud-github-action@v3.1.0 + env: + SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}' + + - name: Build Documentation + run: uv run --group=docs make clean html --directory docs/ + + - name: Upload Documentation to GitHub Pages + uses: peaceiris/actions-gh-pages@v4.0.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/_build/html + + - name: Minimize UV Cache + run: uv cache prune --ci diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..af367550 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,61 @@ +name: Docker Build and Push + +on: + workflow_run: + workflows: ["Continuous Integration", "Continuous Deployment"] + types: + - completed + +jobs: + build: + name: Build and Push Docker Image + runs-on: ubuntu-latest + needs: ["Continuous Integration", "Continuous Deployment"] + strategy: + matrix: + platform: [linux/amd64, linux/arm64] + steps: + - name: Checkout Repository + uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + + - name: Set up QEMU for Multi-Architecture Builds + uses: docker/setup-qemu-action@v3.2.0 + + - name: Set up Docker Buildx for Multi-Platform Builds + uses: docker/setup-buildx-action@v3.7.1 + + - name: Generate Docker Image Metadata + id: meta + uses: docker/metadata-action@v5.5.1 + with: + images: ghcr.io/mountaingod2/chaturbate_poller + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value={{ sha }},prefix=commit- + type=raw,value=latest,enable={{is_default_branch}} + + - name: Log in to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3.3.0 + with: + registry: ghcr.io + username: '${{ github.repository_owner }}' + password: '${{ secrets.GITHUB_TOKEN }}' + + - name: Build and Push Docker Image + uses: docker/build-push-action@v6.9.0 + with: + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + + - name: Run Docker Image Tests + run: docker run --rm ghcr.io/mountaingod2/chaturbate_poller:latest --version