Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
l7ssha committed Oct 24, 2024
2 parents a11bc80 + e5c24ed commit f4a4535
Show file tree
Hide file tree
Showing 49 changed files with 1,017 additions and 147 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Deploy dev docs to nyxx.l7ssha.xyz
on:
push:
branches:
- dev
- next

jobs:
Expand Down Expand Up @@ -39,9 +38,10 @@ jobs:
- name: Deploy nyxx dev docs
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_SERVER_KEY }}
ARGS: "-rltDzvO"
SOURCE: "doc/api/"
TARGET: "${{ secrets.DEPLOY_REMOTE_TARGET }}/dartdocs/nyxx/${{ steps.extract_branch.outputs.branch }}/"
with:
REMOTE_HOST: ${{ secrets.DEPLOY_REMOTE_HOST }}
REMOTE_USER: ${{ secrets.DEPLOY_REMOTE_USER }}
TARGET: "${{ secrets.DEPLOY_REMOTE_TARGET }}/dartdocs/nyxx/${{ steps.extract_branch.outputs.branch }}/"
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_SERVER_KEY }}
35 changes: 0 additions & 35 deletions .github/workflows/integration_tests.yml

This file was deleted.

27 changes: 4 additions & 23 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Publish nyxx to pub.dev
name: Publish package to pub.dev

on:
push:
branches:
- main
release:
types:
- created

jobs:
nyxx_publish:
Expand All @@ -28,22 +28,3 @@ jobs:
force: true
suppressBuildRunner: true
credentialJson: ${{ secrets.CREDENTIAL_JSON }}

- name: 'Commit release tag'
if: steps.publish.outputs.success
uses: hole19/git-tag-action@master
env:
TAG: ${{steps.publish.outputs.package}}-${{steps.publish.outputs.localVersion}}
GITHUB_TOKEN: ${{ secrets.TAG_RELEASE_TOKEN }}

- name: 'Create Release'
if: steps.publish.outputs.success
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TAG_RELEASE_TOKEN }}
with:
tag_name: ${{steps.publish.outputs.package}}-${{steps.publish.outputs.localVersion}}
release_name: ${{steps.publish.outputs.localVersion}}
body: See CHANGELOG.md for the changes in this version.
draft: false
prerelease: false
68 changes: 61 additions & 7 deletions .github/workflows/unit_tests.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: Run unit tests
name: Test

on:
push:
branches-ignore:
branches:
- main
- next
pull_request:

jobs:
analyze:
name: Analyze project source
name: dart analyze
runs-on: ubuntu-latest
steps:
- name: Setup Dart Action
Expand All @@ -31,8 +32,32 @@ jobs:
- name: Analyze project source
run: dart analyze

fix:
name: dart fix
runs-on: ubuntu-latest
steps:
- name: Setup Dart Action
uses: dart-lang/setup-dart@v1

- name: Checkout
uses: actions/[email protected]

- name: Cache
uses: actions/cache@v2
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pubspec-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pubspec-
- name: Install dependencies
run: dart pub get

- name: Analyze project source
run: dart fix --dry-run

format:
name: Check project formatting
name: dart format
runs-on: ubuntu-latest
steps:
- name: Setup Dart Action
Expand All @@ -55,8 +80,8 @@ jobs:
- name: Format
run: dart format --set-exit-if-changed -l 160 ./lib

tests:
needs: [ format, analyze ]
unit-tests:
needs: [ format, analyze, fix ]
name: Unit tests
runs-on: ubuntu-latest
env:
Expand All @@ -82,4 +107,33 @@ jobs:
run: dart pub get

