Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/exams-page
Browse files Browse the repository at this point in the history
  • Loading branch information
rubuy-74 authored Oct 7, 2023
2 parents d3e75bb + 2d63a85 commit 60c0b08
Show file tree
Hide file tree
Showing 143 changed files with 7,954 additions and 1,639 deletions.
36 changes: 23 additions & 13 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
on:
push:
branches: [ master, develop ]
branches: [master, develop]

jobs:
bump_version:
permissions:
actions: "write"
name: "Bump pubspec version"
runs-on: ubuntu-latest
env:
Expand All @@ -14,12 +16,19 @@ jobs:
with:
token: ${{ secrets.NIAEFEUPBOT_PAT }}

- name: Get develop hash
if: github.ref == 'refs/heads/master'
run: |
git fetch origin develop
current_hash=$(git rev-parse origin/develop)
echo "DEVELOPHASH=$current_hash" >> $GITHUB_ENV
- name: Bump flutter patch version
if: github.ref == 'refs/heads/develop'
if: github.ref == 'refs/heads/develop' || github.sha != env.DEVELOPHASH
run: perl -i -pe 's/^(\d+\.\d+\.)(\d+)(\+)(\d+)$/$1.($2+1).($3).($4+1)/e' ${{ env.APP_VERSION_PATH }}

- name: Bump flutter minor version
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/master' && github.sha == env.DEVELOPHASH
run: perl -i -pe 's/^(\d+)(\.)(\d+)(\.)(\d+)(\+)(\d+)$/$1.($2).($3+1).($4).(0).($6).($7+1)/e' ${{ env.APP_VERSION_PATH }}

- name: Copy app version to pubspec
Expand All @@ -29,9 +38,16 @@ jobs:
with:
commit_message: "Bump app version [no ci]"

- name: Propagate master version bump to develop
- name: Propagate master version bump to develop if master version is aad
if: github.ref == 'refs/heads/master'
run: git push --force-with-lease origin HEAD:develop
run: |
git fetch origin develop
if [[ $(git diff --quiet HEAD~1 origin/develop) ]]; then
echo "Master version does not match develop version"
else
echo "Master version matches develop version"
git push --force-with-lease origin HEAD:develop
fi
build:
name: "Build App Bundle"
Expand All @@ -40,7 +56,7 @@ jobs:
env:
PROPERTIES_PATH: "android/key.properties"
JAVA_VERSION: "11.x"
FLUTTER_VERSION: "3.7.2"
FLUTTER_VERSION: "3.10.6"
defaults:
run:
working-directory: ./uni
Expand All @@ -49,17 +65,11 @@ jobs:
- uses: actions/setup-java@v3
with:
java-version: ${{env.JAVA_VERSION}}
distribution: 'zulu'
distribution: "zulu"
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}

- name: Setup production environment
run: |
mkdir -p assets/env
rm -f -- assets/env/env.json
echo "{\"gh_token\": \"${{ secrets.NIAEFEUPBOT_PAT }}\"}" >> assets/env/env.json
- name: Download Android keystore
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > /tmp/key.jks

Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/format_lint_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches: [master, develop]

env:
FLUTTER_VERSION: 3.7.2
FLUTTER_VERSION: 3.10.6
JAVA_VERSION: 11.x

jobs:
Expand All @@ -20,7 +20,7 @@ jobs:
with:
flutter-version: ${{ env.FLUTTER_VERSION }}

- run: dart format $(find . -type f -name "*.dart" -a -not -name "*.g.dart") --set-exit-if-changed
- run: dart format $(find . -type f -name "*.dart" -a -not -name "*.g.dart" -a -not -name "*.mocks.dart") --set-exit-if-changed

lint:
name: "Lint"
Expand Down Expand Up @@ -65,4 +65,11 @@ jobs:
with:
flutter-version: ${{ env.FLUTTER_VERSION }}

- run: flutter test --no-sound-null-safety
- name: Test with coverage
run: flutter test --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
.pub/
build/
*.bin
uni/pubspec.lock
.flutter-plugins*

# IDE files
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

