diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 9e98858..510884b 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -1,9 +1,8 @@ -name: deploy dev docs +name: Deploy dev docs to nyxx.l7ssha.xyz on: push: branches: - - dev - next jobs: @@ -15,10 +14,10 @@ jobs: uses: dart-lang/setup-dart@v1 - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v4 - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.pub-cache key: ${{ runner.os }}-pubspec-${{ hashFiles('**/pubspec.lock') }} @@ -31,17 +30,13 @@ jobs: - name: Generate docs run: dart doc - - name: Extract branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - name: Deploy nyxx dev docs - uses: easingthemes/ssh-deploy@v2.1.5 + uses: easingthemes/ssh-deploy@v5.1.0 env: - SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_SERVER_KEY }} ARGS: "-rltDzvO" SOURCE: "doc/api/" + TARGET: "${{ secrets.DEPLOY_REMOTE_TARGET }}/dartdocs/nyxx_extensions/${{ github.head_ref || github.ref_name }}/" + with: REMOTE_HOST: ${{ secrets.DEPLOY_REMOTE_HOST }} REMOTE_USER: ${{ secrets.DEPLOY_REMOTE_USER }} - TARGET: "${{ secrets.DEPLOY_REMOTE_TARGET }}/dartdocs/nyxx_extensions/${{ steps.extract_branch.outputs.branch }}/" + SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_SERVER_KEY }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a4ed848..b6025c1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,9 +1,9 @@ -name: publish +name: Publish package to pub.dev on: - push: - branches: - - main + release: + types: + - created jobs: nyxx_publish: @@ -13,7 +13,7 @@ jobs: uses: actions/checkout@v2 - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.pub-cache key: ${{ runner.os }}-pubspec-${{ hashFiles('**/pubspec.lock') }} @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..59f8a19 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,139 @@ +name: Test + +on: + push: + branches: + - main + - next + pull_request: + +jobs: + analyze: + name: dart analyze + runs-on: ubuntu-latest + steps: + - name: Setup Dart Action + uses: dart-lang/setup-dart@v1 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Cache + uses: actions/cache@v4 + 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 analyze + + fix: + name: dart fix + runs-on: ubuntu-latest + steps: + - name: Setup Dart Action + uses: dart-lang/setup-dart@v1 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Cache + uses: actions/cache@v4 + 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: dart format + runs-on: ubuntu-latest + steps: + - name: Setup Dart Action + uses: dart-lang/setup-dart@v1 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Cache + uses: actions/cache@v4 + with: + path: ~/.pub-cache + key: ${{ runner.os }}-pubspec-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-pubspec- + + - name: Install dependencies + run: dart pub get + + - name: Format + run: dart format --set-exit-if-changed -l 160 ./lib + + unit-tests: + needs: [ format, analyze, fix ] + name: Unit tests + 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/checkout@v4 + + - name: Cache + uses: actions/cache@v4 + with: + path: ~/.pub-cache + key: ${{ runner.os }}-pubspec-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-pubspec- + + - name: Install dependencies + run: dart pub get + + - name: Unit tests + 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/checkout@v4 + + - name: Cache + uses: actions/cache@v4 + 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/** diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml deleted file mode 100644 index 69bc5e4..0000000 --- a/.github/workflows/unit_tests.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: unit tests - -on: - push: - branches-ignore: - - main - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - steps: - - name: Setup Dart Action - uses: dart-lang/setup-dart@v1 - - - name: Checkout - uses: actions/checkout@v2.3.4 - - - 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 analyze - - format: - name: Format - runs-on: ubuntu-latest - steps: - - name: Setup Dart Action - uses: dart-lang/setup-dart@v1 - - - name: Checkout - uses: actions/checkout@v2.3.4 - - - 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: Format - run: dart format --set-exit-if-changed -l 160 ./lib - - tests: - needs: [ format, analyze ] - name: Tests - runs-on: ubuntu-latest - env: - TEST_TOKEN: ${{ secrets.TEST_TOKEN }} - TEST_GUILD: ${{ secrets.TEST_GUILD }} - TEST_TEXT_CHANNEL: ${{ secrets.TEST_TEXT_CHANNEL }} - steps: - - name: Setup Dart Action - uses: dart-lang/setup-dart@v1 - - - name: Checkout - uses: actions/checkout@v2.3.4 - - - 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: Unit tests - run: dart run test --coverage="coverage" diff --git a/CHANGELOG.md b/CHANGELOG.md index e92fd45..d5a0848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 4.2.1 +__01.11.2024__ + +- bug: Fix getInviteUri default scopes + ## 4.2.0 __04.10.2024__ diff --git a/Makefile b/Makefile index 950244b..1aa3fdc 100644 --- a/Makefile +++ b/Makefile @@ -1,40 +1,26 @@ -.PHONY: help help: @fgrep -h "##" $(MAKEFILE_LIST) | sed -e 's/\(\:.*\#\#\)/\:\ /' | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' -.PHONY: app-check ## Run basic format checks and then generate code coverage -app-check: format-check generate-coverage - -.PHONY: format-check ## Check basic format -format-check: format analyze - -.PHONY: generate-coverage -generate-coverage: integration-tests unit-tests coverage-format coverage-gen-html ## Run all test and generate html code coverage +format: ## Run dart format + dart format -l 160 . -.PHONY: integration-tests -integration-tests: ## Run integration tests with coverage - (timeout 20s dart run test --coverage="coverage" --timeout=none test/integration/** ; exit 0) +fix: ## Run dart fix + dart fix --apply -.PHONY: unit-tests -unit-tests: ## Run unit tests with coverage - (timeout 10s dart run test --coverage="coverage" --timeout=none test/unit/** ; exit 0) +analyze: ## Run dart analyze + dart analyze -.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 +unit-tests: ## Run unit tests + dart run test test/unit/** -.PHONY: coverage-gen-html -coverage-gen-html: ## Generate html coverage from lcov data - genhtml coverage/coverage.lcov -o coverage/coverage_gen +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 -format: ## Run dart format - dart format --set-exit-if-changed -l 160 ./lib +fix-project: analyze fix format ## Fix whole project -.PHONY: format-apply -format-apply: ## Run dart format - dart format --fix -l 160 ./lib +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 diff --git a/analysis_options.yaml b/analysis_options.yaml index 6cd73fb..5075f41 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,10 +1,4 @@ include: package:lints/recommended.yaml -linter: - rules: - implementation_imports: false - analyzer: - language: - strict-raw-types: true - strict-casts: false + exclude: [build/**] diff --git a/lib/src/extensions/application.dart b/lib/src/extensions/application.dart index b6940c8..8256e78 100644 --- a/lib/src/extensions/application.dart +++ b/lib/src/extensions/application.dart @@ -4,7 +4,7 @@ import 'package:nyxx/nyxx.dart'; extension ApplicationExtensions on PartialApplication { /// Get a URL users can visit to add this bot to a guild. Uri getInviteUri({ - List scopes = const ['bot', 'application.commands'], + List scopes = const ['bot', 'applications.commands'], Flags? permissions, Snowflake? guildId, bool? disableGuildSelect, diff --git a/pubspec.yaml b/pubspec.yaml index 45e030d..158e401 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: nyxx_extensions -version: 4.2.0 +version: 4.2.1 description: Extensions to the Discord API provided in nyxx, including pagination support and message sanitization. repository: https://github.com/nyxx-discord/nyxx_extensions documentation: https://nyxx.l7ssha.xyz