Skip to content

Commit

Permalink
ci: add pr test and lint (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercy811 authored Feb 6, 2024
1 parent 31a4419 commit 233818d
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 13 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test and Lint

on: [pull_request]

jobs:
test:
name: Check the source code
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Check Flutter version
run: flutter --version

- name: Install packages
run: flutter pub get

- name: Linter
run: flutter analyze

- name: Test
run: flutter test
43 changes: 43 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Semantic PR Check

on:
pull_request:
types: [opened, synchronize, edited]

jobs:
pr-title-check:
name: Check PR for semantic title
runs-on: ubuntu-latest
steps:
- name: PR title is valid
if: >
startsWith(github.event.pull_request.title, 'feat:') || startsWith(github.event.pull_request.title, 'feat(') ||
startsWith(github.event.pull_request.title, 'fix:') || startsWith(github.event.pull_request.title, 'fix(') ||
startsWith(github.event.pull_request.title, 'perf:') || startsWith(github.event.pull_request.title, 'perf(') ||
startsWith(github.event.pull_request.title, 'docs:') || startsWith(github.event.pull_request.title, 'docs(') ||
startsWith(github.event.pull_request.title, 'test:') || startsWith(github.event.pull_request.title, 'test(') ||
startsWith(github.event.pull_request.title, 'refactor:') || startsWith(github.event.pull_request.title, 'refactor(') ||
startsWith(github.event.pull_request.title, 'style:') || startsWith(github.event.pull_request.title, 'style(') ||
startsWith(github.event.pull_request.title, 'build:') || startsWith(github.event.pull_request.title, 'build(') ||
startsWith(github.event.pull_request.title, 'ci:') || startsWith(github.event.pull_request.title, 'ci(') ||
startsWith(github.event.pull_request.title, 'chore:') || startsWith(github.event.pull_request.title, 'chore(') ||
startsWith(github.event.pull_request.title, 'revert:') || startsWith(github.event.pull_request.title, 'revert(')
run: |
echo 'Title checks passed'
- name: PR title is invalid
if: >
!startsWith(github.event.pull_request.title, 'feat:') && !startsWith(github.event.pull_request.title, 'feat(') &&
!startsWith(github.event.pull_request.title, 'fix:') && !startsWith(github.event.pull_request.title, 'fix(') &&
!startsWith(github.event.pull_request.title, 'perf:') && !startsWith(github.event.pull_request.title, 'perf(') &&
!startsWith(github.event.pull_request.title, 'docs:') && !startsWith(github.event.pull_request.title, 'docs(') &&
!startsWith(github.event.pull_request.title, 'test:') && !startsWith(github.event.pull_request.title, 'test(') &&
!startsWith(github.event.pull_request.title, 'refactor:') && !startsWith(github.event.pull_request.title, 'refactor(') &&
!startsWith(github.event.pull_request.title, 'style:') && !startsWith(github.event.pull_request.title, 'style(') &&
!startsWith(github.event.pull_request.title, 'build:') && !startsWith(github.event.pull_request.title, 'build(') &&
!startsWith(github.event.pull_request.title, 'ci:') && !startsWith(github.event.pull_request.title, 'ci(') &&
!startsWith(github.event.pull_request.title, 'chore:') && !startsWith(github.event.pull_request.title, 'chore(') &&
!startsWith(github.event.pull_request.title, 'revert:') && !startsWith(github.event.pull_request.title, 'revert(')
run: |
echo 'Pull request title is not valid. Please check github.com/amplitude/Amplitude-Flutter/blob/main/CONTRIBUTING.md#pr-commit-title-conventions'
exit 1
23 changes: 22 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,25 @@ You can checkout the the official Flutter documentation on [getting started](htt

Checkout the [set up and editor](https://flutter.dev/docs/get-started/editor?tab=vscode) and [test drive](https://flutter.dev/docs/get-started/test-drive) sections of the official Flutter documentation on setting up your environment.

You should then be able to run the Flutter project in `example/` which has the Amplitude Flutter SDK installed.
You should then be able to run the Flutter project in `example/` which has the Amplitude Flutter SDK installed.

## Practices

### PR Commit Title Conventions

PR titles should follow [conventional commit standards](https://www.conventionalcommits.org/en/v1.0.0/). This helps automate the release process.

#### Commit Types

- **Special Case**: Any commit with `BREAKING CHANGES` in the body: Creates major release
- `feat(<optional scope>)`: New features (minimum minor release)
- `fix(<optional scope>)`: Bug fixes (minimum patch release)
- `perf(<optional scope>)`: Performance improvement
- `docs(<optional scope>)`: Documentation updates
- `test(<optional scope>)`: Test updates
- `refactor(<optional scope>)`: Code change that neither fixes a bug nor adds a feature
- `style(<optional scope>)`: Code style changes (e.g. formatting, commas, semi-colons)
- `build(<optional scope>)`: Changes that affect the build system or external dependencies (e.g. Yarn, Npm)
- `ci(<optional scope>)`: Changes to our CI configuration files and scripts
- `chore(<optional scope>)`: Other changes that don't modify src or test files
- `revert(<optional scope>)`: Revert commit
1 change: 0 additions & 1 deletion example/lib/app_state.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:amplitude_flutter/amplitude.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class AppState extends InheritedWidget {
Expand Down
4 changes: 2 additions & 2 deletions example/lib/deviceid_sessionid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class _DeviceIdSessionIdState extends State<DeviceIdSessionId> {
children: [
Row(
children: [
Text('Device Id', style: Theme.of(context).textTheme.headline5),
Text('Device Id', style: Theme.of(context).textTheme.headlineSmall),
],
),
Row(
Expand All @@ -28,7 +28,7 @@ class _DeviceIdSessionIdState extends State<DeviceIdSessionId> {
),
Row(
children: [
Text('Session Id', style: Theme.of(context).textTheme.headline5),
Text('Session Id', style: Theme.of(context).textTheme.headlineSmall),
],
),
Row(children: [
Expand Down
2 changes: 1 addition & 1 deletion example/lib/event_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _EventFormState extends State<EventForm> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Event', style: Theme.of(context).textTheme.headline5),
Text('Event', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 10),
TextField(
decoration: InputDecoration(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/flush_thresholds_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _FlushThresholdFormState extends State<FlushThresholdForm> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Flush Intervals', style: Theme.of(context).textTheme.headline5),
Text('Flush Intervals', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 10),
TextField(
decoration: InputDecoration(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/group_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _GroupFormState extends State<GroupForm> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Group / Account', style: Theme.of(context).textTheme.headline5),
Text('Group / Account', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 10),
Row(children: <Widget>[
Expanded(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/group_identify_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class _GroupIdentifyFormState extends State<GroupIdentifyForm> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Group Identify', style: Theme.of(context).textTheme.headline5),
Text('Group Identify', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 10),
Row(children: <Widget>[
Expanded(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/identify_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _IdentifyFormState extends State<IdentifyForm> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Identify', style: Theme.of(context).textTheme.headline5),
Text('Identify', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 10),
Row(children: <Widget>[
Expanded(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/my_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class _MyAppState extends State<MyApp> {
child: const Text('Flush Events'),
onPressed: _flushEvents,
),
Text(_message, style: Theme.of(context).textTheme.bodyText1)
Text(_message, style: Theme.of(context).textTheme.bodyLarge)
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/revenue_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _RevenueFormState extends State<RevenueForm> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Revenue', style: Theme.of(context).textTheme.headline5),
Text('Revenue', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 10),
TextField(
decoration: dec.copyWith(labelText: 'Product Id'),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/user_id_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class _UserIdFormState extends State<UserIdForm> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Current User Id', style: Theme.of(context).textTheme.headline5),
Text('Current User Id', style: Theme.of(context).textTheme.headlineSmall),
FutureBuilder(
future: AppState.of(context).analytics.getUserId(),
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
return Text(snapshot.data.toString());
},
),
const SizedBox(height: 10),
Text('User Id', style: Theme.of(context).textTheme.headline5),
Text('User Id', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 10),
new TextField(
autocorrect: false,
Expand Down
2 changes: 2 additions & 0 deletions lib/web/amplitude_js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class Amplitude {
String groupType,
String groupName,
Identify groupIdentify,
// ignore: non_constant_identifier_names
Function? opt_callback,
// ignore: non_constant_identifier_names
Function? opt_error_callback,
bool? outOfSession);
external bool setOffline(bool enabled);
Expand Down

0 comments on commit 233818d

Please sign in to comment.