Improve GitHub Actions #8
Workflow file for this run
This file contains 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: | |
- 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/[email protected] | |
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/[email protected] | |
- 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/[email protected] | |
- 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 |