Skip to content

Commit

Permalink
Back to School 2023 Release (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes authored Sep 26, 2023
2 parents d2ed63a + 85d7277 commit 9e6b7f0
Show file tree
Hide file tree
Showing 310 changed files with 15,651 additions and 8,505 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/app_version_integrity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ on: pull_request

jobs:
app_version_integrity:
name: "Check for app version change"
name: "Version integrity"
runs-on: ubuntu-latest
env:
APP_VERSION_PATH: "uni/app_version.txt"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Fetch origin target branch
run: |
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
APP_VERSION_PATH: "uni/app_version.txt"
PUBSPEC_PATH: "uni/pubspec.yaml"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
token: ${{ secrets.NIAEFEUPBOT_PAT }}

Expand Down Expand Up @@ -40,25 +40,20 @@ jobs:
env:
PROPERTIES_PATH: "android/key.properties"
JAVA_VERSION: "11.x"
FLUTTER_VERSION: "3.3.2"
FLUTTER_VERSION: "3.10.6"
defaults:
run:
working-directory: ./uni
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: ${{env.JAVA_VERSION}}
- uses: subosito/flutter-action@v1
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 All @@ -77,7 +72,7 @@ jobs:
flutter build appbundle
- name: Upload App Bundle
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: appbundle
if-no-files-found: error
Expand All @@ -88,9 +83,9 @@ jobs:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Get App Bundle
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: appbundle

Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/format_lint_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
on:
pull_request:
push:
branches: [master, develop]

env:
FLUTTER_VERSION: 3.10.6
JAVA_VERSION: 11.x

jobs:
format:
name: "Format"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./uni
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}

- 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"
runs-on: ubuntu-latest
needs: format
defaults:
run:
working-directory: ./uni
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "zulu"
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}

- name: Cache pub dependencies
uses: actions/cache@v3
with:
path: ${{ env.FLUTTER_HOME }}/.pub-cache
key: ${{ runner.os }}-pub-${{ github.ref }}-${{ hashFiles('**/pubspec.lock') }}
restore-keys: ${{ runner.os }}-pub-${{ github.ref }}-

- run: flutter analyze .

test:
name: "Test"
runs-on: ubuntu-latest
needs: lint
defaults:
run:
working-directory: ./uni
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "zulu"
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}

- 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
45 changes: 0 additions & 45 deletions .github/workflows/test_lint.yaml

This file was deleted.

11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
<br>
<br>

[![Build badge](https://img.shields.io/github/actions/workflow/status/NIAEFEUP/project-schrodinger/test_lint.yaml?style=for-the-badge)](https://github.com/NIAEFEUP/project-schrodinger/actions)
[![Deploy badge](https://img.shields.io/github/actions/workflow/status/NIAEFEUP/project-schrodinger/deploy.yaml?label=Deploy&style=for-the-badge)](https://github.com/NIAEFEUP/project-schrodinger/actions)
[![License badge](https://img.shields.io/github/license/NIAEFEUP/project-schrodinger?style=for-the-badge)](https://github.com/NIAEFEUP/project-schrodinger/blob/master/LICENSE)
[![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)

<a href='https://play.google.com/store/apps/details?id=pt.up.fe.ni.uni&hl=pt_PT&gl=US&pli=1&pcampaignid=pcampaignidMKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'><img style="width: 135px;" alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png'/></a>

Expand All @@ -31,4 +34,4 @@ This application is licensed under the [GNU General Public License v3.0](./LICEN

Contributions are welcome, and can be made by opening a pull request. Please note, however, that a university's account is required to access most of the app's features.

For further information about the project structure, please refer to [the app's README file](./uni/README.md).
For further information about the project structure, please refer to [the app's README file](./uni/README.md).
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
15 changes: 15 additions & 0 deletions pre-commit-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
mkdir -p .git/hooks #it seems that are some cases where git will not create a hook directory if someone removed the hook templates
tee .git/hooks/pre-commit << EOF
#!/bin/sh
FILES="\$(git diff --name-only --cached | grep .*\.dart | grep -v .*\.g\.dart | grep -v .*\.mocks\.dart)"
[ -z "\$FILES" ] && exit 0
echo "\$FILES" | xargs dart format
echo "\$FILES" | xargs git add
EOF

chmod +x .git/hooks/pre-commit
4 changes: 3 additions & 1 deletion uni/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.buildlog/
.history
.svn/
assets/env/env.json
*.env

# IntelliJ related
*.iml
Expand Down Expand Up @@ -100,12 +100,14 @@ unlinked_spec.ds
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
**/ios/Podfile

# macOS
**/Flutter/ephemeral/
**/Pods/
**/macos/Flutter/GeneratedPluginRegistrant.swift
**/macos/Flutter/ephemeral
**/macos/Podfile
**/xcuserdata/

# Windows
Expand Down
56 changes: 48 additions & 8 deletions uni/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,57 @@

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
### Automated formatting

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**.
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**:

The token is read from the file assets/env/env.json, which you may need to create, and must be in the following format:
``` bash
chmod +x pre-commit-hook.sh && ./pre-commit-hook.sh
```

In order to remove it, is it as simple as running the following command, from the **root directory of the repository**:

```bash
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(){
```json
{
"gh_token" : "your super secret token"
}
}
```
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

Expand All @@ -36,4 +76,4 @@ The *view* part of the app is made of *widgets* (stateful or stateless). They ea
### Controller

The *controller* directory contains all artifacts that are not directly related to the view or the model. This includes the parsers, the networking code, the database code and the logic that handles the global state of the app.
The *controller* directory contains all artifacts that are not directly related to the view or the model. This includes the parsers, the networking code, the database code and the logic that handles the global state of the app.
Loading

0 comments on commit 9e6b7f0

Please sign in to comment.