Compare commits
45
Commits
0.1.0
..
c929fdfda6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c929fdfda6 | ||
|
|
3d2c0487b7 | ||
|
|
cb89a1c6b9 | ||
|
|
5e27a5bc93 | ||
|
|
f52a3449c6 | ||
|
|
ca94b80beb | ||
|
|
cd326a34ba | ||
|
|
8fb7781227 | ||
|
|
1e2f022579 | ||
|
|
c89b4e9212 | ||
|
|
5c47888a49 | ||
|
|
f2bf24994c | ||
|
|
fcf841f7ad | ||
|
|
9b631f4777 | ||
|
|
596260bb85 | ||
|
|
9f3c54afd1 | ||
|
|
11bec43bbe | ||
|
|
09c0be8312 | ||
|
|
6d6680ca37 | ||
|
|
406da07397 | ||
|
|
d5d948f423 | ||
|
|
a6e904fc61 | ||
|
|
980463f715 | ||
|
|
095b9675f9 | ||
|
|
8dbfef8496 | ||
|
|
a527eada56 | ||
|
|
423ac5470d | ||
|
|
4e992c8f79 | ||
|
|
4983492088 | ||
|
|
169fa8c76a | ||
|
|
4cefba1a37 | ||
|
|
28a0916487 | ||
|
|
4cfa61f1c0 | ||
|
|
2f3268c0b7 | ||
|
|
89d0e2b0f6 | ||
|
|
fad176419c | ||
|
|
3743ba31d2 | ||
|
|
8a675cf02f | ||
|
|
20c5acc5ae | ||
|
|
21867256e8 | ||
|
|
67d4a50ee1 | ||
|
|
e72ee2541e | ||
|
|
ecdb8c1716 | ||
|
|
841f4329de | ||
|
|
50256c97ef |
+32
-1
@@ -1,6 +1,37 @@
|
|||||||
|
# Build descriptors (not application code)
|
||||||
|
Dockerfile*
|
||||||
|
|
||||||
|
# Version control
|
||||||
.git
|
.git
|
||||||
.gitea
|
.gitea
|
||||||
|
|
||||||
|
# AI / IDE tooling
|
||||||
|
.claude
|
||||||
|
|
||||||
|
# Dev tooling
|
||||||
|
.gitignore
|
||||||
|
/.phpunit.cache
|
||||||
|
phpunit.xml.dist
|
||||||
|
tests/
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
CHANGELOG.md
|
||||||
|
CLAUDE.md
|
||||||
|
README.md
|
||||||
|
|
||||||
|
# Compose / deployment descriptors (not app code)
|
||||||
|
docker-compose.yml
|
||||||
|
docker-compose.override.yml
|
||||||
|
docker-compose.prod.yml
|
||||||
|
|
||||||
|
# Dependencies — re-installed from lockfile in the build stage;
|
||||||
|
# a local vendor/ in the build context would silently override the clean install
|
||||||
|
vendor/
|
||||||
|
|
||||||
|
# Runtime dirs (generated at build or run time, not from source)
|
||||||
var/
|
var/
|
||||||
|
|
||||||
|
# Env files — .env contains only placeholder defaults and is needed by composer dump-env;
|
||||||
|
# local overrides with real secrets stay excluded
|
||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
docker-compose.override.yml
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: 'Release tag (semver, e.g. 1.2.3)'
|
description: "Release tag (semver, e.g. 1.2.3)"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
@@ -55,8 +55,6 @@ jobs:
|
|||||||
images: ${{ env.REGISTRY }}/${{ gitea.repository }}
|
images: ${{ env.REGISTRY }}/${{ gitea.repository }}
|
||||||
tags: |
|
tags: |
|
||||||
type=semver,pattern={{version}},value=${{ inputs.tag }}
|
type=semver,pattern={{version}},value=${{ inputs.tag }}
|
||||||
type=semver,pattern={{major}}.{{minor}},value=${{ inputs.tag }}
|
|
||||||
type=semver,pattern={{major}},value=${{ inputs.tag }}
|
|
||||||
labels: |
|
labels: |
|
||||||
org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}
|
org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}
|
||||||
|
|
||||||
@@ -75,10 +73,22 @@ jobs:
|
|||||||
username: ${{ gitea.actor }}
|
username: ${{ gitea.actor }}
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
# Build a single-arch image locally so Trivy can inspect it before the real push.
|
||||||
|
- name: Build local image for scanning
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
target: final
|
||||||
|
platforms: linux/amd64
|
||||||
|
load: true
|
||||||
|
tags: scan-target:${{ inputs.tag }}
|
||||||
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
target: final
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
|||||||
@@ -3,5 +3,4 @@
|
|||||||
/vendor/
|
/vendor/
|
||||||
/var/
|
/var/
|
||||||
/public/bundles/
|
/public/bundles/
|
||||||
composer.lock
|
|
||||||
/.phpunit.cache
|
/.phpunit.cache
|
||||||
|
|||||||
+27
-25
@@ -1,9 +1,16 @@
|
|||||||
|
#syntax=docker/dockerfile:1
|
||||||
|
|
||||||
FROM dunglas/frankenphp:1-php8.4-alpine AS base
|
FROM dunglas/frankenphp:1-php8.4-alpine AS base
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache icu-dev libzip-dev \
|
||||||
curl \
|
&& docker-php-ext-install -j$(nproc) intl opcache zip \
|
||||||
icu-libs \
|
&& apk del icu-dev libzip-dev \
|
||||||
libzip
|
&& apk add --no-cache curl icu-libs libzip \
|
||||||
|
&& cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
|
||||||
|
&& mkdir -p $PHP_INI_DIR/app.conf.d
|
||||||
|
|
||||||
|
ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d"
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -21,34 +28,29 @@ RUN composer install \
|
|||||||
# ── build stage (generate optimised classmap with source present) ──────────────
|
# ── build stage (generate optimised classmap with source present) ──────────────
|
||||||
FROM deps AS build
|
FROM deps AS build
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN composer dump-autoload --optimize --no-dev --no-interaction
|
RUN composer dump-autoload --classmap-authoritative --no-dev --no-interaction && \
|
||||||
|
mkdir -p var/cache var/log && \
|
||||||
# ── dev stage (all deps + Xdebug, source is mounted at runtime) ───────────────
|
APP_ENV=prod APP_SECRET=placeholder php bin/console cache:warmup --no-debug && \
|
||||||
FROM base AS dev
|
composer dump-env prod
|
||||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
|
||||||
RUN apk add --no-cache ${PHPIZE_DEPS} linux-headers \
|
|
||||||
&& pecl install xdebug \
|
|
||||||
&& docker-php-ext-enable xdebug \
|
|
||||||
&& apk del ${PHPIZE_DEPS}
|
|
||||||
COPY docker/php/xdebug.ini /usr/local/etc/php/conf.d/docker-xdebug.ini
|
|
||||||
COPY docker/frankenphp/Caddyfile.dev /etc/caddy/Caddyfile
|
|
||||||
COPY composer.json composer.lock* ./
|
|
||||||
RUN composer install --no-scripts --no-interaction --prefer-dist
|
|
||||||
EXPOSE 8080
|
|
||||||
ENV APP_ENV=dev APP_DEBUG=1
|
|
||||||
CMD ["frankenphp", "run", "--config", "/etc/caddy/Caddyfile"]
|
|
||||||
|
|
||||||
# ── final (prod) stage — no composer binary ────────────────────────────────────
|
# ── final (prod) stage — no composer binary ────────────────────────────────────
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
|
|
||||||
RUN addgroup -S app && adduser -S -G app app
|
RUN addgroup -S app && adduser -S -G app app
|
||||||
|
|
||||||
COPY --from=build /app/vendor /app/vendor
|
COPY --link --from=build /app/vendor /app/vendor
|
||||||
COPY . .
|
COPY --link --from=build /app/var/cache/prod /app/var/cache/prod
|
||||||
COPY docker/frankenphp/Caddyfile /etc/caddy/Caddyfile
|
COPY --link bin/ ./bin/
|
||||||
|
COPY --link config/ ./config/
|
||||||
|
COPY --link public/ ./public/
|
||||||
|
COPY --link src/ ./src/
|
||||||
|
COPY --link composer.json composer.lock ./
|
||||||
|
COPY --link docker/frankenphp/Caddyfile /etc/caddy/Caddyfile
|
||||||
|
COPY --link docker/php/conf.d/20-app.prod.ini $PHP_INI_DIR/app.conf.d/
|
||||||
|
|
||||||
RUN mkdir -p var/cache var/log \
|
RUN chmod +x bin/console && \
|
||||||
&& chown -R app:app /app
|
mkdir -p var/cache/prod/pools var/log /config/caddy /data/caddy && \
|
||||||
|
chown -R app:app /app /config /data
|
||||||
|
|
||||||
USER app
|
USER app
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
FROM dunglas/frankenphp:1-php8.4-alpine
|
||||||
|
|
||||||
|
RUN apk add --no-cache icu-dev libzip-dev \
|
||||||
|
&& docker-php-ext-install -j$(nproc) intl opcache zip \
|
||||||
|
&& apk del icu-dev libzip-dev \
|
||||||
|
&& apk add --no-cache curl icu-libs libzip \
|
||||||
|
&& cp "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" \
|
||||||
|
&& mkdir -p $PHP_INI_DIR/app.conf.d
|
||||||
|
|
||||||
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
RUN apk add --no-cache ${PHPIZE_DEPS} linux-headers \
|
||||||
|
&& pecl install xdebug \
|
||||||
|
&& docker-php-ext-enable xdebug \
|
||||||
|
&& apk del ${PHPIZE_DEPS}
|
||||||
|
|
||||||
|
ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d"
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY docker/php/xdebug.ini /usr/local/etc/php/conf.d/docker-xdebug.ini
|
||||||
|
COPY docker/php/conf.d/20-app.dev.ini $PHP_INI_DIR/app.conf.d/
|
||||||
|
COPY docker/frankenphp/Caddyfile.dev /etc/caddy/Caddyfile
|
||||||
|
COPY composer.json composer.lock* ./
|
||||||
|
RUN composer install --no-scripts --no-interaction --prefer-dist
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
ENV APP_ENV=dev APP_DEBUG=1
|
||||||
|
CMD ["frankenphp", "run", "--config", "/etc/caddy/Caddyfile"]
|
||||||
@@ -29,7 +29,7 @@ https://your-host/graph.svg?theme=dark
|
|||||||
|
|
||||||
### 1. Create a `docker-compose.yml`
|
### 1. Create a `docker-compose.yml`
|
||||||
|
|
||||||
Use the pre-built image — no need to clone the repo:
|
Use the pre-built image
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
# TODO: persist contribution history in SQLite + audit cleanup
|
||||||
|
|
||||||
|
Backend-only work. Follow Red → Green → Refactor per `CLAUDE.md` for every
|
||||||
|
step that adds behavior (store, retention, provider `$since` handling).
|
||||||
|
Order matters — later steps assume earlier ones are done.
|
||||||
|
|
||||||
|
## 1. Audit cleanup
|
||||||
|
|
||||||
|
- [x] **Remove `eightpoints/guzzle-bundle` + `idci/graphql-client-bundle`.**
|
||||||
|
They exist only to build one near-static GitHub GraphQL query string
|
||||||
|
(`GitHubProvider.php:59-74`); the bundle's own HTTP transport is already
|
||||||
|
bypassed (comment at `GitHubProvider.php:76-77`).
|
||||||
|
- [ ] Replace
|
||||||
|
`$graphqlClient->buildQuery(...)->getGraphQLQuery()` with a plain
|
||||||
|
`sprintf`/heredoc query string. Delete the two packages from
|
||||||
|
`composer.json`, `config/bundles.php`, and delete
|
||||||
|
`config/packages/eight_points_guzzle.yaml` +
|
||||||
|
`config/packages/idci_graphql_client.yaml`. Run `composer update` and
|
||||||
|
commit the regenerated `composer.lock`.
|
||||||
|
|
||||||
|
- [x] **Dedupe `baseUrl` normalization.** `GitLabProvider.php` (lines 41,
|
||||||
|
53) and `GiteaProvider.php` (lines 42, 54) each call
|
||||||
|
`rtrim($this->baseUrl..., '/')` twice — once in `ping()`, once in
|
||||||
|
`fetch()`. Compute it once as a `private readonly string $baseUrl` in
|
||||||
|
the constructor instead.
|
||||||
|
|
||||||
|
## 2. Fix stale `config/services.yaml` (found during exploration, blocks step 1 & 4)
|
||||||
|
|
||||||
|
- [ ] `services.yaml` still binds `$username`/`$token`/`$baseUrl` to the
|
||||||
|
pre-refactor FQCNs (`App\Service\GitHubProvider` etc.) and
|
||||||
|
`_instanceof: App\Service\ProviderInterface`, left over from the
|
||||||
|
`Service/` → `Provider/`+`Renderer/` namespace reorg. Update all of
|
||||||
|
these to `App\Service\Provider\...`. Currently these bindings silently
|
||||||
|
no-op, and scalar constructor args can't autowire without them — any
|
||||||
|
edit to these constructors (steps 1, 4) needs this fixed first, or the
|
||||||
|
container fails to compile.
|
||||||
|
|
||||||
|
## 3. `ContributionStore` (SQLite via native PDO)
|
||||||
|
|
||||||
|
- [x] New `src/Service/ContributionStore.php`. PDO SQLite, DB file at
|
||||||
|
`%kernel.project_dir%/var/data/contributions.db` (configurable
|
||||||
|
constructor arg), table created lazily:
|
||||||
|
```sql
|
||||||
|
CREATE TABLE IF NOT EXISTS contributions (
|
||||||
|
provider TEXT NOT NULL,
|
||||||
|
date TEXT NOT NULL,
|
||||||
|
count INTEGER NOT NULL CHECK (count >= 0),
|
||||||
|
PRIMARY KEY (provider, date)
|
||||||
|
) WITHOUT ROWID, STRICT;
|
||||||
|
```
|
||||||
|
- [ ] `latestDate(string $provider): ?string` — `SELECT MAX(date) WHERE provider = ?`.
|
||||||
|
- [ ] `merge(string $provider, array $dateCounts): void` — upsert via
|
||||||
|
`INSERT ... ON CONFLICT(provider, date) DO UPDATE SET count = excluded.count`.
|
||||||
|
- [ ] `all(string $provider, ?int $sinceDays = null): array` — `date => count`;
|
||||||
|
`null` returns full history (no arbitrary cutoff), a value filters to the
|
||||||
|
last N days.
|
||||||
|
- [ ] `prune(): void` — `DELETE FROM contributions WHERE date < ?` using
|
||||||
|
the configured retention window; no-ops if retention is unset/0.
|
||||||
|
- [ ] Constructor takes `?int $retentionDays` bound from new env var
|
||||||
|
`CONTRIBUTIONS_RETENTION_DAYS` (empty/default = keep forever).
|
||||||
|
- [ ] Tests: `tests/Unit/Service/ContributionStoreTest.php` — store &
|
||||||
|
retrieve, upsert overwrites existing date, `sinceDays` filtering,
|
||||||
|
`prune()` no-ops when retention unset, `prune()` deletes rows older
|
||||||
|
than the window when set.
|
||||||
|
|
||||||
|
## 4. Wire `$since` through providers
|
||||||
|
|
||||||
|
- [ ] `ProviderInterface::fetch()` → `fetch(?\DateTimeImmutable $since = null): array`.
|
||||||
|
- [ ] `GitHubProvider::fetch()` — use `$since ?? new \DateTimeImmutable('-365 days')`
|
||||||
|
for the GraphQL `from` param.
|
||||||
|
- [ ] `GitLabProvider::fetch()` — same, feeds the `after` query param
|
||||||
|
(this is what actually shrinks the pagination loop).
|
||||||
|
- [ ] `GiteaProvider::fetch()` — same, feeds the `$cutoff` timestamp filter.
|
||||||
|
- [ ] Update `GitHubProviderTest.php` (drop `GraphQLApiClientRegistryInterface`
|
||||||
|
stub setup entirely per step 1), `GitLabProviderTest.php`,
|
||||||
|
`GiteaProviderTest.php` — add a case asserting a passed `$since` narrows
|
||||||
|
the request window.
|
||||||
|
|
||||||
|
## 5. Wire `ContributionStore` into `ContributionAggregator`
|
||||||
|
|
||||||
|
- [ ] Inject `ContributionStore` into `ContributionAggregator`.
|
||||||
|
- [ ] Per configured provider: `$since = $store->latestDate($name)` → if
|
||||||
|
set, `(new \DateTimeImmutable($latest))->modify('-3 days')` (3-day
|
||||||
|
overlap for late corrections), else `null` (first run).
|
||||||
|
- [ ] `$fresh = $provider->fetch($since)`, `$store->merge($name, $fresh)`,
|
||||||
|
then read back `$store->all($name, sinceDays: 371)` for the render
|
||||||
|
window (53 weeks × 7 days) and merge into the returned array.
|
||||||
|
- [ ] Call `$store->prune()` once per `aggregate()` call, after all
|
||||||
|
providers have merged.
|
||||||
|
- [ ] Keep the existing try/catch-and-log-per-provider behavior — a
|
||||||
|
provider failure leaves its DB history stale, doesn't break the render.
|
||||||
|
- [ ] Update `ContributionAggregatorTest.php` with store-interaction and
|
||||||
|
prune-call cases.
|
||||||
|
|
||||||
|
## 6. Docker / env
|
||||||
|
|
||||||
|
- [ ] `docker-compose.yml` — add a `data` named volume mounted at
|
||||||
|
`/app/var/data` (same pattern as `cache`/`logs`), and pass through
|
||||||
|
`CONTRIBUTIONS_RETENTION_DAYS: "${CONTRIBUTIONS_RETENTION_DAYS:-}"`.
|
||||||
|
- [ ] `Dockerfile` — add `var/data` to the `mkdir -p` in the `final` stage
|
||||||
|
alongside `var/cache/prod/pools var/log`, owned by `app`.
|
||||||
|
- [ ] `.env` — document `CONTRIBUTIONS_RETENTION_DAYS` (empty by default),
|
||||||
|
same style as the existing `ALLOWED_HOSTS` comment.
|
||||||
|
|
||||||
|
## 7. PHPStan
|
||||||
|
|
||||||
|
- [ ] `composer require --dev phpstan/phpstan` (plain PHPStan — no
|
||||||
|
Symfony extension needed for this app's size).
|
||||||
|
- [ ] Add `phpstan.neon`: `paths: [src, tests]`, `level: 8`.
|
||||||
|
- [ ] Add composer script `"phpstan": "phpstan analyse"`.
|
||||||
|
- [ ] Fix whatever level-8 flags on first run.
|
||||||
|
|
||||||
|
## 8. `CLAUDE.md` update
|
||||||
|
|
||||||
|
- [ ] Architecture section: add the `ContributionStore` (SQLite) tier
|
||||||
|
between providers and the renderer; note the two-tier cache (1h SVG
|
||||||
|
cache → SQLite raw-data store → provider APIs).
|
||||||
|
- [ ] Environment variables table: add `CONTRIBUTIONS_RETENTION_DAYS`.
|
||||||
|
- [ ] Development section: add `composer phpstan` next to the existing
|
||||||
|
`vendor/bin/phpunit` commands.
|
||||||
|
- [ ] Remove any remaining mentions of the two deleted bundles.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
- `vendor/bin/phpunit --testdox` green after every step.
|
||||||
|
- `composer phpstan` clean at level 8.
|
||||||
|
- `composer install` succeeds with no dangling references to the removed bundles.
|
||||||
|
- `docker compose up -d --build`; clear the FS cache
|
||||||
|
(`docker compose exec graph rm -rf var/cache/*`); hit
|
||||||
|
`/graph.svg?theme=dark` twice; check `docker compose logs -f graph` shows
|
||||||
|
a narrower `since` window on the second fetch.
|
||||||
|
- Set `CONTRIBUTIONS_RETENTION_DAYS=30`; confirm rows older than 30 days
|
||||||
|
are gone after the next refresh
|
||||||
|
(`sqlite3 var/data/contributions.db "SELECT date FROM contributions ORDER BY date LIMIT 1"`).
|
||||||
|
- `curl localhost:8080/health` still reports all configured providers healthy.
|
||||||
@@ -5,8 +5,6 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2",
|
"php": ">=8.2",
|
||||||
"eightpoints/guzzle-bundle": "^8.6",
|
|
||||||
"idci/graphql-client-bundle": "^2.0",
|
|
||||||
"monolog/monolog": "^3.10",
|
"monolog/monolog": "^3.10",
|
||||||
"symfony/cache": "7.4.*",
|
"symfony/cache": "7.4.*",
|
||||||
"symfony/console": "7.4.*",
|
"symfony/console": "7.4.*",
|
||||||
|
|||||||
Generated
+4948
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
|||||||
eight_points_guzzle:
|
|
||||||
clients:
|
|
||||||
github_graphql:
|
|
||||||
base_url: 'https://api.github.com/graphql'
|
|
||||||
options:
|
|
||||||
headers:
|
|
||||||
Authorization: 'Bearer %env(GITHUB_TOKEN)%'
|
|
||||||
@@ -7,3 +7,7 @@ framework:
|
|||||||
cache:
|
cache:
|
||||||
app: cache.adapter.filesystem
|
app: cache.adapter.filesystem
|
||||||
default_redis_provider: 'redis://localhost'
|
default_redis_provider: 'redis://localhost'
|
||||||
|
http_client:
|
||||||
|
default_options:
|
||||||
|
timeout: 10 # connect + wait-for-first-byte cap per request
|
||||||
|
max_duration: 15 # hard cap on total request duration
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
idci_graphql_client:
|
|
||||||
clients:
|
|
||||||
github:
|
|
||||||
http_client: 'eight_points_guzzle.client.github_graphql'
|
|
||||||
@@ -121,7 +121,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||||||
* }
|
* }
|
||||||
* @psalm-type ServicesConfig = array{
|
* @psalm-type ServicesConfig = array{
|
||||||
* _defaults?: DefaultsType,
|
* _defaults?: DefaultsType,
|
||||||
* _instanceof?: InstanceofType,
|
* _instanceof?: array<class-string, InstanceofType>,
|
||||||
* ...<string, DefinitionType|AliasType|PrototypeType|StackType|ArgumentsType|null>
|
* ...<string, DefinitionType|AliasType|PrototypeType|StackType|ArgumentsType|null>
|
||||||
* }
|
* }
|
||||||
* @psalm-type ExtensionType = array<string, mixed>
|
* @psalm-type ExtensionType = array<string, mixed>
|
||||||
@@ -857,6 +857,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||||||
* http_errors?: bool|Param,
|
* http_errors?: bool|Param,
|
||||||
* expect?: mixed,
|
* expect?: mixed,
|
||||||
* ssl_key?: mixed,
|
* ssl_key?: mixed,
|
||||||
|
* force_ip_resolve?: mixed, // Default: null
|
||||||
* stream?: bool|Param,
|
* stream?: bool|Param,
|
||||||
* synchronous?: bool|Param,
|
* synchronous?: bool|Param,
|
||||||
* read_timeout?: scalar|Param|null,
|
* read_timeout?: scalar|Param|null,
|
||||||
|
|||||||
@@ -22,21 +22,21 @@ services:
|
|||||||
- '../src/Kernel.php'
|
- '../src/Kernel.php'
|
||||||
|
|
||||||
_instanceof:
|
_instanceof:
|
||||||
App\Service\ProviderInterface:
|
App\Service\Provider\ProviderInterface:
|
||||||
tags: ['app.provider']
|
tags: ['app.provider']
|
||||||
|
|
||||||
App\Service\GitHubProvider:
|
App\Service\Provider\GitHubProvider:
|
||||||
arguments:
|
arguments:
|
||||||
$username: '%env(GITHUB_USER)%'
|
$username: '%env(GITHUB_USER)%'
|
||||||
$token: '%env(GITHUB_TOKEN)%'
|
$token: '%env(GITHUB_TOKEN)%'
|
||||||
|
|
||||||
App\Service\GitLabProvider:
|
App\Service\Provider\GitLabProvider:
|
||||||
arguments:
|
arguments:
|
||||||
$username: '%env(GITLAB_USER)%'
|
$username: '%env(GITLAB_USER)%'
|
||||||
$token: '%env(GITLAB_TOKEN)%'
|
$token: '%env(GITLAB_TOKEN)%'
|
||||||
$baseUrl: '%env(GITLAB_URL)%'
|
$baseUrl: '%env(GITLAB_URL)%'
|
||||||
|
|
||||||
App\Service\GiteaProvider:
|
App\Service\Provider\GiteaProvider:
|
||||||
arguments:
|
arguments:
|
||||||
$username: '%env(GITEA_USER)%'
|
$username: '%env(GITEA_USER)%'
|
||||||
$token: '%env(GITEA_TOKEN)%'
|
$token: '%env(GITEA_TOKEN)%'
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
services:
|
services:
|
||||||
graph:
|
graph:
|
||||||
build:
|
build:
|
||||||
target: dev
|
dockerfile: Dockerfile.dev
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
- /app/vendor # keeps vendor from the dev image, not your local dir
|
- ./vendor:/app/vendor
|
||||||
|
- /app/var/data
|
||||||
environment:
|
environment:
|
||||||
APP_ENV: dev
|
APP_ENV: dev
|
||||||
APP_DEBUG: "1"
|
APP_DEBUG: "1"
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
services:
|
||||||
|
graph:
|
||||||
|
image: git.arthurerlich.de/haylan/git-contribution-graph:latest
|
||||||
|
container_name: git-contribution-graph
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
environment:
|
||||||
|
APP_ENV: prod
|
||||||
|
APP_DEBUG: "0"
|
||||||
|
APP_SECRET: "${APP_SECRET}"
|
||||||
|
ALLOWED_HOSTS: "${ALLOWED_HOSTS:-}"
|
||||||
|
GITHUB_USER: "${GITHUB_USER:-}"
|
||||||
|
GITHUB_TOKEN: "${GITHUB_TOKEN:-}"
|
||||||
|
GITLAB_USER: "${GITLAB_USER:-}"
|
||||||
|
GITLAB_TOKEN: "${GITLAB_TOKEN:-}"
|
||||||
|
GITLAB_URL: "${GITLAB_URL:-}"
|
||||||
|
GITEA_USER: "${GITEA_USER:-}"
|
||||||
|
GITEA_TOKEN: "${GITEA_TOKEN:-}"
|
||||||
|
GITEA_URL: "${GITEA_URL:-}"
|
||||||
|
volumes:
|
||||||
|
- cache:/app/var/cache/prod/pools
|
||||||
|
- logs:/app/var/log
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
cache:
|
||||||
|
logs:
|
||||||
+2
-1
@@ -21,13 +21,14 @@ services:
|
|||||||
GITEA_TOKEN: "${GITEA_TOKEN:-}"
|
GITEA_TOKEN: "${GITEA_TOKEN:-}"
|
||||||
GITEA_URL: "${GITEA_URL:-}"
|
GITEA_URL: "${GITEA_URL:-}"
|
||||||
volumes:
|
volumes:
|
||||||
- cache:/app/var/cache
|
- cache:/app/var/cache/prod/pools
|
||||||
- logs:/app/var/log
|
- logs:/app/var/log
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
start_period: 10s
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
cache:
|
cache:
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
opcache.validate_timestamps=1
|
||||||
|
opcache.revalidate_freq=0
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
opcache.enable=1
|
||||||
|
opcache.enable_cli=0
|
||||||
|
opcache.memory_consumption=128
|
||||||
|
opcache.max_accelerated_files=20000
|
||||||
|
opcache.validate_timestamps=0
|
||||||
|
expose_php=0
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 539 B |
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:recommended"
|
||||||
|
],
|
||||||
|
"separateMajorMinor": true,
|
||||||
|
"major": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"packageRules": [
|
||||||
|
{
|
||||||
|
"allowedVersions": "^7.0",
|
||||||
|
"description": "Keep Symfony on 7.x LTS until EOL",
|
||||||
|
"matchPackageNames": [
|
||||||
|
"/^symfony//"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matchManagers": ["github-actions"],
|
||||||
|
"enabled": false,
|
||||||
|
"description": "Ignore GitHub Actions — no GITHUB_COM_TOKEN available"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matchPackageNames": ["phpunit/phpunit"],
|
||||||
|
"allowedVersions": "^12.0",
|
||||||
|
"description": "Stay on PHPUnit 12.x (compatible with Symfony 7 / PHP 8.2+)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Service\ContributionAggregator;
|
use App\Service\ContributionAggregator;
|
||||||
use App\Service\ProviderHealthChecker;
|
use App\Service\Provider\ProviderHealthChecker;
|
||||||
use App\Service\SvgRenderer;
|
use App\Service\Renderer\SvgRenderer;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
@@ -53,6 +53,7 @@ final class GraphController
|
|||||||
$svg = $this->cache->get($cacheKey, function (ItemInterface $item) use ($theme, &$cacheMiss): string {
|
$svg = $this->cache->get($cacheKey, function (ItemInterface $item) use ($theme, &$cacheMiss): string {
|
||||||
$cacheMiss = true;
|
$cacheMiss = true;
|
||||||
$item->expiresAfter(3600);
|
$item->expiresAfter(3600);
|
||||||
|
set_time_limit(30); // ponytail: providers fetch concurrently now (cost ~= max, not sum); GitLab pagination + per-request HTTP timeout (framework.yaml) still need headroom over the 30s default
|
||||||
|
|
||||||
return $this->renderer->render($this->aggregator->aggregate(), $theme);
|
return $this->renderer->render($this->aggregator->aggregate(), $theme);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service;
|
||||||
|
|
||||||
|
use App\Service\Provider\ProviderInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
|
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ final class ContributionAggregator
|
|||||||
/** @return array<string, int> */
|
/** @return array<string, int> */
|
||||||
public function aggregate(): array
|
public function aggregate(): array
|
||||||
{
|
{
|
||||||
$contributions = [];
|
$pending = [];
|
||||||
|
|
||||||
/** @var ProviderInterface $provider */
|
/** @var ProviderInterface $provider */
|
||||||
foreach ($this->providers as $provider) {
|
foreach ($this->providers as $provider) {
|
||||||
@@ -27,7 +28,17 @@ final class ContributionAggregator
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
foreach ($provider->fetch() as $date => $count) {
|
$pending[] = [$provider, $provider->startFetch()];
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->logger->warning(sprintf('%s fetch failed: %s', $provider::class, $e->getMessage()), ['exception' => $e]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$contributions = [];
|
||||||
|
|
||||||
|
foreach ($pending as [$provider, $handle]) {
|
||||||
|
try {
|
||||||
|
foreach ($provider->resolveFetch($handle) as $date => $count) {
|
||||||
$contributions[$date] = ($contributions[$date] ?? 0) + $count;
|
$contributions[$date] = ($contributions[$date] ?? 0) + $count;
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
class ContributionStore {
|
||||||
|
private PDO $pdo;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private readonly string $dbPath = "%kernel.project_dir%/var/data/contributions.db",
|
||||||
|
private readonly ?int $retentionDays = null,
|
||||||
|
){
|
||||||
|
if(!is_dir(\dirname($this->dbPath))){
|
||||||
|
mkdir(\dirname($this->dbPath), 0755, recursive: true);
|
||||||
|
}
|
||||||
|
$this->pdo = new PDO('sqlite:' . $this->dbPath);
|
||||||
|
$this->pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
|
||||||
|
$this->prepareSchema();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function prepareSchema():void{
|
||||||
|
$this->pdo->exec('
|
||||||
|
CREATE TABLE IF NOT EXISTS contributions (
|
||||||
|
provider TEXT NOT NULL,
|
||||||
|
date INTEGER NOT NULL,
|
||||||
|
count INTEGER NOT NULL CHECK (count >= 0),
|
||||||
|
PRIMARY KEY (provider, date)
|
||||||
|
) WITHOUT ROWID, STRICT
|
||||||
|
');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add(string $provider, int $unixtime, int $count):void{
|
||||||
|
$stmt = $this->pdo->prepare('
|
||||||
|
INSERT INTO contributions (
|
||||||
|
provider, date, count
|
||||||
|
)
|
||||||
|
VALUES(
|
||||||
|
?,?,?
|
||||||
|
)
|
||||||
|
');
|
||||||
|
$stmt->execute([$provider,$unixtime,$count]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove(string $provider, int $unixtime):void{
|
||||||
|
$stmt = $this->pdo->prepare('
|
||||||
|
DELETE contributions
|
||||||
|
WHERE provider LIKE ? and date = ?
|
||||||
|
');
|
||||||
|
$stmt->execute([$provider,$unixtime]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function all():void{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Provider;
|
||||||
|
|
||||||
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClient;
|
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClient;
|
||||||
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClientRegistryInterface;
|
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClientRegistryInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the last 365 days of contributions from the GitHub GraphQL API.
|
* Fetches the last 365 days of contributions from the GitHub GraphQL API.
|
||||||
@@ -46,10 +47,7 @@ final class GitHubProvider implements ProviderInterface
|
|||||||
])->getContent();
|
])->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function startFetch(): ResponseInterface
|
||||||
* @return array<string, int> date (Y-m-d) => contribution count
|
|
||||||
*/
|
|
||||||
public function fetch(): array
|
|
||||||
{
|
{
|
||||||
$this->logger->debug('GitHubProvider: fetching contributions', ['user' => $this->username]);
|
$this->logger->debug('GitHubProvider: fetching contributions', ['user' => $this->username]);
|
||||||
|
|
||||||
@@ -75,15 +73,24 @@ final class GitHubProvider implements ProviderInterface
|
|||||||
|
|
||||||
// GitHub's GraphQL API requires application/json — the bundle's built-in
|
// GitHub's GraphQL API requires application/json — the bundle's built-in
|
||||||
// transport sends form_params, so we use Symfony HttpClient here instead.
|
// transport sends form_params, so we use Symfony HttpClient here instead.
|
||||||
$response = $this->client->request('POST', self::GRAPHQL_URL, [
|
// request() doesn't block; the response is read in resolveFetch() so
|
||||||
|
// multiple providers' requests can be in flight at once.
|
||||||
|
return $this->client->request('POST', self::GRAPHQL_URL, [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Authorization' => "Bearer {$this->token}",
|
'Authorization' => "Bearer {$this->token}",
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
],
|
],
|
||||||
'json' => ['query' => $query],
|
'json' => ['query' => $query],
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$data = $response->toArray();
|
/**
|
||||||
|
* @return array<string, int> date (Y-m-d) => contribution count
|
||||||
|
*/
|
||||||
|
public function resolveFetch(mixed $handle): array
|
||||||
|
{
|
||||||
|
/** @var ResponseInterface $handle */
|
||||||
|
$data = $handle->toArray();
|
||||||
|
|
||||||
if (isset($data['errors'])) {
|
if (isset($data['errors'])) {
|
||||||
throw new ServiceUnavailableHttpException(null, 'GitHub GraphQL error: ' . json_encode($data['errors']));
|
throw new ServiceUnavailableHttpException(null, 'GitHub GraphQL error: ' . json_encode($data['errors']));
|
||||||
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Provider;
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the last 365 days of push/merge events from the GitLab REST API.
|
* Fetches the last 365 days of push/merge events from the GitLab REST API.
|
||||||
@@ -24,7 +25,9 @@ final class GitLabProvider implements ProviderInterface
|
|||||||
private readonly string $token,
|
private readonly string $token,
|
||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
private readonly string $baseUrl = '',
|
private readonly string $baseUrl = '',
|
||||||
) {}
|
) {
|
||||||
|
$this->baseUrl = rtrim($this->baseUrl !== '' ? $this->baseUrl : 'https://gitlab.com', '/');
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
@@ -38,47 +41,59 @@ final class GitLabProvider implements ProviderInterface
|
|||||||
|
|
||||||
public function ping(): void
|
public function ping(): void
|
||||||
{
|
{
|
||||||
$baseUrl = rtrim($this->baseUrl !== '' ? $this->baseUrl : 'https://gitlab.com', '/');
|
|
||||||
|
$this->client->request('GET', "$this->baseUrl/api/v4/user", [
|
||||||
$this->client->request('GET', "$baseUrl/api/v4/user", [
|
|
||||||
'headers' => ['PRIVATE-TOKEN' => $this->token],
|
'headers' => ['PRIVATE-TOKEN' => $this->token],
|
||||||
])->getContent();
|
])->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, int> date (Y-m-d) => event count
|
* @return array{baseUrl: string, userId: int, after: string, page: int, response: ResponseInterface}
|
||||||
|
*
|
||||||
|
* ponytail: the user-id lookup and event pagination stay sequential within
|
||||||
|
* this one provider (each page depends on the previous). Parallelism here
|
||||||
|
* only spans across providers; revisit only if GitLab pagination itself
|
||||||
|
* becomes the bottleneck.
|
||||||
*/
|
*/
|
||||||
public function fetch(): array
|
public function startFetch(): array
|
||||||
{
|
{
|
||||||
$baseUrl = rtrim($this->baseUrl !== '' ? $this->baseUrl : 'https://gitlab.com', '/');
|
|
||||||
|
$this->logger->debug('GitLabProvider: fetching contributions', ['user' => $this->username, 'url' => $this->baseUrl]);
|
||||||
|
|
||||||
$this->logger->debug('GitLabProvider: fetching contributions', ['user' => $this->username, 'url' => $baseUrl]);
|
$userResponse = $this->client->request('GET', "$this->baseUrl/api/v4/users", [
|
||||||
|
|
||||||
$userResponse = $this->client->request('GET', "$baseUrl/api/v4/users", [
|
|
||||||
'headers' => ['PRIVATE-TOKEN' => $this->token],
|
'headers' => ['PRIVATE-TOKEN' => $this->token],
|
||||||
'query' => ['username' => $this->username],
|
'query' => ['username' => $this->username],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$users = $userResponse->toArray();
|
$users = $userResponse->toArray();
|
||||||
if (empty($users)) {
|
if (empty($users)) {
|
||||||
throw new NotFoundHttpException("GitLab: user '{$this->username}' not found on $baseUrl");
|
throw new NotFoundHttpException("GitLab: user '{$this->username}' not found on $this->baseUrl");
|
||||||
}
|
}
|
||||||
$userId = $users[0]['id'];
|
$userId = $users[0]['id'];
|
||||||
|
$after = (new \DateTimeImmutable('-365 days'))->format('Y-m-d');
|
||||||
|
|
||||||
|
$response = $this->client->request('GET', "$this->baseUrl/api/v4/users/$userId/events", [
|
||||||
|
'headers' => ['PRIVATE-TOKEN' => $this->token],
|
||||||
|
'query' => [
|
||||||
|
'after' => $after,
|
||||||
|
'per_page' => 100,
|
||||||
|
'page' => 1,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return ['baseUrl' => $this->baseUrl, 'userId' => $userId, 'after' => $after, 'page' => 1, 'response' => $response];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, int> date (Y-m-d) => event count
|
||||||
|
*/
|
||||||
|
public function resolveFetch(mixed $handle): array
|
||||||
|
{
|
||||||
|
['baseUrl' => $baseUrl, 'userId' => $userId, 'after' => $after, 'page' => $page, 'response' => $response] = $handle;
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
$after = (new \DateTimeImmutable('-365 days'))->format('Y-m-d');
|
|
||||||
$page = 1;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$response = $this->client->request('GET', "$baseUrl/api/v4/users/$userId/events", [
|
|
||||||
'headers' => ['PRIVATE-TOKEN' => $this->token],
|
|
||||||
'query' => [
|
|
||||||
'after' => $after,
|
|
||||||
'per_page' => 100,
|
|
||||||
'page' => $page,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$events = $response->toArray();
|
$events = $response->toArray();
|
||||||
|
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
@@ -87,6 +102,17 @@ final class GitLabProvider implements ProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$page++;
|
$page++;
|
||||||
|
|
||||||
|
if (count($events) === 100) {
|
||||||
|
$response = $this->client->request('GET', "$baseUrl/api/v4/users/$userId/events", [
|
||||||
|
'headers' => ['PRIVATE-TOKEN' => $this->token],
|
||||||
|
'query' => [
|
||||||
|
'after' => $after,
|
||||||
|
'per_page' => 100,
|
||||||
|
'page' => $page,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
} while (count($events) === 100);
|
} while (count($events) === 100);
|
||||||
|
|
||||||
$this->logger->info('GitLabProvider: fetched contributions', [
|
$this->logger->info('GitLabProvider: fetched contributions', [
|
||||||
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Provider;
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches contribution data from the Gitea heatmap endpoint.
|
* Fetches contribution data from the Gitea heatmap endpoint.
|
||||||
@@ -25,7 +26,9 @@ final class GiteaProvider implements ProviderInterface
|
|||||||
private readonly string $token,
|
private readonly string $token,
|
||||||
private readonly string $baseUrl,
|
private readonly string $baseUrl,
|
||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
) {}
|
) {
|
||||||
|
$this->baseUrl = rtrim($this->baseUrl, '/');
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
@@ -39,27 +42,31 @@ final class GiteaProvider implements ProviderInterface
|
|||||||
|
|
||||||
public function ping(): void
|
public function ping(): void
|
||||||
{
|
{
|
||||||
$baseUrl = rtrim($this->baseUrl, '/');
|
|
||||||
|
|
||||||
$this->client->request('GET', "$baseUrl/api/v1/user", [
|
$this->client->request('GET', "$this->baseUrl/api/v1/user", [
|
||||||
'headers' => ['Authorization' => "token {$this->token}"],
|
'headers' => ['Authorization' => "token {$this->token}"],
|
||||||
])->getContent();
|
])->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function startFetch(): ResponseInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$this->logger->debug('GiteaProvider: fetching contributions', ['user' => $this->username, 'url' => $this->baseUrl]);
|
||||||
|
|
||||||
|
return $this->client->request('GET', "$this->baseUrl/api/v1/users/{$this->username}/heatmap", [
|
||||||
|
'headers' => ['Authorization' => "token {$this->token}"],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, int> date (Y-m-d) => contribution count
|
* @return array<string, int> date (Y-m-d) => contribution count
|
||||||
*/
|
*/
|
||||||
public function fetch(): array
|
public function resolveFetch(mixed $handle): array
|
||||||
{
|
{
|
||||||
$baseUrl = rtrim($this->baseUrl, '/');
|
/** @var ResponseInterface $handle */
|
||||||
|
$data = $handle->toArray();
|
||||||
$this->logger->debug('GiteaProvider: fetching contributions', ['user' => $this->username, 'url' => $baseUrl]);
|
|
||||||
|
|
||||||
$response = $this->client->request('GET', "$baseUrl/api/v1/users/{$this->username}/heatmap", [
|
|
||||||
'headers' => ['Authorization' => "token {$this->token}"],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = $response->toArray();
|
|
||||||
$cutoff = (new \DateTimeImmutable('-365 days'))->getTimestamp();
|
$cutoff = (new \DateTimeImmutable('-365 days'))->getTimestamp();
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Provider;
|
||||||
|
|
||||||
use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;
|
use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;
|
||||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Provider;
|
||||||
|
|
||||||
enum ProviderErrorCode: string
|
enum ProviderErrorCode: string
|
||||||
{
|
{
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Provider;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
|
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
|
||||||
|
|
||||||
@@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Provider;
|
||||||
|
|
||||||
interface ProviderInterface
|
interface ProviderInterface
|
||||||
{
|
{
|
||||||
|
/** Fire the HTTP request(s) without blocking; returns an opaque handle for resolveFetch(). */
|
||||||
|
public function startFetch(): mixed;
|
||||||
|
|
||||||
/** @return array<string, int> date (Y-m-d) => contribution count */
|
/** @return array<string, int> date (Y-m-d) => contribution count */
|
||||||
public function fetch(): array;
|
public function resolveFetch(mixed $handle): array;
|
||||||
|
|
||||||
public function isConfigured(): bool;
|
public function isConfigured(): bool;
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Provider;
|
||||||
|
|
||||||
final class ProviderStatus
|
final class ProviderStatus
|
||||||
{
|
{
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Provider;
|
||||||
|
|
||||||
enum ProviderStatusType: string
|
enum ProviderStatusType: string
|
||||||
{
|
{
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service\Renderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a GitHub-style contribution heatmap as an inline SVG.
|
* Renders a GitHub-style contribution heatmap as an inline SVG.
|
||||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Tests\Unit\Service;
|
namespace App\Tests\Unit\Service;
|
||||||
|
|
||||||
use App\Service\ContributionAggregator;
|
use App\Service\ContributionAggregator;
|
||||||
use App\Service\ProviderInterface;
|
use App\Service\Provider\ProviderInterface;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@@ -49,7 +49,7 @@ final class ContributionAggregatorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$provider = $this->createStub(ProviderInterface::class);
|
$provider = $this->createStub(ProviderInterface::class);
|
||||||
$provider->method('isConfigured')->willReturn(true);
|
$provider->method('isConfigured')->willReturn(true);
|
||||||
$provider->method('fetch')->willReturn(['2024-01-01' => 3]);
|
$provider->method('resolveFetch')->willReturn(['2024-01-01' => 3]);
|
||||||
|
|
||||||
$aggregator = new ContributionAggregator([$provider], $this->logger);
|
$aggregator = new ContributionAggregator([$provider], $this->logger);
|
||||||
|
|
||||||
@@ -63,11 +63,11 @@ final class ContributionAggregatorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$providerA = $this->createStub(ProviderInterface::class);
|
$providerA = $this->createStub(ProviderInterface::class);
|
||||||
$providerA->method('isConfigured')->willReturn(true);
|
$providerA->method('isConfigured')->willReturn(true);
|
||||||
$providerA->method('fetch')->willReturn(['2024-01-01' => 3, '2024-01-02' => 1]);
|
$providerA->method('resolveFetch')->willReturn(['2024-01-01' => 3, '2024-01-02' => 1]);
|
||||||
|
|
||||||
$providerB = $this->createStub(ProviderInterface::class);
|
$providerB = $this->createStub(ProviderInterface::class);
|
||||||
$providerB->method('isConfigured')->willReturn(true);
|
$providerB->method('isConfigured')->willReturn(true);
|
||||||
$providerB->method('fetch')->willReturn(['2024-01-01' => 2, '2024-01-03' => 5]);
|
$providerB->method('resolveFetch')->willReturn(['2024-01-01' => 2, '2024-01-03' => 5]);
|
||||||
|
|
||||||
$aggregator = new ContributionAggregator([$providerA, $providerB], $this->logger);
|
$aggregator = new ContributionAggregator([$providerA, $providerB], $this->logger);
|
||||||
|
|
||||||
@@ -77,15 +77,15 @@ final class ContributionAggregatorTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
public function it_continues_fetching_remaining_providers_when_one_throws(): void
|
public function it_continues_fetching_remaining_providers_when_one_throws_on_start(): void
|
||||||
{
|
{
|
||||||
$failing = $this->createStub(ProviderInterface::class);
|
$failing = $this->createStub(ProviderInterface::class);
|
||||||
$failing->method('isConfigured')->willReturn(true);
|
$failing->method('isConfigured')->willReturn(true);
|
||||||
$failing->method('fetch')->willThrowException(new \RuntimeException('Network error'));
|
$failing->method('startFetch')->willThrowException(new \RuntimeException('Network error'));
|
||||||
|
|
||||||
$healthy = $this->createStub(ProviderInterface::class);
|
$healthy = $this->createStub(ProviderInterface::class);
|
||||||
$healthy->method('isConfigured')->willReturn(true);
|
$healthy->method('isConfigured')->willReturn(true);
|
||||||
$healthy->method('fetch')->willReturn(['2024-01-01' => 7]);
|
$healthy->method('resolveFetch')->willReturn(['2024-01-01' => 7]);
|
||||||
|
|
||||||
$aggregator = new ContributionAggregator([$failing, $healthy], $this->logger);
|
$aggregator = new ContributionAggregator([$failing, $healthy], $this->logger);
|
||||||
|
|
||||||
@@ -95,14 +95,45 @@ final class ContributionAggregatorTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
public function it_logs_a_warning_when_a_provider_fetch_throws(): void
|
public function it_continues_fetching_remaining_providers_when_one_throws_on_resolve(): void
|
||||||
|
{
|
||||||
|
$failing = $this->createStub(ProviderInterface::class);
|
||||||
|
$failing->method('isConfigured')->willReturn(true);
|
||||||
|
$failing->method('resolveFetch')->willThrowException(new \RuntimeException('Network error'));
|
||||||
|
|
||||||
|
$healthy = $this->createStub(ProviderInterface::class);
|
||||||
|
$healthy->method('isConfigured')->willReturn(true);
|
||||||
|
$healthy->method('resolveFetch')->willReturn(['2024-01-01' => 7]);
|
||||||
|
|
||||||
|
$aggregator = new ContributionAggregator([$failing, $healthy], $this->logger);
|
||||||
|
|
||||||
|
$result = $aggregator->aggregate();
|
||||||
|
|
||||||
|
$this->assertSame(['2024-01-01' => 7], $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function it_logs_a_warning_when_a_provider_start_fetch_throws(): void
|
||||||
{
|
{
|
||||||
$logger = $this->createMock(LoggerInterface::class);
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
$logger->expects($this->once())->method('warning');
|
$logger->expects($this->once())->method('warning');
|
||||||
|
|
||||||
$provider = $this->createStub(ProviderInterface::class);
|
$provider = $this->createStub(ProviderInterface::class);
|
||||||
$provider->method('isConfigured')->willReturn(true);
|
$provider->method('isConfigured')->willReturn(true);
|
||||||
$provider->method('fetch')->willThrowException(new \RuntimeException('fail'));
|
$provider->method('startFetch')->willThrowException(new \RuntimeException('fail'));
|
||||||
|
|
||||||
|
(new ContributionAggregator([$provider], $logger))->aggregate();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function it_logs_a_warning_when_a_provider_resolve_fetch_throws(): void
|
||||||
|
{
|
||||||
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
|
$logger->expects($this->once())->method('warning');
|
||||||
|
|
||||||
|
$provider = $this->createStub(ProviderInterface::class);
|
||||||
|
$provider->method('isConfigured')->willReturn(true);
|
||||||
|
$provider->method('resolveFetch')->willThrowException(new \RuntimeException('fail'));
|
||||||
|
|
||||||
(new ContributionAggregator([$provider], $logger))->aggregate();
|
(new ContributionAggregator([$provider], $logger))->aggregate();
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Tests\Unit\Service;
|
namespace App\Tests\Unit\Service\Provider;
|
||||||
|
|
||||||
use App\Service\GitHubProvider;
|
use App\Service\Provider\GitHubProvider;
|
||||||
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClient;
|
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClient;
|
||||||
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClientRegistryInterface;
|
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClientRegistryInterface;
|
||||||
use IDCI\Bundle\GraphQLClientBundle\Query\GraphQLQuery;
|
use IDCI\Bundle\GraphQLClientBundle\Query\GraphQLQuery;
|
||||||
@@ -96,7 +96,8 @@ final class GitHubProviderTest extends TestCase
|
|||||||
]],
|
]],
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$result = $this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$result = $provider->resolveFetch($provider->startFetch());
|
||||||
|
|
||||||
$this->assertSame(4, $result['2024-06-10']);
|
$this->assertSame(4, $result['2024-06-10']);
|
||||||
$this->assertSame(2, $result['2024-06-11']);
|
$this->assertSame(2, $result['2024-06-11']);
|
||||||
@@ -112,7 +113,8 @@ final class GitHubProviderTest extends TestCase
|
|||||||
]],
|
]],
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$result = $this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$result = $provider->resolveFetch($provider->startFetch());
|
||||||
|
|
||||||
$this->assertArrayNotHasKey('2024-06-11', $result);
|
$this->assertArrayNotHasKey('2024-06-11', $result);
|
||||||
}
|
}
|
||||||
@@ -130,7 +132,8 @@ final class GitHubProviderTest extends TestCase
|
|||||||
|
|
||||||
$this->expectException(ServiceUnavailableHttpException::class);
|
$this->expectException(ServiceUnavailableHttpException::class);
|
||||||
|
|
||||||
$this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$provider->resolveFetch($provider->startFetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
@@ -139,7 +142,8 @@ final class GitHubProviderTest extends TestCase
|
|||||||
$client = $this->createStub(HttpClientInterface::class);
|
$client = $this->createStub(HttpClientInterface::class);
|
||||||
$client->method('request')->willReturn($this->stubGraphqlResponse([]));
|
$client->method('request')->willReturn($this->stubGraphqlResponse([]));
|
||||||
|
|
||||||
$result = $this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$result = $provider->resolveFetch($provider->startFetch());
|
||||||
|
|
||||||
$this->assertSame([], $result);
|
$this->assertSame([], $result);
|
||||||
}
|
}
|
||||||
+8
-5
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Tests\Unit\Service;
|
namespace App\Tests\Unit\Service\Provider;
|
||||||
|
|
||||||
use App\Service\GitLabProvider;
|
use App\Service\Provider\GitLabProvider;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@@ -71,7 +71,8 @@ final class GitLabProviderTest extends TestCase
|
|||||||
|
|
||||||
$this->expectException(NotFoundHttpException::class);
|
$this->expectException(NotFoundHttpException::class);
|
||||||
|
|
||||||
$this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$provider->resolveFetch($provider->startFetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
@@ -92,7 +93,8 @@ final class GitLabProviderTest extends TestCase
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$result = $provider->resolveFetch($provider->startFetch());
|
||||||
|
|
||||||
$this->assertSame(2, $result['2024-06-10']);
|
$this->assertSame(2, $result['2024-06-10']);
|
||||||
$this->assertSame(1, $result['2024-06-11']);
|
$this->assertSame(1, $result['2024-06-11']);
|
||||||
@@ -119,7 +121,8 @@ final class GitLabProviderTest extends TestCase
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$result = $provider->resolveFetch($provider->startFetch());
|
||||||
|
|
||||||
$this->assertSame(2, $callCount);
|
$this->assertSame(2, $callCount);
|
||||||
$this->assertSame(100, $result['2024-06-10']);
|
$this->assertSame(100, $result['2024-06-10']);
|
||||||
+8
-5
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Tests\Unit\Service;
|
namespace App\Tests\Unit\Service\Provider;
|
||||||
|
|
||||||
use App\Service\GiteaProvider;
|
use App\Service\Provider\GiteaProvider;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@@ -78,7 +78,8 @@ final class GiteaProviderTest extends TestCase
|
|||||||
['timestamp' => $now, 'contributions' => 5],
|
['timestamp' => $now, 'contributions' => 5],
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$result = $this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$result = $provider->resolveFetch($provider->startFetch());
|
||||||
|
|
||||||
$this->assertSame(5, $result[date('Y-m-d', $now)]);
|
$this->assertSame(5, $result[date('Y-m-d', $now)]);
|
||||||
}
|
}
|
||||||
@@ -93,7 +94,8 @@ final class GiteaProviderTest extends TestCase
|
|||||||
['timestamp' => $old, 'contributions' => 3],
|
['timestamp' => $old, 'contributions' => 3],
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$result = $this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$result = $provider->resolveFetch($provider->startFetch());
|
||||||
|
|
||||||
$this->assertSame([], $result);
|
$this->assertSame([], $result);
|
||||||
}
|
}
|
||||||
@@ -104,7 +106,8 @@ final class GiteaProviderTest extends TestCase
|
|||||||
$client = $this->createStub(HttpClientInterface::class);
|
$client = $this->createStub(HttpClientInterface::class);
|
||||||
$client->method('request')->willReturn($this->stubResponse([]));
|
$client->method('request')->willReturn($this->stubResponse([]));
|
||||||
|
|
||||||
$result = $this->makeProvider(client: $client)->fetch();
|
$provider = $this->makeProvider(client: $client);
|
||||||
|
$result = $provider->resolveFetch($provider->startFetch());
|
||||||
|
|
||||||
$this->assertSame([], $result);
|
$this->assertSame([], $result);
|
||||||
}
|
}
|
||||||
+7
-6
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Tests\Unit\Service;
|
namespace App\Tests\Unit\Service\Provider;
|
||||||
|
|
||||||
use App\Service\ProbeTrait;
|
use App\Service\Provider\ProbeTrait;
|
||||||
use App\Service\ProviderErrorCode;
|
use App\Service\Provider\ProviderErrorCode;
|
||||||
use App\Service\ProviderInterface;
|
use App\Service\Provider\ProviderInterface;
|
||||||
use App\Service\ProviderStatusType;
|
use App\Service\Provider\ProviderStatusType;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@@ -31,7 +31,8 @@ final class ProbeTraitTest extends TestCase
|
|||||||
public function isConfigured(): bool { return $this->configured; }
|
public function isConfigured(): bool { return $this->configured; }
|
||||||
public function getName(): string { return 'test'; }
|
public function getName(): string { return 'test'; }
|
||||||
public function ping(): void { ($this->ping)(); }
|
public function ping(): void { ($this->ping)(); }
|
||||||
public function fetch(): array { return []; }
|
public function startFetch(): mixed { return null; }
|
||||||
|
public function resolveFetch(mixed $handle): array { return []; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
+6
-6
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Tests\Unit\Service;
|
namespace App\Tests\Unit\Service\Provider;
|
||||||
|
|
||||||
use App\Service\ProviderErrorCode;
|
use App\Service\Provider\ProviderErrorCode;
|
||||||
use App\Service\ProviderHealthChecker;
|
use App\Service\Provider\ProviderHealthChecker;
|
||||||
use App\Service\ProviderInterface;
|
use App\Service\Provider\ProviderInterface;
|
||||||
use App\Service\ProviderStatus;
|
use App\Service\Provider\ProviderStatus;
|
||||||
use App\Service\ProviderStatusType;
|
use App\Service\Provider\ProviderStatusType;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
+4
-4
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Tests\Unit\Service;
|
namespace App\Tests\Unit\Service\Provider;
|
||||||
|
|
||||||
use App\Service\ProviderErrorCode;
|
use App\Service\Provider\ProviderErrorCode;
|
||||||
use App\Service\ProviderStatus;
|
use App\Service\Provider\ProviderStatus;
|
||||||
use App\Service\ProviderStatusType;
|
use App\Service\Provider\ProviderStatusType;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
+2
-2
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Tests\Unit\Service;
|
namespace App\Tests\Unit\Service\Renderer;
|
||||||
|
|
||||||
use App\Service\SvgRenderer;
|
use App\Service\Renderer\SvgRenderer;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
Reference in New Issue
Block a user