- name: Unit tests
run: dart run test --coverage="coverage" test/unit/**
run: dart run test test/unit/**

integration-tests:
name: Integration tests
needs: [ format, analyze, fix ]
runs-on: ubuntu-latest
env:
TEST_TOKEN: ${{ secrets.TEST_TOKEN }}
TEST_TEXT_CHANNEL: ${{ secrets.TEST_TEXT_CHANNEL }}
TEST_GUILD: ${{ secrets.TEST_GUILD }}
steps:
- name: Setup Dart Action
uses: dart-lang/setup-dart@v1

- name: Checkout
uses: actions/[email protected]

- name: Cache
uses: actions/cache@v2
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pubspec-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pubspec-
- name: Install dependencies
run: dart pub get

- name: Integration tests
run: dart run test test/integration/**
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 6.5.0
__22.10.2024__

- feature: Add new member flags. ([`#715`](https://github.com/nyxx-discord/nyxx/pull/715)) - ([`e10d0ffb`](https://github.com/nyxx-discord/nyxx/commit/e10d0ffb680e28ed74397875bb6a0a4b2fa411f7))
- feature: Add new fields on message snapshot. ([`#716`](https://github.com/nyxx-discord/nyxx/pull/716)) - ([`57dc3282`](https://github.com/nyxx-discord/nyxx/commit/57dc32826081d60ec4fd905c939b15afe7dc7abe))
- bug: Fix serialization of `before` parameter. ([`#717`](https://github.com/nyxx-discord/nyxx/pull/717)) - ([`091c376f`](https://github.com/nyxx-discord/nyxx/commit/091c376fe80456d18e046ea047072d0271bb4384))
- feature: Recurrence rule can be set to null when updating. ([`#720`](https://github.com/nyxx-discord/nyxx/pull/720)) - ([`aaef80ac`](https://github.com/nyxx-discord/nyxx/commit/aaef80ac469331fa2da06eb776e2708813268b07))
- feature: Add support for soundboard. ([`#708`](https://github.com/nyxx-discord/nyxx/pull/708)) - ([`d93aa122`](https://github.com/nyxx-discord/nyxx/commit/d93aa122965b6d9b11f51dac377ee3c13eefac97))
- feature: Allow polls to be constructed in a interation response. ([`#719`](https://github.com/nyxx-discord/nyxx/pull/719)) - ([`db27c54d`](https://github.com/nyxx-discord/nyxx/commit/db27c54d24be1bb4010457041b7b4d09063e701d))
- feature: Add banner property to member. ([`#676](https://github.com/nyxx-discord/nyxx/pull/676)) - ([`4041b556`](https://github.com/nyxx-discord/nyxx/commit/4041b5569853d8eac6f2a165a3cb03b736e02cef))
- feature: Fix user avatar decoration, add member avatar decoration. ([`#718`](https://github.com/nyxx-discord/nyxx/pull/718)) - ([`b8e5ba7c`](https://github.com/nyxx-discord/nyxx/commit/b8e5ba7c89dbabd72821b7cd603bdab88cf0e751))
- maintenance: Update integration_tests.yml. ([`527eed5a`](https://github.com/nyxx-discord/nyxx/commit/527eed5a90c83071f5346273426bd0fd20089a60))

## 6.4.3
__08.10.2024__

Expand Down
57 changes: 18 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,26 @@
.PHONY: help
help: ## display help
@grep -F -h "##" $(MAKEFILE_LIST) | sed -e 's/\(\:.*\#\#\)/\:\ /' | grep -F -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
help:
@fgrep -h "##" $(MAKEFILE_LIST) | sed -e 's/\(\:.*\#\#\)/\:\ /' | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

.PHONY: app-check
app-check: format-check generate-coverage ## Run basic format checks and then generate code coverage

.PHONY: format-check
format-check: format analyze ## Check basic format

.PHONY: generate-coverage
generate-coverage: integration-tests unit-tests coverage-format coverage-gen-html ## Run all test and generate html code coverage

.PHONY: generate-coverage-unit
generate-coverage-unit: unit-tests coverage-format coverage-gen-html ## Run unit tests ad generate coverage

.PHONY: integration-tests
integration-tests: ## Run integration tests with coverage
(timeout 20s dart run test --coverage="coverage" --timeout=none test/integration/** ; exit 0)
format: ## Run dart format
dart format -l120 .

.PHONY: unit-tests
unit-tests: ## Run unit tests with coverage
(timeout 10s dart run test --coverage="coverage" --timeout=none test/unit/** ; exit 0)
fix: ## Run dart fix
dart fix --apply

.PHONY: coverage-format
coverage-format: ## Format dart coverage output to lcov
dart run coverage:format_coverage --lcov --in=coverage --out=coverage/coverage.lcov --packages=.packages --report-on=lib
analyze: ## Run dart analyze
dart analyze

.PHONY: coverage-gen-html
coverage-gen-html: ## Generate html coverage from lcov data
genhtml coverage/coverage.lcov -o coverage/coverage_gen
unit-tests: ## Run unit tests
dart run test test/unit/**

.PHONY: format
format: ## Run dart format
dart format --set-exit-if-changed -l 160 ./lib
integration-tests: ## Run integrations tests
ifndef TEST_TOKEN $(error TEST_TOKEN is undefined) endif \
ifndef TEST_TEXT_CHANNEL $(error TEST_TEXT_CHANNEL is undefined) endif \
ifndef TEST_GUILD $(error TEST_GUILD is undefined) endif \
dart run test test/integration/**

.PHONY: format-apply
format-apply: ## Run dart format
dart format --fix -l 160 ./lib
fix-project: analyze fix format ## Fix whole project

.PHONY: format-apply-tests
format-apply-tests: ## Apply formatting to tests directory
dart format --fix -l 160 ./test
test-project: unit-tests integration-tests ## Run all tests

.PHONY: analyze
analyze: ## Run dart analyze
dart analyze
check-project: fix-project test-project ## Run all checks
8 changes: 0 additions & 8 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
include: package:lints/recommended.yaml

linter:
rules:
unrelated_type_equality_checks: false
implementation_imports: false

analyzer:
exclude: [build/**]
language:
strict-casts: true
strict-raw-types: true
2 changes: 1 addition & 1 deletion lib/src/api_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:oauth2/oauth2.dart';
/// Options for connecting to the Discord API.
abstract class ApiOptions {
/// The version of nyxx used in [defaultUserAgent].
static const nyxxVersion = '6.4.3';
static const nyxxVersion = '6.5.0';

/// The URL to the nyxx repository used in [defaultUserAgent].
static const nyxxRepositoryUrl = 'https://github.com/nyxx-discord/nyxx';
Expand Down
4 changes: 2 additions & 2 deletions lib/src/builders/channel/forum_tag.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:nyxx/src/builders/builder.dart';
import 'package:nyxx/src/models/channel/types/forum.dart';
import 'package:nyxx/src/models/snowflake.dart';
import 'package:nyxx/src/utils/building_helpers.dart';

class ForumTagBuilder extends CreateBuilder<ForumTag> {
String name;
Expand All @@ -17,7 +18,6 @@ class ForumTagBuilder extends CreateBuilder<ForumTag> {
Map<String, Object?> build() => {
'name': name,
if (isModerated != null) 'moderated': isModerated,
if (emojiId != null) 'emoji_id': emojiId!.toString(),
if (emojiName != null) 'emoji_name': emojiName,
...makeEmojiMap(emojiId: emojiId, emojiName: emojiName),
};
}
15 changes: 3 additions & 12 deletions lib/src/builders/channel/guild_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:nyxx/src/models/channel/types/guild_voice.dart';
import 'package:nyxx/src/models/channel/voice_channel.dart';
import 'package:nyxx/src/models/permission_overwrite.dart';
import 'package:nyxx/src/models/snowflake.dart';
import 'package:nyxx/src/utils/building_helpers.dart';
import 'package:nyxx/src/utils/flags.dart';

class GuildChannelBuilder<T extends GuildChannel> extends CreateBuilder<T> {
Expand Down Expand Up @@ -231,12 +232,7 @@ class ForumChannelBuilder extends GuildChannelBuilder<ForumChannel> {
if (isNsfw != null) 'nsfw': isNsfw,
if (defaultAutoArchiveDuration != null) 'default_auto_archive_duration': defaultAutoArchiveDuration!.inMinutes,
if (!identical(defaultReaction, sentinelDefaultReaction))
'default_reaction_emoji': defaultReaction == null
? null
: {
if (defaultReaction!.emojiId != null) 'emoji_id': defaultReaction!.emojiId!.toString(),
if (defaultReaction!.emojiName != null) 'emoji_name': defaultReaction!.emojiName,
},
'default_reaction_emoji': defaultReaction == null ? null : makeEmojiMap(emojiId: defaultReaction!.emojiId, emojiName: defaultReaction!.emojiName),
if (tags != null) 'available_tags': tags!.map((e) => e.build()).toList(),
if (defaultSortOrder != null) 'default_sort_order': defaultSortOrder!.value,
};
Expand Down Expand Up @@ -293,12 +289,7 @@ class ForumChannelUpdateBuilder extends GuildChannelUpdateBuilder<ForumChannel>
if (flags != null) 'flags': flags!.value,
if (tags != null) 'available_tags': tags!.map((e) => e.build()).toList(),
if (!identical(defaultReaction, sentinelDefaultReaction))
'default_reaction_emoji': defaultReaction == null
? null
: {
if (defaultReaction!.emojiId != null) 'emoji_id': defaultReaction!.emojiId!.toString(),
if (defaultReaction!.emojiName != null) 'emoji_name': defaultReaction!.emojiName,
},
'default_reaction_emoji': defaultReaction == null ? null : makeEmojiMap(emojiId: defaultReaction!.emojiId, emojiName: defaultReaction!.emojiName),
if (defaultThreadRateLimitPerUser != null) 'default_thread_rate_limit_per_user': defaultThreadRateLimitPerUser!.inSeconds,
if (defaultSortOrder != null) 'default_sort_order': defaultSortOrder!.value,
if (defaultLayout != null) 'default_forum_layout': defaultLayout!.value,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/builders/guild/scheduled_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ScheduledEventUpdateBuilder extends UpdateBuilder<ScheduledEvent> {
this.type,
this.status,
this.image,
this.recurrenceRule,
this.recurrenceRule = sentinelRecurrenceRuleBuilder,
});

@override
Expand All @@ -137,7 +137,7 @@ class ScheduledEventUpdateBuilder extends UpdateBuilder<ScheduledEvent> {
if (type != null) 'entity_type': type!.value,
if (status != null) 'status': status!.value,
if (image != null) 'image': image!.buildDataString(),
if (recurrenceRule != null) 'recurrence_rule': recurrenceRule!.build(),
if (!identical(recurrenceRule, sentinelRecurrenceRuleBuilder)) 'recurrence_rule': recurrenceRule?.build(),
};
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/builders/guild/welcome_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:nyxx/src/builders/builder.dart';
import 'package:nyxx/src/builders/sentinels.dart';
import 'package:nyxx/src/models/guild/welcome_screen.dart';
import 'package:nyxx/src/utils/building_helpers.dart';

class WelcomeScreenUpdateBuilder extends UpdateBuilder<WelcomeScreen> {
bool? isEnabled;
Expand All @@ -20,8 +21,7 @@ class WelcomeScreenUpdateBuilder extends UpdateBuilder<WelcomeScreen> {
{
'channel_id': channel.channelId.toString(),
'description': channel.description,
'emoji_id': channel.emojiId?.toString(),
'emoji_name': channel.emojiName,
...makeEmojiMap(emojiId: channel.emojiId, emojiName: channel.emojiName),
},
],
if (!identical(description, sentinelString)) 'description': description,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/builders/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ImageBuilder {
ImageBuilder.gif(this.data) : format = 'gif';

static Future<ImageBuilder> fromFile(File file, {String? format}) async {
format ??= p.extension(file.path);
format ??= p.extension(file.path).substring(1);

const formats = {
'png': 'png',
Expand Down
Loading

0 comments on commit f4a4535

Please sign in to comment.