Unverified Commit 959ec58b authored by Hong Minhee's avatar Hong Minhee
Browse files

Merge branch 'ci'

parents 461b8cfe f7219998
Loading
Loading
Loading
Loading
+82 −79
Original line number Diff line number Diff line
@@ -3,16 +3,22 @@ on: [push, pull_request_target]

jobs:
  test:
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
      fail-fast: false
    runs-on: ${{ matrix.os }}
    runs-on: ubuntu-latest
    permissions:
      contents: read
      issues: read
      checks: write
      pull-requests: write
    services:
      rabbitmq:
        image: rabbitmq
        env:
          RABBITMQ_DEFAULT_USER: guest
          RABBITMQ_DEFAULT_PASS: guest
        ports:
        - 5672:5672
    env:
      AMQP_URL: amqp://guest:guest@localhost:5672
    steps:
    - if: github.event_name == 'push'
      uses: actions/checkout@v4
@@ -24,8 +30,6 @@ jobs:
    - uses: denoland/setup-deno@v2
      with:
        deno-version: v2.x
    - run: deno task cache
      working-directory: ${{ github.workspace }}/fedify/
    - run: deno task test --coverage=.cov --junit-path=.test-report.xml
      env:
        RUST_BACKTRACE: ${{ runner.debug }}
@@ -35,30 +39,34 @@ jobs:
      if: success() || failure()
      with:
        name: "Test Results (${{ matrix.os }})"
        path: fedify/.test-report.xml
        path: .test-report.xml
        reporter: jest-junit
      continue-on-error: true
    - if: '!cancelled()'
      uses: codecov/test-results-action@v1
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        files: fedify/.test-report.xml
        files: .test-report.xml
    - run: deno coverage --lcov .cov > .cov.lcov
      working-directory: ${{ github.workspace }}/fedify/
      continue-on-error: true
    - uses: codecov/codecov-action@v5
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        files: fedify/.cov.lcov
        files: .cov.lcov
      continue-on-error: true
    - run: "true"

  test-node:
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
      fail-fast: false
    runs-on: ${{ matrix.os }}
    runs-on: ubuntu-latest
    services:
      rabbitmq:
        image: rabbitmq
        env:
          RABBITMQ_DEFAULT_USER: guest
          RABBITMQ_DEFAULT_PASS: guest
        ports:
        - 5672:5672
    env:
      AMQP_URL: amqp://guest:guest@localhost:5672
    steps:
    - if: github.event_name == 'push'
      uses: actions/checkout@v4
@@ -76,15 +84,21 @@ jobs:
    - uses: pnpm/action-setup@v4
      with:
        version: 10
    - run: deno task test:node
      working-directory: ${{ github.workspace }}/fedify/
    - run: pnpm install
    - run: pnpm run --recursive test

  test-bun:
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
      fail-fast: false
    runs-on: ${{ matrix.os }}
    runs-on: ubuntu-latest
    services:
      rabbitmq:
        image: rabbitmq
        env:
          RABBITMQ_DEFAULT_USER: guest
          RABBITMQ_DEFAULT_PASS: guest
        ports:
        - 5672:5672
    env:
      AMQP_URL: amqp://guest:guest@localhost:5672
    steps:
    - if: github.event_name == 'push'
      uses: actions/checkout@v4
@@ -105,8 +119,8 @@ jobs:
    - uses: pnpm/action-setup@v4
      with:
        version: 10
    - run: deno task test:bun
      working-directory: ${{ github.workspace }}/fedify/
    - run: pnpm install
    - run: pnpm run --recursive test:bun

  test-cfworkers:
    runs-on: ubuntu-latest
@@ -169,16 +183,9 @@ jobs:
        version: 10
    - run: '[[ "$(jq -r .version deno.json)" = "$(jq -r .version package.json)" ]]'
      working-directory: ${{ github.workspace }}/fedify/
    - run: deno task publish --dry-run
      working-directory: ${{ github.workspace }}/fedify/
    - run: deno task npm
      working-directory: ${{ github.workspace }}/fedify/
    - run: npm publish --dry-run fedify-fedify-*.tgz
      working-directory: ${{ github.workspace }}/fedify/
      env:
        DNT_SKIP_TEST: "true"
    - run: deno task publish-dry-run
      working-directory: ${{ github.workspace }}/cli/
    - run: deno task -f @fedify/fedify codegen
    - run: deno publish --dry-run
    - run: pnpm publish --recursive --dry-run

  publish:
    needs: [test, test-node, test-bun, test-cfworkers, lint, release-test]
@@ -235,7 +242,7 @@ jobs:
        echo version="$(jq -r .version deno.json)" >> $GITHUB_OUTPUT
        echo short_version="$(jq -r .version deno.json | sed 's/[+].*//')" >> $GITHUB_OUTPUT
      working-directory: ${{ github.workspace }}/fedify/
    - run: deno task -r sync-version
    - run: deno task check-versions --fix
    - if: github.ref_type == 'tag'
      run: |
        set -ex
