Skip to content

Commit

Permalink
infra(server)!: fix typeorm asset entity relations (immich-app#1782)
Browse files Browse the repository at this point in the history
* fix: add correct relations to asset typeorm entity

* fix: add missing createdAt column to asset entity

* ci: run check to make sure generated API is up-to-date

* ci: cancel workflows that aren't for the latest commit in a branch

* chore: add fvm config for flutter
  • Loading branch information
zackpollard authored Feb 19, 2023
1 parent 000d0a0 commit 5ad4e5b
Show file tree
Hide file tree
Showing 65 changed files with 432 additions and 306 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-sign-android:
name: Build and sign Android
Expand All @@ -24,7 +28,7 @@ jobs:
github_ref="${{ github.sha }}"
ref="${input_ref:-$github_ref}"
echo "ref=$ref" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
ref: ${{ steps.get-ref.outputs.ref }}
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/cache-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,28 @@ on:
types:
- closed

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH=${{ github.ref }}
echo "Fetching list of cache keys"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
schedule:
- cron: '20 13 * * 1'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
Expand Down Expand Up @@ -48,11 +52,11 @@ jobs:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand All @@ -61,7 +65,7 @@ jobs:
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/dispatch_sdk_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
push:
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
update-sdk-repos:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_and_push:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/github-repo-stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- cron: "0 23 * * *"
workflow_dispatch: # Allow for running this manually.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
j1:
name: github-repo-stats
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ on:
required: false
type: boolean

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
bump_version:
runs-on: ubuntu-latest

outputs:
ref: ${{ steps.push-tag.outputs.commit_long_sha }}

steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -42,7 +46,7 @@ jobs:
message: "Version ${{ env.IMMICH_VERSION }}"
tag: ${{ env.IMMICH_VERSION }}
push: true

build_mobile:
uses: ./.github/workflows/build-mobile.yml
needs: bump_version
Expand All @@ -59,7 +63,7 @@ jobs:
uses: actions/checkout@v3
with:
token: ${{ secrets.ORG_RELEASE_TOKEN }}

- name: Download APK
uses: actions/download-artifact@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
mobile-dart-analyze:
name: Run Dart Code Analysis
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
e2e-tests:
name: Run end-to-end test suites
Expand Down Expand Up @@ -54,6 +58,27 @@ jobs:
working-directory: ./mobile
run: flutter test

generated-api-up-to-date:
name: Check generated files are up-to-date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run API generation
run: cd server && npm ci && npm run api:generate
- name: Find file changes
uses: tj-actions/[email protected]
id: verify-changed-files
with:
files: |
mobile/openapi
web/src/api/open-api
- name: Verify files have not changed
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
echo "ERROR: Generated files not up to date!"
echo "Changed files: ${{ steps.verify-changed-files.outputs.changed_files }}"
exit 1
mobile-integration-tests:
name: Run mobile end-to-end integration tests
runs-on: macos-latest
Expand Down
4 changes: 4 additions & 0 deletions mobile/.fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutterSdkVersion": "3.7.0",
"flavors": {}
}
3 changes: 2 additions & 1 deletion mobile/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
.pub-cache/
.pub/
/build/
.fvm/flutter_sdk

# Web related
lib/generated_plugin_registrant.dart
Expand All @@ -48,4 +49,4 @@ app.*.map.json
/android/app/release

# Fastlane
ios/fastlane/report.xml
ios/fastlane/report.xml
4 changes: 2 additions & 2 deletions mobile/lib/modules/album/views/album_viewer_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class AlbumViewerPage extends HookConsumerWidget {
}

