Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up unit tests & run them in CI #336

Merged
merged 12 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ on: [push]

jobs:
build:

runs-on: ubuntu-latest

container:
image: dart:2.14

image: dart:2.17
steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: dart pub get
- name: Dart Analyzer
run: dart analyze
- name: Check Dart Format
run: dart format --set-exit-if-changed -o none lib test tool example && echo Dart Format 👍 || echo Files needed Dart formatting 😢
run: dart format --set-exit-if-changed -o none lib test tool example integration_test && echo Dart Format 👍 || echo Files needed Dart formatting 😢
- name: Check if Publishable
run: dart pub publish --dry-run
2 changes: 1 addition & 1 deletion .github/workflows/release_unreleased_prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
container: dart:2.14.4
container: dart:2.17.7
permissions:
contents: write

Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ on:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
sdk: [2.14.4, 2.17.7, stable] # Test with at least the declared minimum Dart version
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1
- name: Install dependencies
run: dart pub get
# - name: Unit tests
# run: dart test test
# - name: Integration tests
# run: dart test integration_test
- uses: actions/checkout@v2
- uses: dart-lang/[email protected]
with:
sdk: ${{ matrix.sdk }}
- name: Install dependencies
run: dart pub get
- name: Unit tests
run: dart test
# - name: Integration tests
# run: dart test integration_test
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.DEFAULT_GOAL := help
SHELL=/bin/bash -o pipefail

# Cite: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help: ## Display this help page
@grep -E '^[a-zA-Z0-9/_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: fixtures
fixtures: ## Run octokit-fixtures-server for scenario tests
@npx octokit-fixtures-server &

.PHONY: stop
stop: ## Stop the fixtures server
@killall node

.PHONY: test
test: fixtures ## Run tests
@dart test -P all
make stop
15 changes: 15 additions & 0 deletions dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
tags:
scenarios:
skip: |
Not run by default when running dart test. To run:
npx octokit-fixtures-server
dart test -P scenarios
or run all tests with:
make test

presets:
scenarios:
include_tags: scenarios
run_skipped: true
all:
run_skipped: true
12 changes: 8 additions & 4 deletions lib/src/common/model/misc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ class RateLimit {
///
/// API docs: https://developer.github.com/v3/rate_limit/
factory RateLimit.fromRateLimitResponse(Map<String, dynamic> response) {
final rateJson = response['rate'] as Map<String, dynamic>;
final limit = rateJson['limit'] as int?;
final remaining = rateJson['remaining'] as int?;
final resets = DateTime.fromMillisecondsSinceEpoch(rateJson['reset']!);
final rateJson = response['rate'] == null
? null
: response['rate'] as Map<String, dynamic>;
final limit = rateJson?['limit'] as int?;
final remaining = rateJson?['remaining'] as int?;
final resets = rateJson?['reset'] == null
? null
: DateTime.fromMillisecondsSinceEpoch(rateJson?['reset']);
return RateLimit(limit, remaining, resets);
}

Expand Down
1 change: 1 addition & 0 deletions lib/src/common/model/repos_releases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class CreateRelease {

String? discussionCategoryName;

@JsonKey(defaultValue: false)
bool generateReleaseNotes = false;

CreateRelease(this.tagName);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/common/model/repos_releases.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ dev_dependencies:
json_serializable: ^6.0.0
lints: ^1.0.0
mockito: ^5.0.0
pub_semver:
nock: ^1.0.0
pub_semver: ^2.0.0
test: ^1.16.0
yaml: ^3.0.0
yaml_edit:
Loading