@@ -246,12 +253,14 @@ jobs:
    # in deno.json:
    - run: rm vocab/.gitignore
      working-directory: ${{ github.workspace }}/fedify/
    - run: deno task npm
      working-directory: ${{ github.workspace }}/fedify/
    - run: |
        pnpm install
        pnpm pack --recursive
        if [[ "$GITHUB_REF_TYPE" != tag ]]; then
          rm fedify-cli-*.tgz
        fi
    - run: deno task pack
      working-directory: ${{ github.workspace }}/cli/
    - run: 'deno task npm "$(jq -r .version deno.json)"'
      working-directory: ${{ github.workspace }}/cli/
    - id: extract-changelog
      uses: dahlia/submark@5a5ff0a58382fb812616a5801402f5aef00f90ce
      with:
@@ -267,55 +276,45 @@ jobs:
      with:
        name: dist
        path: |
          fedify/fedify-fedify-*.tgz
          cli/fedify-cli-*
          fedify-*.tgz
          cli/fedify-cli-*.tar.xz
          cli/fedify-cli-*.zip
    - if: github.event_name == 'push' && github.ref_type == 'tag'
      uses: softprops/action-gh-release@v1
      with:
        body_path: ${{ steps.extract-changelog.outputs.output-file }}
        name: Fedify ${{ github.ref_name }}
        files: |
          fedify/fedify-fedify-*.tgz
          cli/fedify-cli-*
          fedify-*.tgz
          cli/fedify-cli-*.tar.xz
          cli/fedify-cli-*.zip
        generate_release_notes: false
    - if: github.event_name == 'pull_request_target'
      run: deno task publish --allow-dirty --no-provenance
      working-directory: ${{ github.workspace }}/fedify/
    - if: github.event_name != 'pull_request_target'
      run: deno task publish --allow-dirty
      working-directory: ${{ github.workspace }}/fedify/
    - if: github.event_name == 'pull_request_target'
      run: deno task publish --allow-dirty --no-provenance
      working-directory: ${{ github.workspace }}/cli/
    - if: github.event_name != 'pull_request_target'
      run: deno task publish --allow-dirty
      working-directory: ${{ github.workspace }}/cli/
    - run: |
        set -ex
        deno task -f @fedify/fedify codegen
        if [[ "$GITHUB_EVENT_NAME" = "pull_request_target" ]]; then
          deno publish --allow-dirty --no-provenance
        else
          deno publish --allow-dirty
        fi
    - run: |
        set -ex
        npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
        for pkg in fedify-*.tgz; do
          if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
          npm publish --provenance --access public fedify-fedify-*.tgz
            npm publish --provenance --access public "$pkg"
          elif [[ "$GITHUB_EVENT_NAME" = "pull_request_target" ]]; then
            npm publish \
            --provenance \
              --access public \
              --tag "pr-$PR_NUMBER" \
            fedify-fedify-*.tgz
              "$pkg"
          else
          npm publish --provenance --access public --tag dev fedify-fedify-*.tgz
            npm publish --provenance --access public --tag dev "$pkg"
          fi
        done
      env:
        NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
        PR_NUMBER: ${{ github.event.pull_request.number }}
      working-directory: ${{ github.workspace }}/fedify/
    - if: github.event_name == 'push' && github.ref_type == 'tag'
      run: |
        set -ex
        npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
        npm publish --provenance --access public fedify-cli-*.tgz
      env:
        NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
      working-directory: ${{ github.workspace }}/cli/
    - if: github.event_name == 'pull_request_target'
      uses: thollander/actions-comment-pull-request@v3
      with:
@@ -329,12 +328,16 @@ jobs:
          The latest push to this pull request has been published to JSR and npm as a pre-release:

          - [`jsr:@fedify/fedify@${{ steps.versioning.outputs.version }}`][1]
          - [`jsr:@fedify/cli@${{ steps.versioning.outputs.version }}`][2]
          - [`npm:@fedify/fedify@${{ steps.versioning.outputs.short_version }}`][3]
          - [`npm:@fedify/fedify@${{ steps.versioning.outputs.short_version }}`][2]
          - [`jsr:@fedify/amqp@${{ steps.versioning.outputs.version }}`][3]
          - [`npm:@fedify/amqp@${{ steps.versioning.outputs.short_version }}`][4]
          - [`jsr:@fedify/cli@${{ steps.versioning.outputs.version }}`][5]

          [1]: https://jsr.io/@fedify/fedify@${{ steps.versioning.outputs.version }}
          [2]: https://jsr.io/@fedify/cli@${{ steps.versioning.outputs.version }}
          [3]: https://www.npmjs.com/package/@fedify/fedify/v/${{ steps.versioning.outputs.short_version }}
          [2]: https://www.npmjs.com/package/@fedify/fedify/v/${{ steps.versioning.outputs.short_version }}
          [3]: https://jsr.io/@fedify/amqp@${{ steps.versioning.outputs.version }}
          [4]: https://www.npmjs.com/package/@fedify/amqp/v/${{ steps.versioning.outputs.short_version }}
          [5]: https://jsr.io/@fedify/cli@${{ steps.versioning.outputs.version }}
        pr-number: ${{ github.event.pull_request.number }}
        comment-tag: publish