Widget buildAlbumDateRange(Album album) {
final DateTime startDate = album.assets.first.createdAt;
final DateTime endDate = album.assets.last.createdAt; //Need default.
final DateTime startDate = album.assets.first.fileCreatedAt;
final DateTime endDate = album.assets.last.fileCreatedAt; //Need default.
final String startDateText =
DateFormat(startDate.year == endDate.year ? 'LLL d' : 'LLL d, y')
.format(startDate);
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class ExifBottomSheet extends HookConsumerWidget {
buildDate() {
return Text(
DateFormat('date_format'.tr()).format(
assetDetail.createdAt.toLocal(),
assetDetail.fileCreatedAt.toLocal(),
),
style: const TextStyle(
fontWeight: FontWeight.bold,
Expand Down
18 changes: 9 additions & 9 deletions mobile/lib/modules/backup/models/current_upload_asset.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import 'dart:convert';

class CurrentUploadAsset {
final String id;
final DateTime createdAt;
final DateTime fileCreatedAt;
final String fileName;
final String fileType;

CurrentUploadAsset({
required this.id,
required this.createdAt,
required this.fileCreatedAt,
required this.fileName,
required this.fileType,
});

CurrentUploadAsset copyWith({
String? id,
DateTime? createdAt,
DateTime? fileCreatedAt,
String? fileName,
String? fileType,
}) {
return CurrentUploadAsset(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
fileCreatedAt: fileCreatedAt ?? this.fileCreatedAt,
fileName: fileName ?? this.fileName,
fileType: fileType ?? this.fileType,
);
Expand All @@ -31,7 +31,7 @@ class CurrentUploadAsset {
final result = <String, dynamic>{};

result.addAll({'id': id});
result.addAll({'createdAt': createdAt.millisecondsSinceEpoch});
result.addAll({'fileCreatedAt': fileCreatedAt.millisecondsSinceEpoch});
result.addAll({'fileName': fileName});
result.addAll({'fileType': fileType});

Expand All @@ -41,7 +41,7 @@ class CurrentUploadAsset {
factory CurrentUploadAsset.fromMap(Map<String, dynamic> map) {
return CurrentUploadAsset(
id: map['id'] ?? '',
createdAt: DateTime.fromMillisecondsSinceEpoch(map['createdAt']),
fileCreatedAt: DateTime.fromMillisecondsSinceEpoch(map['fileCreatedAt']),
fileName: map['fileName'] ?? '',
fileType: map['fileType'] ?? '',
);
Expand All @@ -54,7 +54,7 @@ class CurrentUploadAsset {

@override
String toString() {
return 'CurrentUploadAsset(id: $id, createdAt: $createdAt, fileName: $fileName, fileType: $fileType)';
return 'CurrentUploadAsset(id: $id, fileCreatedAt: $fileCreatedAt, fileName: $fileName, fileType: $fileType)';
}

@override
Expand All @@ -63,15 +63,15 @@ class CurrentUploadAsset {

return other is CurrentUploadAsset &&
other.id == id &&
other.createdAt == createdAt &&
other.fileCreatedAt == fileCreatedAt &&
other.fileName == fileName &&
other.fileType == fileType;
}

@override
int get hashCode {
return id.hashCode ^
createdAt.hashCode ^
fileCreatedAt.hashCode ^
fileName.hashCode ^
fileType.hashCode;
}
Expand Down
14 changes: 7 additions & 7 deletions mobile/lib/modules/backup/models/error_upload_asset.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import 'package:photo_manager/photo_manager.dart';

class ErrorUploadAsset {
final String id;
final DateTime createdAt;
final DateTime fileCreatedAt;
final String fileName;
final String fileType;
final AssetEntity asset;
final String errorMessage;

const ErrorUploadAsset({
required this.id,
required this.createdAt,
required this.fileCreatedAt,
required this.fileName,
required this.fileType,
required this.asset,
Expand All @@ -19,15 +19,15 @@ class ErrorUploadAsset {

ErrorUploadAsset copyWith({
String? id,
DateTime? createdAt,
DateTime? fileCreatedAt,
String? fileName,
String? fileType,
AssetEntity? asset,
String? errorMessage,
}) {
return ErrorUploadAsset(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
fileCreatedAt: fileCreatedAt ?? this.fileCreatedAt,
fileName: fileName ?? this.fileName,
fileType: fileType ?? this.fileType,
asset: asset ?? this.asset,
Expand All @@ -37,7 +37,7 @@ class ErrorUploadAsset {

@override
String toString() {
return 'ErrorUploadAsset(id: $id, createdAt: $createdAt, fileName: $fileName, fileType: $fileType, asset: $asset, errorMessage: $errorMessage)';
return 'ErrorUploadAsset(id: $id, fileCreatedAt: $fileCreatedAt, fileName: $fileName, fileType: $fileType, asset: $asset, errorMessage: $errorMessage)';
}

@override
Expand All @@ -46,7 +46,7 @@ class ErrorUploadAsset {

return other is ErrorUploadAsset &&
other.id == id &&
other.createdAt == createdAt &&
other.fileCreatedAt == fileCreatedAt &&
other.fileName == fileName &&
other.fileType == fileType &&
other.asset == asset &&
Expand All @@ -56,7 +56,7 @@ class ErrorUploadAsset {
@override
int get hashCode {
return id.hashCode ^
createdAt.hashCode ^
fileCreatedAt.hashCode ^
fileName.hashCode ^
fileType.hashCode ^
asset.hashCode ^
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/modules/backup/providers/backup.provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BackupNotifier extends StateNotifier<BackUpState> {
selectedAlbumsBackupAssetsIds: const {},
currentUploadAsset: CurrentUploadAsset(
id: '...',
createdAt: DateTime.parse('2020-10-04'),
fileCreatedAt: DateTime.parse('2020-10-04'),
fileName: '...',
fileType: '...',
),
Expand Down
Loading

0 comments on commit 5ad4e5b

Please sign in to comment.