Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Publish Docker image on GitHub Container Registry
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions

on:
workflow_dispatch:
push:
tags:
- "v*.*.*"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-publish-image:
runs-on: ubuntu-24.04

# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false # do not keep the token around

# Uses the `docker/login-action` action to log in to the Container registry using
# the account and password that will publish the packages.
- name: Log in to the Container registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for image
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
Comment thread
ziadhany marked this conversation as resolved.
tags: |
type=sha,event=workflow_dispatch,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
type=semver,pattern={{version}}
labels: |
org.opencontainers.image.title=HealthyCode
org.opencontainers.image.description=Client to generate GrimoireLab metrics for Project Health using the software analytics platform GrimoireLab
org.opencontainers.image.licenses=GPL-3.0-or-later
annotations: |
org.opencontainers.image.title=HealthyCode
org.opencontainers.image.description=Client to generate GrimoireLab metrics for Project Health using the software analytics platform GrimoireLab
org.opencontainers.image.licenses=GPL-3.0-or-later

@keshav-space keshav-space Sep 16, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, auto generated OCI labels/annotations won’t be able to accurately capture the license, description, and title.

Suggested change
labels: |
org.opencontainers.image.title=HealthyCode
org.opencontainers.image.description=Client to generate GrimoireLab metrics for Project Health using the software analytics platform GrimoireLab
org.opencontainers.image.licenses=GPL-3.0-only
annotations: |
org.opencontainers.image.title=HealthyCode
org.opencontainers.image.description=Client to generate GrimoireLab metrics for Project Health using the software analytics platform GrimoireLab
org.opencontainers.image.licenses=GPL-3.0-only

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The license should be GPL-3.0-or-later, I think. https://github.com/aboutcode-org/healthycode/blob/main/pyproject.toml#L9

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, license is ambiguous.

image image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the license specifies:

either version 3 of the License, or
    (at your option) any later version.

https://github.com/aboutcode-org/healthycode/tree/main?tab=GPL-3.0-1-ov-file

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0

- name: Build and push Docker image
id: push
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: .
push: true
tags: |
${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}

- name: Generate artifact attestation for Docker image
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM python:3.13-slim

Comment thread
ziadhany marked this conversation as resolved.
LABEL org.opencontainers.image.source="https://github.com/aboutcode-org/healthycode"
LABEL org.opencontainers.image.description="Client to generate GrimoireLab metrics for Project Health using the software analytics platform GrimoireLab"
LABEL org.opencontainers.image.licenses="GPL-3.0-or-later"

RUN apt-get update && apt-get install -y --no-install-recommends \
git build-essential \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt/healthycode

RUN pip install --no-cache-dir poetry
RUN poetry config virtualenvs.in-project true

COPY pyproject.toml poetry.lock* ./
RUN poetry install --no-interaction --no-ansi --no-root

COPY . .

RUN poetry build -f wheel \
&& .venv/bin/pip install dist/*.whl
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ grimoirelab-metrics spdx.xml \
--pony-threshold 0.5 \
--elephant-threshold 0.5 \
--dev-categories-thresholds 0.8 0.95 \
--grimoirelab-ecosystem "npm-training-set" \
--grimoirelab-project "npm-popular-components" \
--output metrics.json
```

Expand Down Expand Up @@ -109,6 +111,39 @@ This is an example of a valid SPDX file:
</Document>
```

### Running with Docker
The tool can also be run using the published Docker image. This is useful when you
do not want to install Poetry and the tool's dependencies locally.

Build the Docker image from the repository:
```bash
docker build -t healthycode .
```

Then run the tool with a Git repository as the input:

```bash
docker run --rm \
healthycode \
/opt/healthycode/.venv/bin/grimoirelab-metrics https://github.com/aboutcode/example.git \
--grimoirelab-url http://localhost:8000 \
--grimoirelab-user user --grimoirelab-password password \
--opensearch-url https://127.0.0.1:9200 \
--opensearch-index events \
--opensearch-user 'admin' --opensearch-password 'admin' \
--verify-certs --opensearch-ca-certs /path/to/ca.pem \
--from-date 2024-01-01 --to-date 2025-01-01 \
--repository-timeout 3600 \
--code-file-pattern "\.py$|\.js$" \
--binary-file-pattern "\.exe$|\.tar$" \
--pony-threshold 0.5 \
--elephant-threshold 0.5 \
--dev-categories-thresholds 0.8 0.95 \
--grimoirelab-ecosystem "npm-training-set" \
--grimoirelab-project "npm-popular-components" \
--output metrics.json
```

## Project Health Metrics

This is the list of the metrics generated by this tool:
Expand Down
Loading