No description
Find a file
Voislav Vasiljevski 3967a1ba79 feat: add Forgejo Actions runs API (#1)
New model:
  - WorkflowRun — mirrors Forgejo's ActionRun schema (id, title, status,
    event, indexInRepo, commitSha, prettyRef, workflowId, created, updated,
    started, stopped, durationNanos, htmlUrl, triggerUser, repository).

New service:
  - WorkflowService
      - fetchRuns(owner:repo:status:event:ref:workflowId:runNumber:headSha:page:limit:)
        backed by GET /repos/{owner}/{repo}/actions/runs.
      - fetchRun(owner:repo:runId:) backed by
        GET /repos/{owner}/{repo}/actions/runs/{run_id}.

Experimental:
  - fetchRunView(owner:repo:runIndex:jobIndex:logCursors:) backed by
    Forgejo's web-UI route POST
    /{owner}/{repo}/actions/runs/{runIndex}/jobs/{jobIndex}/attempt/{N}.
    This is not part of /api/v1 and may change between Forgejo releases;
    it lets clients render jobs, steps, and step logs (via WorkflowRunView,
    WorkflowRunViewJob, WorkflowRunViewStep, WorkflowLogCursor types).
  - ForgejoClient.discoverRedirectLocation(url:) helper that resolves
    Forgejo's RedirectToLatestAttempt without consuming the redirect
    target — used to find the latest attempt number before POSTing.

Co-authored-by: Voislav Vasiljevski <voislav@voioo.cz>
Reviewed-on: https://codeberg.org/secana/ForgejoKit/pulls/1
Reviewed-by: secana <secana@noreply.codeberg.org>
2026-05-07 16:42:16 +02:00
Sources/ForgejoKit feat: add Forgejo Actions runs API (#1) 2026-05-07 16:42:16 +02:00
Tests/ForgejoKitTests feat: add Forgejo Actions runs API (#1) 2026-05-07 16:42:16 +02:00
.envrc feat: initial commit 2026-02-28 20:25:57 +01:00
.gitignore feat: initial commit 2026-02-28 20:25:57 +01:00
.swiftformat feat: initial commit 2026-02-28 20:25:57 +01:00
.swiftlint.yml feat: initial commit 2026-02-28 20:25:57 +01:00
flake.lock fix: lint errors 2026-03-11 22:17:20 +01:00
flake.nix fix: lint errors 2026-03-11 22:17:20 +01:00
justfile fix: failing release command 2026-02-28 20:33:38 +01:00
LICENSE feat: initial commit 2026-02-28 20:25:57 +01:00
Package.swift feat: initial commit 2026-02-28 20:25:57 +01:00
README.md release 0.3.2 2026-03-22 11:49:58 +01:00

ForgejoKit

A native Swift library for the Forgejo API. ForgejoKit provides a typed, async/await interface for interacting with Forgejo instances from Swift applications on macOS and iOS.

Features

  • Authentication via username/password (with optional OTP) or API tokens
  • Repositories: search, list, create, fork, star, file contents, commits, branches, tags, releases
  • Issues: create, edit, list, comment, manage labels and milestones
  • Pull requests: create, edit, merge, review, diff
  • Notifications: list, unread count, mark as read
  • Self-signed certificate support

Installation

Add ForgejoKit as a dependency in your Package.swift:

dependencies: [
    .package(url: "https://codeberg.org/secana/ForgejoKit.git", from: "0.3.2"),
],
targets: [
    .target(
        name: "MyApp",
        dependencies: ["ForgejoKit"]
    ),
]

Usage

import ForgejoKit

// Authenticate with a token
let client = ForgejoClient(serverURL: "https://codeberg.org", username: "user", token: "your-token")

// Or log in with username/password to create an API token
let result = try await ForgejoClient.login(serverURL: "https://codeberg.org", username: "user", password: "pass")
let client = result.client

// Fetch repositories
let repoService = RepositoryService(client: client)
let repos = try await repoService.searchRepositories(query: "swift")

// Work with issues
let issueService = IssueService(client: client)
let issues = try await issueService.fetchIssues(owner: "owner", repo: "repo")

// Check notifications
let notificationService = NotificationService(client: client)
let unread = try await notificationService.fetchUnreadCount()

Development

Prerequisites

Install Nix and enable flakes.

Dev Shell

Enter the development shell with all required tools:

nix develop

This provides swift, swiftformat, and just on all platforms, plus swiftlint and xcbeautify on macOS.

Building and Testing

The project uses just as a command runner. Run just to see all available commands:

just          # list available commands
just build    # build the library
just test     # run tests
just lint     # lint sources with swiftlint
just format   # format sources with swiftformat

Releasing a New Version

Make sure all changes are committed and pushed, then run:

just release 1.0.0

This will verify the tag doesn't already exist, update the version in README.md, commit, tag, and push. Swift Package Manager resolves versions from git tags, so no registry publication is needed.