+1 −0
Original line number Diff line number Diff line
.claude/settings.local.json
.DS_Store
dist/
deno.lock
node_modules/
repomix-output.xml

amqp/README.md

0 → 100644
+109 −0
Original line number Diff line number Diff line
<!-- deno-fmt-ignore-file -->

@fedify/amqp: AMQP/RabbitMQ driver for Fedify
=============================================

[![JSR][JSR badge]][JSR]
[![npm][npm badge]][npm]
[![GitHub Actions][GitHub Actions badge]][GitHub Actions]

> [!NOTE]
>
> Although it's theoretically possible to be used with any AMQP 0-9-1 broker,
> this package is primarily designed for and tested with [RabbitMQ].

This package provides [Fedify]'s [`MessageQueue`] implementation for AMQP, which
is supported by RabbitMQ:

 -  [`AmqpMessageQueue`]

Here is an example of how to use it:

~~~~ typescript
import { createFederation } from "@fedify/fedify";
import { AmqpMessageQueue } from "@fedify/amqp";
import { connect } from "amqplib";

const federation = createFederation({
  queue: new AmqpMessageQueue(await connect("amqp://localhost")),
  // ... other configurations
});
~~~~

The `AmqpMessageQueue` constructor accepts options as the second
parameter, which can be used to configure the message queue:

~~~~ typescript
new AmqpMessageQueue(await connect("amqp://localhost"), {
  queue: "my_queue",
})
~~~~

For more details, please refer to the docs of [`AmqpMessageQueueOptions`].

[JSR]: https://jsr.io/@fedify/amqp
[JSR badge]: https://jsr.io/badges/@fedify/amqp
[npm]: https://www.npmjs.com/package/@fedify/amqp
[npm badge]: https://img.shields.io/npm/v/@fedify/amqp?logo=npm
[GitHub Actions]: https://github.com/fedify-dev/amqp/actions/workflows/main.yaml
[GitHub Actions badge]: https://github.com/fedify-dev/amqp/actions/workflows/main.yaml/badge.svg
[RabbitMQ]: https://www.rabbitmq.com/
[Fedify]: https://fedify.dev/
[`KvStore`]: https://jsr.io/@fedify/fedify/doc/federation/~/KvStore
[`MessageQueue`]: https://jsr.io/@fedify/fedify/doc/federation/~/MessageQueue
[`AmqpMessageQueue`]: https://jsr.io/@fedify/amqp/doc/mq/~/AmqpMessageQueue
[`AmqpMessageQueueOptions`]: https://jsr.io/@fedify/amqp/doc/mq/~/AmqpMessageQueueOptions


Installation
------------

### Deno

~~~~ sh
deno add @fedify/amqp
~~~~

### Node.js

~~~~ sh
npm install @fedify/amqp
~~~~

### Bun

~~~~ sh
bun add @fedify/amqp
~~~~


Changelog
---------

### Version 0.4.0

To be released.

### Version 0.3.0

Released on June 25, 2025.

 -  Added `nativeRetrial` option to `AmqpMessageQueueOptions` to enable
    native retrial of messages.

 -  The type of the `AmqpMessageQueue()` constructor's first parameter has been
    changed from `Connection` to `ChannelModel`.

### Version 0.2.0

Released on March 28, 2025.

 -  Added `AmqpMessageQueue.enqueueMany()` method for efficiently enqueuing
    multiple messages at once.

 -  Updated *@js-temporal/polyfill* to 0.5.0 for Node.js and Bun. On Deno,
    there is no change because the polyfill is not used.

### Version 0.1.0

Initial release.  Released on October 14, 2024.

amqp/deno.json

0 → 100644
+46 −0
Original line number Diff line number Diff line
{
  "name": "@fedify/amqp",
  "version": "1.8.0",
  "license": "MIT",
  "exports": {
    ".": "./mod.ts",
    "./mq": "./mq.ts"
  },
  "imports": {
    "@hongminhee/suite": "jsr:@hongminhee/suite@^0.6.3"
  },
  "nodeModulesDir": "auto",
  "unstable": [
    "temporal"
  ],
  "exclude": [
    ".github",
    "node_modules",
    "npm",
    "pnpm-lock.yaml"
  ],
  "tasks": {
    "build": "pnpm build",
    "check": "deno fmt --check && deno lint && deno check *.ts",
    "test": "deno test --allow-net --allow-env",
    "test:node": {
      "dependencies": [
        "build"
      ],
      "command": "node --experimental-transform-types --test"
    },
    "test:bun": {
      "dependencies": [
        "build"
      ],
      "command": "bun test --timeout 15000"
    },
    "test-all": {
      "dependencies": [
        "test",
        "test:node",
        "test:bun"
      ]
    }
  }
}

amqp/mod.ts

0 → 100644
+1 −0
Original line number Diff line number Diff line
export * from "./mq.ts";
Loading