diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index f474cc8..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: CI -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - id: setup-python - with: - python-version: 3.12 - - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v4 - with: - path: .venv - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} - - - name: Install dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: | - poetry install --no-interaction --no-root - - - name: Format - run: | - source .venv/bin/activate - black . --check - - - name: Type Check - run: | - source .venv/bin/activate - mypy . - - - name: Lint - run: | - source .venv/bin/activate - pylint $(git ls-files -- '*.py' ':!:**/migrations/*.py') - - test: - name: Test - runs-on: ubuntu-latest - services: - redis: - image: redis:6 - ports: ['6379:6379'] - rabbitmq: - image: rabbitmq:3 - ports: ['5672:5672'] - strategy: - matrix: - broker: [memory, redis, rabbitmq] - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - id: setup-python - with: - python-version: 3.12 - - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v4 - with: - path: .venv - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} - - - name: Install dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: | - poetry install --no-interaction --no-root - source .venv/bin/activate - - - name: Test - run: | - source .venv/bin/activate - pytest --broker=${{ matrix.broker }} --ignore .poetry --cov diff --git a/.github/workflows/helm-release.yml b/.github/workflows/helm-release.yml deleted file mode 100644 index 2586449..0000000 --- a/.github/workflows/helm-release.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Release Charts - -on: - push: - branches: - - master - -jobs: - release: - # depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions - # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token - permissions: - contents: write - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Configure Git - run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - - name: Set up Helm - uses: azure/setup-helm@v4.2.0 - with: - version: v3.14.4 - - - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.6.0 - env: - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - CR_RELEASE_NAME_TEMPLATE: "{{ .Name }}-chart-{{ .Version }}" diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml deleted file mode 100644 index bc70c0d..0000000 --- a/.github/workflows/helm-test.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Lint and Test Charts - -on: pull_request - -jobs: - lint-test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Helm - uses: azure/setup-helm@v4.2.0 - with: - version: v3.14.4 - - - uses: actions/setup-python@v5 - with: - python-version: "3.x" - check-latest: true - - - name: Set up chart-testing - uses: helm/chart-testing-action@v2.6.1 - - - name: Run chart-testing (list-changed) - id: list-changed - run: | - changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) - if [[ -n "$changed" ]]; then - echo "changed=true" >> "$GITHUB_OUTPUT" - fi - - - name: Run chart-testing (lint) - if: steps.list-changed.outputs.changed == 'true' - run: ct lint --target-branch ${{ github.event.repository.default_branch }} - - - name: Create kind cluster - if: steps.list-changed.outputs.changed == 'true' - uses: helm/kind-action@v1.10.0 - - - name: Run chart-testing (install) - if: steps.list-changed.outputs.changed == 'true' - run: ct install --target-branch ${{ github.event.repository.default_branch }} diff --git a/.github/workflows/push-image-ghcr.yml b/.github/workflows/push-image-ghcr.yml deleted file mode 100644 index 5e60097..0000000 --- a/.github/workflows/push-image-ghcr.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Create and publish a Docker image to ghcr.io - -on: - push: - tags: - - "v[0-9]+.[0-9]+.[0-9]+" - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - build-and-push-image: - runs-on: ubuntu-latest - permissions: - contents: write - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=sha,enable=true,priority=100,prefix=,suffix=,format=short - type=semver,pattern={{version}},value=${{ github.ref_name }} - - - name: Build and push - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64,linux/arm64 - provenance: false - push: true - tags: ${{ steps.meta.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..146b326 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,104 @@ +name: Release + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + +jobs: + github: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref_name }} + release_name: Version ${{ github.ref_name }} + draft: false + prerelease: false + + docker-hub: + needs: github + runs-on: ubuntu-latest + env: + IMAGE: danihodovic/celery-exporter + permissions: + contents: write + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Prepare Image Metadata + id: metadata + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.IMAGE }} + ghcr.io/${{ env.IMAGE }} + - name: Set Up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set Up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login To Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Login to Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build, tag, and push image to Docker Hub + uses: docker/build-push-action@v6 + with: + cache-from: type=gha + cache-to: type=gha,mode=max + context: . + platforms: linux/amd64,linux/arm64 + push: true + annotations: ${{ steps.metadata.outputs.annotations }} + labels: ${{ steps.metadata.outputs.labels }} + tags: ${{ steps.metadata.outputs.tags }} + - name: Update Description On Docker Hub Description + uses: peter-evans/dockerhub-description@v4 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + repository: ${{ env.IMAGE }} + + helm-chart: + runs-on: ubuntu-latest + needs: github + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Set Up Helm + uses: azure/setup-helm@v4.2.0 + with: + version: v3.14.4 + - name: Get Chart Version + id: chart-version + run: echo "::set-output name=version::$(grep 'version:' ./charts/celery-exporter/Chart.yaml | cut -d ' ' -f 2)" + - name: Package Helm chart + run: helm package ./charts/celery-exporter --app-version=${{ github.ref_name }} + - name: Upload To Github Release + uses: softprops/action-gh-release@v2 + with: + files: | + celery-exporter-${{ steps.chart-version.outputs.version }}.tgz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..03d0c08 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,154 @@ +name: Test + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + docker-build: + runs-on: ubuntu-latest + env: + IMAGE: danihodovic/celery-exporter + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Prepare Image Metadata + id: metadata + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE }} + - name: Set Up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set Up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Test Multi-Arch Building Of Image + uses: docker/build-push-action@v6 + with: + cache-from: type=gha + cache-to: type=gha,mode=max + context: . + platforms: linux/amd64,linux/arm64 + push: false + annotations: ${{ steps.metadata.outputs.annotations }} + labels: ${{ steps.metadata.outputs.labels }} + tags: ${{ steps.metadata.outputs.tags }} + + helm-chart: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set Up Helm + uses: azure/setup-helm@v4.2.0 + with: + version: v3.14.4 + - name: Set Up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + check-latest: true + - name: Set Up Chart-Testing + uses: helm/chart-testing-action@v2.6.1 + - name: Run Chart-Testing (List-Changed) + id: list-changed + run: | + changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + - name: Run Chart-Testing (Lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --target-branch ${{ github.event.repository.default_branch }} + - name: Create Kind Cluster + if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1.10.0 + - name: Run Chart-Testing (Install) + if: steps.list-changed.outputs.changed == 'true' + run: ct install --target-branch ${{ github.event.repository.default_branch }} + + pylint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set Up Python + uses: actions/setup-python@v5 + id: setup-python + with: + python-version: 3.12 + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: Load Cached Venv + id: cached-poetry-dependencies + uses: actions/cache@v4 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + - name: Install Dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: | + poetry install --no-interaction --no-root + - name: Format + run: | + source .venv/bin/activate + black . --check + - name: Type Check + run: | + source .venv/bin/activate + mypy . + - name: Run Pylint + run: | + source .venv/bin/activate + pylint $(git ls-files -- '*.py' ':!:**/migrations/*.py') + + pytest: + runs-on: ubuntu-latest + services: + redis: + image: redis:6 + ports: ['6379:6379'] + rabbitmq: + image: rabbitmq:3 + ports: ['5672:5672'] + strategy: + matrix: + broker: [memory, redis, rabbitmq] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set Up Python + uses: actions/setup-python@v5 + id: setup-python + with: + python-version: 3.12 + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: Load Cached Venv + id: cached-poetry-dependencies + uses: actions/cache@v4 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + - name: Install Dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: | + poetry install --no-interaction --no-root + source .venv/bin/activate + - name: Run Pytest + run: | + source .venv/bin/activate + pytest --broker=${{ matrix.broker }} --ignore .poetry --cov diff --git a/charts/celery-exporter/Chart.yaml b/charts/celery-exporter/Chart.yaml index 3d52834..1ed22d4 100644 --- a/charts/celery-exporter/Chart.yaml +++ b/charts/celery-exporter/Chart.yaml @@ -12,6 +12,4 @@ sources: maintainers: - name: danihodovic - name: adinhodovic - -version: 0.7.0 -appVersion: 0.9.2 +version: 0.7.1