[![Build badge](https://img.shields.io/github/actions/workflow/status/NIAEFEUP/uni/format_lint_test.yaml?style=for-the-badge&branch=develop)](https://github.com/NIAEFEUP/uni/actions)
[![Deploy badge](https://img.shields.io/github/actions/workflow/status/NIAEFEUP/uni/deploy.yaml?label=Deploy&style=for-the-badge&branch=develop)](https://github.com/NIAEFEUP/uni/actions)
[![Codecov branch](https://img.shields.io/codecov/c/github/NIAEFEUP/uni/develop?style=for-the-badge)](https://app.codecov.io/gh/NIAEFEUP/uni/)

[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg?style=for-the-badge)](https://pub.dev/packages/very_good_analysis)
[![License badge](https://img.shields.io/github/license/NIAEFEUP/uni?style=for-the-badge)](https://github.com/NIAEFEUP/uni/blob/develop/LICENSE)
Expand Down
37 changes: 37 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# see https://docs.codecov.io/docs/codecov-yaml
# Validation check:
# $ curl --data-binary @codecov.yml https://codecov.io/validate

ignore:
- "**/*.g.dart"
- "!**/lib/**" # ignore all files outside of lib

codecov:
require_ci_to_pass: yes
notify:
wait_for_ci: yes

coverage:
precision: 0 # 2 = xx.xx%, 0 = xx%
round: up # how coverage is rounded: down/up/nearest
range: 40...100 # custom range of coverage colors from red -> yellow -> green
status:
project:
default:
informational: true
target: 70% # specify the target coverage for each commit status
threshold: 10% # allow this decrease on project
if_ci_failed: error
patch:
default:
informational: true
threshold: 50% # allow this decrease on patch
changes: false

github_checks:
annotations: false

comment:
layout: header, diff
require_changes: false
behavior: default
2 changes: 1 addition & 1 deletion pre-commit-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mkdir -p .git/hooks #it seems that are some cases where git will not create a ho
tee .git/hooks/pre-commit << EOF
#!/bin/sh
FILES="\$(git diff --name-only --cached | grep .*\.dart | grep -v .*\.g\.dart)"
FILES="\$(git diff --name-only --cached | grep .*\.dart | grep -v .*\.g\.dart | grep -v .*\.mocks\.dart)"
[ -z "\$FILES" ] && exit 0
Expand Down
3 changes: 1 addition & 2 deletions uni/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
Expand All @@ -9,7 +8,6 @@
.buildlog/
.history
.svn/
assets/env/env.json
*.env

# IntelliJ related
Expand Down Expand Up @@ -107,6 +105,7 @@ unlinked_spec.ds
**/Pods/
**/macos/Flutter/GeneratedPluginRegistrant.swift
**/macos/Flutter/ephemeral
**/macos/Podfile
**/xcuserdata/

# Windows
Expand Down
50 changes: 38 additions & 12 deletions uni/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@

This is a Flutter project, totally compatible with Android and iOS. To run it, you need to have Flutter installed on your machine. If you don't, you can follow the instructions on https://flutter.dev/docs/get-started/install.

### Further requirements

In order to submit bug reports to the Github API (needed in order to enable in-app bug reporting), a Github Personal Access Token is required. If you don't have one, you can create it on https://github.com/settings/tokens. The only permission it needs is **repo > public_repo**.

The token is read from the file assets/env/env.json, which you may need to create, and must be in the following format:

```json
{
"gh_token" : "your super secret token"
}
```

### Automated formatting

In order to contribute, you must format your changed files using `dart format` manually or enabing _formatting on save_ using your IDE ([VSCode or IntelliJ](https://docs.flutter.dev/tools/formatting)). Alternatively, you can install the git pre-commit hook that formats your changed files when you commit, doing the following command at the **root directory of the repository**:
Expand All @@ -30,6 +18,44 @@ In order to remove it, is it as simple as running the following command, from th
rm .git/hooks/pre-commit
```

### Generated files

Flutter doesn't support runtime reflection. In order to circumvent these limitations, we use **automatic code generation** or **static metaprogramming** for things like **mocks** and other possible usecases. By convention, you should **always commit** the generated `.dart` files into the repository.

Dart leverages annotations to signal the `build_runner` that it should generate some code. They look something like this:
```dart
import 'package:mockito/annotations.dart'
class Cat{
}
@GenerateNiceMocks([MockSpec<Cat>()])
void main(){
}
```
In this case, `build_runner` will detect that `GenerateNiceMocks` is a generator function from `mockito` and will generate code to a different file.

In order to run the `build_runner` once:
```sh
dart run build_runner build
```

But you can also watch for changes in `.dart` files and automatically run the `build_runner` on those file changes (useful if you find yourself in need to generate code very frequently):
```sh
dart run build_runner watch
```

## Translation files

Intl package allows the internationalization of the app, currently supporting Portuguese ('pt_PT') and English ('en_EN). This package creates `.arb` files (one for each language), mapping a key to the correspondent translated string.
In order to access those translations through getters, you must add the translations you want to the `.arb` files and run:
```
dart pub global run intl_utils:generate
```
This will generate `.dart` files with the getters you need to access the translations.
You must include `'package:uni/generated/l10n.dart'` and, depending on the locale of the application, `S.of(context).{key_of_translation}` will get you the translated string.

## Project structure

### Overview
Expand Down
6 changes: 3 additions & 3 deletions uni/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ include: package:very_good_analysis/analysis_options.yaml
analyzer:
# Exclude auto-generated files from dart analysis
exclude:
- '**.g.dart'
- '**.freezed.dart'
- "**.g.dart"
- "**.mocks.dart"
- "**generated/**"

# Custom linter rules. A list of all rules can be found at
# https://dart-lang.github.io/linter/lints/options/options.html
Expand All @@ -13,4 +14,3 @@ linter:
public_member_api_docs: false
avoid_equals_and_hash_code_on_mutable_classes: false
one_member_abstracts: false

6 changes: 2 additions & 4 deletions uni/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 33
compileSdkVersion 33 // default is flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

compileOptions {
Expand All @@ -50,10 +50,8 @@ android {

defaultConfig {
applicationId "pt.up.fe.ni.uni"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 21 // default is flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
targetSdkVersion 33 // default is flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
2 changes: 1 addition & 1 deletion uni/app_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.46+164
1.7.13+203
3 changes: 0 additions & 3 deletions uni/assets/env/.env.template

This file was deleted.

7 changes: 7 additions & 0 deletions uni/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
targets:
$default:
builders:
mockito|mockBuilder:
options:
build_extensions:
'^test/{{}}.dart': 'test/mocks/{{}}.mocks.dart'
5 changes: 4 additions & 1 deletion uni/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ target 'Runner' do
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
end
Loading

0 comments on commit 60c0b08

Please sign in to comment.